aboutsummaryrefslogtreecommitdiffstats
path: root/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'javascript')
-rw-r--r--javascript/hints.js1
-rw-r--r--javascript/ui.js29
2 files changed, 30 insertions, 0 deletions
diff --git a/javascript/hints.js b/javascript/hints.js
index 623bc25c..04ec67fb 100644
--- a/javascript/hints.js
+++ b/javascript/hints.js
@@ -17,6 +17,7 @@ titles = {
"\u2199\ufe0f": "Read generation parameters from prompt or last generation if prompt is empty into user interface.",
"\u{1f4c2}": "Open images output directory",
"\u{1f4be}": "Save style",
+ "\U0001F5D1": "Clear prompt"
"\u{1f4cb}": "Apply selected styles to current prompt",
"Inpaint a part of image": "Draw a mask over an image, and the script will regenerate the masked area with content according to prompt",
diff --git a/javascript/ui.js b/javascript/ui.js
index 7e116465..be47ec64 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -131,6 +131,35 @@ 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 clear_prompt(_, _prompt_neg, confirmed, _token_counter) {
+confirmed = false
+
+if(confirm("Delete prompt?")) {
+ confirmed = true
+} else {
+return [_, _prompt_neg, confirmed, _token_counter]
+}
+
+ if(selected_tab_id() == "tab_txt2img") {
+ update_token_counter("img2img_token_button")
+ } else {
+ update_token_counter("txt2img_token_button")
+ }
+
+ return [_, _prompt_neg, confirmed, _token_counter]
+}
+
opts = {}