aboutsummaryrefslogtreecommitdiffstats
path: root/javascript/ui.js
diff options
context:
space:
mode:
authorLiam <liamthekerr@gmail.com>2022-09-28 13:43:54 +0000
committerLiam <liamthekerr@gmail.com>2022-09-28 13:43:54 +0000
commit7ca9858c4c05b67089b095142ff792e07b5962a9 (patch)
treed7cfd0ca2237e63b6a2693843344a02a67339d9a /javascript/ui.js
parente5707b66d6db2c019bfccf66f9ba53e3daaea40b (diff)
downloadstable-diffusion-webui-gfx803-7ca9858c4c05b67089b095142ff792e07b5962a9.tar.gz
stable-diffusion-webui-gfx803-7ca9858c4c05b67089b095142ff792e07b5962a9.tar.bz2
stable-diffusion-webui-gfx803-7ca9858c4c05b67089b095142ff792e07b5962a9.zip
removed unused import; now using javascript to watch prompt textarea
Diffstat (limited to 'javascript/ui.js')
-rw-r--r--javascript/ui.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/javascript/ui.js b/javascript/ui.js
index 6cfa5c08..562d2552 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -182,21 +182,23 @@ onUiUpdate(function(){
});
json_elem.parentElement.style.display="none"
+
+ if (!txt2img_textarea) {
+ txt2img_textarea = gradioApp().querySelector("#txt2img_prompt > label > textarea");
+ txt2img_textarea?.addEventListener("input", () => update_token_counter("txt2img_token_button"));
+ }
+ if (!img2img_textarea) {
+ img2img_textarea = gradioApp().querySelector("#img2img_prompt > label > textarea");
+ img2img_textarea?.addEventListener("input", () => update_token_counter("img2img_token_button"));
+ }
})
+let txt2img_textarea, img2img_textarea = undefined;
let wait_time = 800
let token_timeout;
-function txt2img_token_counter(text) {
- return update_token_counter("txt2img_token_button", text);
-}
-
-function img2img_token_counter(text) {
- return update_token_counter("img2img_token_button", text);
-}
-function update_token_counter(button_id, text) {
+function update_token_counter(button_id) {
if (token_timeout)
clearTimeout(token_timeout);
token_timeout = setTimeout(() => gradioApp().getElementById(button_id)?.click(), wait_time);
- return [];
}