yizhangliu commited on
Commit
e5c8bfa
1 Parent(s): 127d233

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -42
app.py CHANGED
@@ -59,55 +59,60 @@ start_work = """async() => {
59
  if (!gradioEl) {
60
  gradioEl = document.querySelector('body > gradio-app');
61
  }
62
-
63
  if (typeof window['gradioEl'] === 'undefined') {
 
64
  window['gradioEl'] = gradioEl;
65
-
66
- # tabitems = window['gradioEl'].querySelectorAll('.tabitem');
67
- # for (var i = 0; i < tabitems.length; i++) {
68
- # tabitems[i].childNodes[0].children[0].style.display='none';
69
- # tabitems[i].childNodes[0].children[1].children[0].style.display='none';
70
- # tabitems[i].childNodes[0].children[1].children[1].children[0].children[1].style.display="none";
71
- # }
72
- # tab_demo = window['gradioEl'].querySelectorAll('#tab_demo')[0];
73
- # tab_demo.style.display = "block";
74
- # tab_demo.setAttribute('style', 'height: 100%;');
 
75
 
76
  const page1 = window['gradioEl'].querySelectorAll('#page_1')[0];
77
  const page2 = window['gradioEl'].querySelectorAll('#page_2')[0];
78
-
79
  page1.style.display = "none";
80
  page2.style.display = "block";
81
-
82
- # window['prevPrompt'] = '';
83
- # window['doCheckPrompt'] = 0;
84
- # window['checkPrompt'] = function checkPrompt() {
85
- # try {
86
- # texts = window['gradioEl'].querySelectorAll('textarea');
87
- # text0 = texts[0];
88
- # text1 = texts[1];
89
- # if (window['doCheckPrompt'] === 0 && window['prevPrompt'] !== text1.value) {
90
- # console.log('_____new prompt___[' + text1.value + ']_');
91
- # window['doCheckPrompt'] = 1;
92
- # window['prevPrompt'] = text1.value;
93
- # for (var i = 2; i < texts.length; i++) {
94
- # setNativeValue(texts[i], text1.value);
95
- # texts[i].dispatchEvent(new Event('input', { bubbles: true }));
96
- # }
97
- # setTimeout(function() {
98
- # btns = window['gradioEl'].querySelectorAll('button');
99
- # for (var i = 0; i < btns.length; i++) {
100
- # if (btns[i].innerText == 'Submit') {
101
- # btns[i].click();
102
- # }
103
- # }
104
- # window['doCheckPrompt'] = 0;
105
- # }, 10);
106
- # }
107
- # } catch(e) {
108
- # }
109
- # }
110
- # window['checkPrompt_interval'] = window.setInterval("window.checkPrompt()", 100);
 
 
 
111
  }
112
 
113
  return false;
 
59
  if (!gradioEl) {
60
  gradioEl = document.querySelector('body > gradio-app');
61
  }
62
+ console.log('liuyz_1_')
63
  if (typeof window['gradioEl'] === 'undefined') {
64
+ console.log('liuyz_2_')
65
  window['gradioEl'] = gradioEl;
66
+ /*
67
+ tabitems = window['gradioEl'].querySelectorAll('.tabitem');
68
+ for (var i = 0; i < tabitems.length; i++) {
69
+ tabitems[i].childNodes[0].children[0].style.display='none';
70
+ tabitems[i].childNodes[0].children[1].children[0].style.display='none';
71
+ tabitems[i].childNodes[0].children[1].children[1].children[0].children[1].style.display="none";
72
+ }
73
+ tab_demo = window['gradioEl'].querySelectorAll('#tab_demo')[0];
74
+ tab_demo.style.display = "block";
75
+ tab_demo.setAttribute('style', 'height: 100%;');
76
+ */
77
 
78
  const page1 = window['gradioEl'].querySelectorAll('#page_1')[0];
79
  const page2 = window['gradioEl'].querySelectorAll('#page_2')[0];
80
+ console.log('liuyz_3_')
81
  page1.style.display = "none";
82
  page2.style.display = "block";
83
+ console.log('liuyz_4_')
84
+
85
+ /*
86
+ window['prevPrompt'] = '';
87
+ window['doCheckPrompt'] = 0;
88
+ window['checkPrompt'] = function checkPrompt() {
89
+ try {
90
+ texts = window['gradioEl'].querySelectorAll('textarea');
91
+ text0 = texts[0];
92
+ text1 = texts[1];
93
+ if (window['doCheckPrompt'] === 0 && window['prevPrompt'] !== text1.value) {
94
+ console.log('_____new prompt___[' + text1.value + ']_');
95
+ window['doCheckPrompt'] = 1;
96
+ window['prevPrompt'] = text1.value;
97
+ for (var i = 2; i < texts.length; i++) {
98
+ setNativeValue(texts[i], text1.value);
99
+ texts[i].dispatchEvent(new Event('input', { bubbles: true }));
100
+ }
101
+ setTimeout(function() {
102
+ btns = window['gradioEl'].querySelectorAll('button');
103
+ for (var i = 0; i < btns.length; i++) {
104
+ if (btns[i].innerText == 'Submit') {
105
+ btns[i].click();
106
+ }
107
+ }
108
+ window['doCheckPrompt'] = 0;
109
+ }, 10);
110
+ }
111
+ } catch(e) {
112
+ }
113
+ }
114
+ window['checkPrompt_interval'] = window.setInterval("window.checkPrompt()", 100);
115
+ */
116
  }
117
 
118
  return false;