From b87f87646a10b9ab6d131818c49673e6a067f6d9 Mon Sep 17 00:00:00 2001 From: florinm03 <116092053+florinm03@users.noreply.github.com> Date: Sat, 25 Apr 2026 15:59:23 +0200 Subject: [PATCH] feat: webui confirm on exit while uploading (#693) --- assets/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/assets/index.js b/assets/index.js index 88dd4bd..fe33786 100644 --- a/assets/index.js +++ b/assets/index.js @@ -106,6 +106,15 @@ let $logoutBtn; */ let $userName; +// manage unload event to prevent leaving with uploads in progress +const beforeUnloadHandler = (event) => { + if (Uploader.queues.length > 0 || Uploader.runnings > 0) { + event.preventDefault(); + event.returnValue = ''; + return ''; // for some browsers + } +}; + // Produce table when window loads window.addEventListener("DOMContentLoaded", async () => { const $indexData = document.getElementById('index-data'); @@ -131,6 +140,8 @@ async function ready() { $logoutBtn = document.querySelector(".logout-btn"); $userName = document.querySelector(".user-name"); + window.addEventListener('beforeunload', beforeUnloadHandler); + addBreadcrumb(DATA.href, DATA.uri_prefix); if (DATA.kind === "Index") {