Add event listener beforeunload

When closing the window, a warning is shown if there are any render results.
This commit is contained in:
JeLuF 2022-11-10 23:23:20 +01:00
parent 3f26d03166
commit 5a06946469

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()