removed unused import; now using javascript to watch prompt textarea

This commit is contained in:
Liam
2022-09-28 09:43:54 -04:00
parent e5707b66d6
commit 7ca9858c4c
2 changed files with 11 additions and 11 deletions

View File

@@ -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 [];
}