Sebastiankay commited on
Commit
852a993
·
verified ·
1 Parent(s): 9da8422

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -262,6 +262,28 @@ theme = gr.themes.Soft(
262
  radius_size="sm",
263
  )
264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  css = """
266
  body > gradio-app {
267
  background: var(--primary-950);
@@ -302,7 +324,7 @@ css = """
302
  }
303
  """
304
 
305
- with gr.Blocks(theme=theme, css=css) as demo:
306
  gr.Markdown(DESCRIPTION, elem_classes="top-description")
307
  with gr.Tab("Canny Edge", elem_id="tab_wrapper", elem_classes="tab_wrapper"):
308
  with gr.Row():
 
262
  radius_size="sm",
263
  )
264
 
265
+ js_test = """
266
+ // Call the below function
267
+ waitForElementToDisplay("#component-153",function(){alert("Hi");},1000,9000);
268
+
269
+ function waitForElementToDisplay(selector, callback, checkFrequencyInMs, timeoutInMs) {
270
+ var startTimeInMs = Date.now();
271
+ (function loopSearch() {
272
+ if (document.querySelector(selector) != null) {
273
+ callback();
274
+ return;
275
+ }
276
+ else {
277
+ setTimeout(function () {
278
+ if (timeoutInMs && Date.now() - startTimeInMs > timeoutInMs)
279
+ return;
280
+ loopSearch();
281
+ }, checkFrequencyInMs);
282
+ }
283
+ })();
284
+ }
285
+ """
286
+
287
  css = """
288
  body > gradio-app {
289
  background: var(--primary-950);
 
324
  }
325
  """
326
 
327
+ with gr.Blocks(theme=theme, css=css, js=js_test) as demo:
328
  gr.Markdown(DESCRIPTION, elem_classes="top-description")
329
  with gr.Tab("Canny Edge", elem_id="tab_wrapper", elem_classes="tab_wrapper"):
330
  with gr.Row():