Merge pull request #461 from JeLuF/dontleave

Add event listener beforeunload
This commit is contained in:
cmdr2 2022-11-11 10:58:15 +05:30 committed by GitHub
commit f954542dda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1417,4 +1417,17 @@ document.querySelectorAll(".tab").forEach(tab => {
})
})
window.addEventListener("beforeunload", function(e) {
const msg = "Unsaved pictures will be lost!";
let elementList = document.getElementsByClassName("imageTaskContainer");
if (elementList.length != 0) {
e.preventDefault();
(e || window.event).returnValue = msg;
return msg;
} else {
return true;
}
});
createCollapsibles()