paulcalzada commited on
Commit
28d31ff
·
verified ·
1 Parent(s): 4c1cfe1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -122,9 +122,8 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
122
  outputs=[run_btn, loading_state],
123
  show_progress=False,
124
  js="""
125
- var deepPart = document.getElementById('deep-part');
126
- if (deepPart) {
127
- deepPart.classList.add('deep-hop-away');
128
  }
129
  """ # Call JS to start animation when button is clicked
130
  ).then(
@@ -136,11 +135,10 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
136
  inputs=[],
137
  outputs=[run_btn, loading_state],
138
  js="""
139
- var deepPart = document.getElementById('deep-part');
140
- if (deepPart) {
141
- deepPart.classList.remove('deep-hop-away');
142
  // This line forces the browser to re-render, ensuring the animation resets
143
- void deepPart.offsetWidth;
144
  }
145
  """ # Call JS to reset animation when generation finishes
146
  )
@@ -154,12 +152,14 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
154
  outputs=[],
155
  js="""
156
  (text) => {
157
- var el = document.createElement('textarea');
158
- el.value = text;
159
- document.body.appendChild(el);
160
- el.select();
161
- document.execCommand('copy');
162
- document.body.removeChild(el);
 
 
163
  }
164
  """
165
  )
 
122
  outputs=[run_btn, loading_state],
123
  show_progress=False,
124
  js="""
125
+ (e) => {
126
+ document.getElementById('deep-part').classList.add('deep-hop-away');
 
127
  }
128
  """ # Call JS to start animation when button is clicked
129
  ).then(
 
135
  inputs=[],
136
  outputs=[run_btn, loading_state],
137
  js="""
138
+ (e) => {
139
+ document.getElementById('deep-part').classList.remove('deep-hop-away');
 
140
  // This line forces the browser to re-render, ensuring the animation resets
141
+ void document.getElementById('deep-part').offsetWidth;
142
  }
143
  """ # Call JS to reset animation when generation finishes
144
  )
 
152
  outputs=[],
153
  js="""
154
  (text) => {
155
+ // Creates and copies a temporary element without using variable declarations
156
+ (function(el) {
157
+ el.value = text;
158
+ document.body.appendChild(el);
159
+ el.select();
160
+ document.execCommand('copy');
161
+ document.body.removeChild(el);
162
+ })(document.createElement('textarea'));
163
  }
164
  """
165
  )