diff options
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/ui.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/javascript/ui.js b/javascript/ui.js index cfd0dcd3..f19af550 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -151,6 +151,36 @@ function ask_for_style_name(_, prompt_text, negative_prompt_text) { return [name_, prompt_text, negative_prompt_text] } +// returns css id for currently selected tab in ui +function selected_tab_id() { + tabs = gradioApp().querySelectorAll('#tabs div.tabitem') + + for(var tab = 0; tab < tabs.length; tab++) { + if (tabs[tab].style.display != "none") return tabs[tab].id + + } + +} + +function trash_prompt(_,_, is_img2img) { + +if(!confirm("Delete prompt?")) return false + + if(selected_tab_id() == "tab_txt2img") { + gradioApp().querySelector("#txt2img_prompt > label > textarea").value = ""; + gradioApp().querySelector("#txt2img_neg_prompt > label > textarea").value = ""; + + update_token_counter("img2img_token_button") + } else { + gradioApp().querySelector("#img2img_prompt > label > textarea").value = ""; + gradioApp().querySelector("#img2img_neg_prompt > label > textarea").value = ""; + + update_token_counter("txt2img_token_button") + } + + return true +} + opts = {} |