From 9bed9c0c41327eabb587025500f0899c4d5d5eac Mon Sep 17 00:00:00 2001 From: KOWX712 Date: Fri, 28 Feb 2025 23:42:04 +0800 Subject: [PATCH] fix: remove no scroll after selecting custom kb --- module/webui/scripts/menu_option.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/module/webui/scripts/menu_option.js b/module/webui/scripts/menu_option.js index 3dbc3d1..23e8818 100644 --- a/module/webui/scripts/menu_option.js +++ b/module/webui/scripts/menu_option.js @@ -320,7 +320,7 @@ async function listFiles(path, skipAnimation = false) { const source = await execCommand(`cat "${item.path}"`); const result = await setKeybox(source); if (result) { - fileSelector.style.display = 'none'; + closeCustomKeyboxSelector(); showPrompt('prompt.custom_key_set'); } else { showPrompt('prompt.custom_key_set_error'); @@ -384,21 +384,22 @@ document.querySelector('.back-button').addEventListener('click', async () => { // Close custom keybox selector document.querySelector('.close-selector').addEventListener('click', () => { + closeCustomKeyboxSelector(); +}); +fileSelector.addEventListener('click', (event) => { + if (event.target === fileSelector) { + closeCustomKeyboxSelector(); + } +}); + +// Function to close custom keybox selector +function closeCustomKeyboxSelector() { fileSelector.style.opacity = '0'; document.body.classList.remove("no-scroll"); setTimeout(() => { fileSelector.style.display = 'none'; }, 300); -}); -fileSelector.addEventListener('click', (event) => { - if (event.target === fileSelector) { - fileSelector.style.opacity = '0'; - document.body.classList.remove("no-scroll"); - setTimeout(() => { - fileSelector.style.display = 'none'; - }, 300); - } -}); +} // Open custom keybox selector document.getElementById('customkb').addEventListener('click', async () => {