From 7ca9858c4c05b67089b095142ff792e07b5962a9 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 28 Sep 2022 09:43:54 -0400 Subject: removed unused import; now using javascript to watch prompt textarea --- javascript/ui.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'javascript/ui.js') 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 []; } -- cgit v1.2.3