diff options
author | CodeHatchling <steve@codehatch.com> | 2023-12-03 04:14:02 +0000 |
---|---|---|
committer | CodeHatchling <steve@codehatch.com> | 2023-12-03 04:14:02 +0000 |
commit | 3bd3a091604a332de6ff249870dabd2a91215499 (patch) | |
tree | 0323625627748ee44fc192bb2496585a4db56b5a /script.js | |
parent | bb04d400c95df01d191ef6c1a43e66b95425fa33 (diff) | |
parent | f0f100e67b78f686dc73cf3c8cad422e45cc9b8a (diff) | |
download | stable-diffusion-webui-gfx803-3bd3a091604a332de6ff249870dabd2a91215499.tar.gz stable-diffusion-webui-gfx803-3bd3a091604a332de6ff249870dabd2a91215499.tar.bz2 stable-diffusion-webui-gfx803-3bd3a091604a332de6ff249870dabd2a91215499.zip |
Merge remote-tracking branch 'origin/dev' into soft-inpainting
# Conflicts:
# modules/processing.py
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 33 |
1 files changed, 23 insertions, 10 deletions
@@ -124,16 +124,29 @@ 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 || e.altKey))) handled = true; - } else if (e.keyCode !== undefined) { - if ((e.keyCode == 13 && (e.metaKey || e.ctrlKey || e.altKey))) handled = true; - } - if (handled) { - var button = get_uiCurrentTabContent().querySelector('button[id$=_generate]'); - if (button) { - button.click(); + const isEnter = e.key === 'Enter' || e.keyCode === 13; + const isModifierKey = e.metaKey || e.ctrlKey || e.altKey; + + const interruptButton = get_uiCurrentTabContent().querySelector('button[id$=_interrupt]'); + const generateButton = get_uiCurrentTabContent().querySelector('button[id$=_generate]'); + + if (isEnter && isModifierKey) { + if (interruptButton.style.display === 'block') { + interruptButton.click(); + const callback = (mutationList) => { + for (const mutation of mutationList) { + if (mutation.type === 'attributes' && mutation.attributeName === 'style') { + if (interruptButton.style.display === 'none') { + generateButton.click(); + observer.disconnect(); + } + } + } + }; + const observer = new MutationObserver(callback); + observer.observe(interruptButton, {attributes: true}); + } else { + generateButton.click(); } e.preventDefault(); } |