mirror of
https://github.com/sigoden/dufs.git
synced 2026-06-07 23:16:54 +03:00
feat: webui confirm on exit while uploading (#693)
This commit is contained in:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user