From abdbf1de646f007b6d76cfb3f416fdfaadb57903 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 29 Sep 2022 14:40:47 -0400 Subject: token counters now update when roll artist and style buttons are pressed https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/1194#issuecomment-1261203893 --- javascript/ui.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'javascript/ui.js') diff --git a/javascript/ui.js b/javascript/ui.js index bfe02410..88fd45ae 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -199,12 +199,21 @@ let txt2img_textarea, img2img_textarea = undefined; let wait_time = 800 let token_timeout; -function submit_prompt(event, generate_button_id) { - if (event.altKey && event.keyCode === 13) { - event.preventDefault(); - gradioApp().getElementById(generate_button_id).click(); - return; - } +function roll_artist_txt2img(prompt_text) { + update_token_counter("txt2img_token_button") + return prompt_text; +} +function roll_artist_img2img(prompt_text) { + update_token_counter("img2img_token_button") + return prompt_text; +} +function update_style_txt2img(prompt_text, negative_prompt, style1, style2) { + update_token_counter("txt2img_token_button") + return [prompt_text, negative_prompt, style1, style2] +} +function update_style_img2img(prompt_text, negative_prompt, style1, style2) { + update_token_counter("img2img_token_button") + return [prompt_text, negative_prompt, style1, style2] } function update_token_counter(button_id) { @@ -212,3 +221,10 @@ function update_token_counter(button_id) { clearTimeout(token_timeout); token_timeout = setTimeout(() => gradioApp().getElementById(button_id)?.click(), wait_time); } +function submit_prompt(event, generate_button_id) { + if (event.altKey && event.keyCode === 13) { + event.preventDefault(); + gradioApp().getElementById(generate_button_id).click(); + return; + } +} \ No newline at end of file -- cgit v1.2.1 From 3c6a049fc3c6b54ada3736710a7e86663ea7f3d9 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 30 Sep 2022 12:12:44 -0400 Subject: consolidated token counter functions --- javascript/ui.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'javascript/ui.js') diff --git a/javascript/ui.js b/javascript/ui.js index 88fd45ae..f94ed081 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -199,21 +199,18 @@ let txt2img_textarea, img2img_textarea = undefined; let wait_time = 800 let token_timeout; -function roll_artist_txt2img(prompt_text) { +function update_txt2img_tokens(...args) { update_token_counter("txt2img_token_button") - return prompt_text; + if (args.length == 2) + return args[0] + return args; } -function roll_artist_img2img(prompt_text) { - update_token_counter("img2img_token_button") - return prompt_text; -} -function update_style_txt2img(prompt_text, negative_prompt, style1, style2) { - update_token_counter("txt2img_token_button") - return [prompt_text, negative_prompt, style1, style2] -} -function update_style_img2img(prompt_text, negative_prompt, style1, style2) { + +function update_img2img_tokens(...args) { update_token_counter("img2img_token_button") - return [prompt_text, negative_prompt, style1, style2] + if (args.length == 2) + return args[0] + return args; } function update_token_counter(button_id) { -- cgit v1.2.1