From 77bd953da2f96845b196f242f7ba51138cd54e3b Mon Sep 17 00:00:00 2001 From: Khachatur Avanesian Date: Sun, 15 Oct 2023 10:25:36 +0300 Subject: [PATCH] Update script.js Exclude lambda --- script.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/script.js b/script.js index 8bf1257da..2fab1554b 100644 --- a/script.js +++ b/script.js @@ -123,23 +123,25 @@ document.addEventListener("DOMContentLoaded", function() { /** * Add a Ctrl (Alt) + Enter as a shortcut to start / restart a generation */ -document.addEventListener('keydown', (e) => { - const isEnter = e.key === 'Enter' || e.keyCode === 13 - const isModifierKey = e.metaKey || e.ctrlKey || e.altKey +document.addEventListener('keydown', function(e) { + 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]') + 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() - setTimeout(() => generateButton.click(), 500) + interruptButton.click(); + setTimeout(function() { + generateButton.click(); + }, 500); } else { - generateButton.click() + generateButton.click(); } - e.preventDefault() + e.preventDefault(); } -}) +}); /** * checks that a UI element is not in another hidden element or tab content