mirror of
https://github.com/sigoden/dufs.git
synced 2026-06-07 15:59:03 +03:00
feat: webui confirm on exit while uploading (#693)
This commit is contained in:
@@ -106,6 +106,15 @@ let $logoutBtn;
|
|||||||
*/
|
*/
|
||||||
let $userName;
|
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
|
// Produce table when window loads
|
||||||
window.addEventListener("DOMContentLoaded", async () => {
|
window.addEventListener("DOMContentLoaded", async () => {
|
||||||
const $indexData = document.getElementById('index-data');
|
const $indexData = document.getElementById('index-data');
|
||||||
@@ -131,6 +140,8 @@ async function ready() {
|
|||||||
$logoutBtn = document.querySelector(".logout-btn");
|
$logoutBtn = document.querySelector(".logout-btn");
|
||||||
$userName = document.querySelector(".user-name");
|
$userName = document.querySelector(".user-name");
|
||||||
|
|
||||||
|
window.addEventListener('beforeunload', beforeUnloadHandler);
|
||||||
|
|
||||||
addBreadcrumb(DATA.href, DATA.uri_prefix);
|
addBreadcrumb(DATA.href, DATA.uri_prefix);
|
||||||
|
|
||||||
if (DATA.kind === "Index") {
|
if (DATA.kind === "Index") {
|
||||||
|
|||||||
Reference in New Issue
Block a user