lnyan commited on
Commit
bb89ebf
1 Parent(s): 9596438

Remove all shadowRoot

Browse files
Files changed (6) hide show
  1. app.py +1 -1
  2. index.html +3 -3
  3. js/outpaint.js +6 -6
  4. js/proceed.js +1 -1
  5. js/setup.js +2 -2
  6. js/upload.js +3 -3
app.py CHANGED
@@ -207,7 +207,7 @@ def load_js(name):
207
  return f"""
208
  function (x)
209
  {{
210
- let frame=document.querySelector("gradio-app").shadowRoot.querySelector("#sdinfframe").contentWindow;
211
  frame.postMessage(["click","{name}"], "*");
212
  return x;
213
  }}
 
207
  return f"""
208
  function (x)
209
  {{
210
+ let frame=document.querySelector("gradio-app").querySelector("#sdinfframe").contentWindow;
211
  frame.postMessage(["click","{name}"], "*");
212
  return x;
213
  }}
index.html CHANGED
@@ -102,9 +102,9 @@ async def draw_canvas() -> None:
102
 
103
  async def draw_canvas_func(event):
104
  try:
105
- width=parent.document.querySelector("gradio-app").shadowRoot.querySelector("#canvas_width input").value
106
- height=parent.document.querySelector("gradio-app").shadowRoot.querySelector("#canvas_height input").value
107
- selection_size=parent.document.querySelector("gradio-app").shadowRoot.querySelector("#selection_size input").value
108
  except:
109
  width=1024
110
  height=768
 
102
 
103
  async def draw_canvas_func(event):
104
  try:
105
+ width=parent.document.querySelector("gradio-app").querySelector("#canvas_width input").value
106
+ height=parent.document.querySelector("gradio-app").querySelector("#canvas_height input").value
107
+ selection_size=parent.document.querySelector("gradio-app").querySelector("#selection_size input").value
108
  except:
109
  width=1024
110
  height=768
js/outpaint.js CHANGED
@@ -4,12 +4,12 @@ function(a){
4
  console.log("setup outpaint here");
5
  window.my_observe_outpaint = new MutationObserver(function (event) {
6
  console.log(event);
7
- let app=document.querySelector("gradio-app").shadowRoot;
8
  let frame=app.querySelector("#sdinfframe").contentWindow;
9
- var str=document.querySelector("gradio-app").shadowRoot.querySelector("#output textarea").value;
10
  frame.postMessage(["outpaint", str], "*");
11
  });
12
- window.my_observe_outpaint_target=document.querySelector("gradio-app").shadowRoot.querySelector("#output span")
13
  window.my_observe_outpaint.observe(window.my_observe_outpaint_target, {
14
  attributes: false,
15
  subtree: true,
@@ -19,12 +19,12 @@ function(a){
19
  window.addEventListener("message", function(e){
20
  if(e.data[0]=="transfer")
21
  {
22
- document.querySelector("gradio-app").shadowRoot.querySelector("#input textarea").value=e.data[1];
23
- document.querySelector("gradio-app").shadowRoot.querySelector("#proceed").click();
24
  }
25
  });
26
  }
27
- let app=document.querySelector("gradio-app").shadowRoot;
28
  let frame=app.querySelector("#sdinfframe").contentWindow;
29
  frame.postMessage(["transfer"],"*")
30
  return a;
 
4
  console.log("setup outpaint here");
5
  window.my_observe_outpaint = new MutationObserver(function (event) {
6
  console.log(event);
7
+ let app=document.querySelector("gradio-app");
8
  let frame=app.querySelector("#sdinfframe").contentWindow;
9
+ var str=document.querySelector("gradio-app").querySelector("#output textarea").value;
10
  frame.postMessage(["outpaint", str], "*");
11
  });
12
+ window.my_observe_outpaint_target=document.querySelector("gradio-app").querySelector("#output span")
13
  window.my_observe_outpaint.observe(window.my_observe_outpaint_target, {
14
  attributes: false,
15
  subtree: true,
 
19
  window.addEventListener("message", function(e){
20
  if(e.data[0]=="transfer")
21
  {
22
+ document.querySelector("gradio-app").querySelector("#input textarea").value=e.data[1];
23
+ document.querySelector("gradio-app").querySelector("#proceed").click();
24
  }
25
  });
26
  }
27
+ let app=document.querySelector("gradio-app");
28
  let frame=app.querySelector("#sdinfframe").contentWindow;
29
  frame.postMessage(["transfer"],"*")
30
  return a;
js/proceed.js CHANGED
@@ -7,7 +7,7 @@ function(sel_buffer_str,
7
  fill_mode,
8
  enable_safety,
9
  state){
10
- sel_buffer = document.querySelector("gradio-app").shadowRoot.querySelector("#input textarea").value;
11
  return [
12
  sel_buffer,
13
  prompt_text,
 
7
  fill_mode,
8
  enable_safety,
9
  state){
10
+ sel_buffer = document.querySelector("gradio-app").querySelector("#input textarea").value;
11
  return [
12
  sel_buffer,
13
  prompt_text,
js/setup.js CHANGED
@@ -1,11 +1,11 @@
1
  function(token_val, width, height, size){
2
- let app=document.querySelector("gradio-app").shadowRoot;
3
  app.querySelector("#sdinfframe").style.height=height+"px";
4
  let frame=app.querySelector("#sdinfframe").contentWindow.document;
5
  if(frame.querySelector("#setup").value=="0")
6
  {
7
  window.my_setup=setInterval(function(){
8
- let frame=document.querySelector("gradio-app").shadowRoot.querySelector("#sdinfframe").contentWindow.document;
9
  console.log("Check PyScript...")
10
  if(frame.querySelector("#setup").value=="1")
11
  {
 
1
  function(token_val, width, height, size){
2
+ let app=document.querySelector("gradio-app");
3
  app.querySelector("#sdinfframe").style.height=height+"px";
4
  let frame=app.querySelector("#sdinfframe").contentWindow.document;
5
  if(frame.querySelector("#setup").value=="0")
6
  {
7
  window.my_setup=setInterval(function(){
8
+ let frame=document.querySelector("gradio-app").querySelector("#sdinfframe").contentWindow.document;
9
  console.log("Check PyScript...")
10
  if(frame.querySelector("#setup").value=="1")
11
  {
js/upload.js CHANGED
@@ -4,11 +4,11 @@ function(a,b){
4
  console.log("setup upload here");
5
  window.my_observe_upload = new MutationObserver(function (event) {
6
  console.log(event);
7
- var frame=document.querySelector("gradio-app").shadowRoot.querySelector("#sdinfframe").contentWindow;
8
- var str=document.querySelector("gradio-app").shadowRoot.querySelector("#upload textarea").value;
9
  frame.postMessage(["upload", str], "*");
10
  });
11
- window.my_observe_upload_target = document.querySelector("gradio-app").shadowRoot.querySelector("#upload span");
12
  window.my_observe_upload.observe(window.my_observe_upload_target, {
13
  attributes: false,
14
  subtree: true,
 
4
  console.log("setup upload here");
5
  window.my_observe_upload = new MutationObserver(function (event) {
6
  console.log(event);
7
+ var frame=document.querySelector("gradio-app").querySelector("#sdinfframe").contentWindow;
8
+ var str=document.querySelector("gradio-app").querySelector("#upload textarea").value;
9
  frame.postMessage(["upload", str], "*");
10
  });
11
+ window.my_observe_upload_target = document.querySelector("gradio-app").querySelector("#upload span");
12
  window.my_observe_upload.observe(window.my_observe_upload_target, {
13
  attributes: false,
14
  subtree: true,