summaryrefslogtreecommitdiff
path: root/web/share
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-09-01 12:24:17 +0300
committerMaxim Devaev <[email protected]>2022-09-01 12:24:17 +0300
commitc15d743f48487f4b0dab78471df14ffc44ba7bfd (patch)
tree16e1538c7cea361b31755ddff19ee4dfe24f9eff /web/share
parenta244c3601093f339f83cbde897b31ebb37c9f481 (diff)
pikvm/pikvm#813: optional page close confirmation
Diffstat (limited to 'web/share')
-rw-r--r--web/share/js/kvm/main.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/web/share/js/kvm/main.js b/web/share/js/kvm/main.js
index 85fcb5db..3717f71d 100644
--- a/web/share/js/kvm/main.js
+++ b/web/share/js/kvm/main.js
@@ -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();