aboutsummaryrefslogtreecommitdiff
path: root/script.js
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2022-10-11 21:50:19 +0300
committerGitHub <noreply@github.com>2022-10-11 21:50:19 +0300
commit419e539fe33e5bd1f7c7f55b477f955f6bdfc822 (patch)
tree131ea9501cefd29b7e5cb4b3e1ea36d76c64beb6 /script.js
parent2536ecbb1790da2af0d61b6a26f38732cba665cd (diff)
parentd7474a5185df2af84a93a12bc7e140d24e0fc516 (diff)
Merge branch 'learning_rate-scheduling' into learnschedule
Diffstat (limited to 'script.js')
-rw-r--r--script.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/script.js b/script.js
index cf989605..9543cbe6 100644
--- a/script.js
+++ b/script.js
@@ -6,6 +6,10 @@ function get_uiCurrentTab() {
return gradioApp().querySelector('.tabs button:not(.border-transparent)')
}
+function get_uiCurrentTabContent() {
+ return gradioApp().querySelector('.tabitem[id^=tab_]:not([style*="display: none"])')
+}
+
uiUpdateCallbacks = []
uiTabChangeCallbacks = []
let uiCurrentTab = null
@@ -41,6 +45,25 @@ document.addEventListener("DOMContentLoaded", function() {
});
/**
+ * Add a ctrl+enter as a shortcut to start a generation
+ */
+ document.addEventListener('keydown', function(e) {
+ var handled = false;
+ if (e.key !== undefined) {
+ if((e.key == "Enter" && (e.metaKey || e.ctrlKey))) handled = true;
+ } else if (e.keyCode !== undefined) {
+ if((e.keyCode == 13 && (e.metaKey || e.ctrlKey))) handled = true;
+ }
+ if (handled) {
+ button = get_uiCurrentTabContent().querySelector('button[id$=_generate]');
+ if (button) {
+ button.click();
+ }
+ e.preventDefault();
+ }
+})
+
+/**
* checks that a UI element is not in another hidden element or tab content
*/
function uiElementIsVisible(el) {