pikvm/pikvm#813: optional page close confirmation

This commit is contained in:
Maxim Devaev
2022-09-01 12:24:17 +03:00
parent a244c36010
commit c15d743f48
3 changed files with 22 additions and 5 deletions

View File

@@ -32,11 +32,17 @@ import {Session} from "./session.js";
export function main() {
if (checkBrowser()) {
window.onbeforeunload = function(event) {
let text = "Are you sure you want to close PiKVM session?";
event.returnValue = text;
return text;
};
tools.storage.bindSimpleSwitch($("page-close-ask-switch"), "page.close.ask", true, function(value) {
if (value) {
window.onbeforeunload = function(event) {
let text = "Are you sure you want to close PiKVM session?";
event.returnValue = text;
return text;
};
} else {
window.onbeforeunload = null;
}
});
initWindowManager();