summaryrefslogtreecommitdiff
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
parenta244c3601093f339f83cbde897b31ebb37c9f481 (diff)
pikvm/pikvm#813: optional page close confirmation
-rw-r--r--web/kvm/index.html9
-rw-r--r--web/kvm/navbar-system.pug2
-rw-r--r--web/share/js/kvm/main.js16
3 files changed, 22 insertions, 5 deletions
diff --git a/web/kvm/index.html b/web/kvm/index.html
index 87414671..803223ac 100644
--- a/web/kvm/index.html
+++ b/web/kvm/index.html
@@ -318,6 +318,15 @@
</div>
</td>
</tr>
+ <tr>
+ <td>Ask page close confirmation:</td>
+ <td align="right">
+ <div class="switch-box">
+ <input checked type="checkbox" id="page-close-ask-switch">
+ <label for="page-close-ask-switch"><span class="switch-inner"></span><span class="switch"></span></label>
+ </div>
+ </td>
+ </tr>
</table>
<hr>
<div class="buttons buttons-row">
diff --git a/web/kvm/navbar-system.pug b/web/kvm/navbar-system.pug
index c415c8e9..4bf4ea77 100644
--- a/web/kvm/navbar-system.pug
+++ b/web/kvm/navbar-system.pug
@@ -96,6 +96,8 @@ li(class="right")
label(for="gpio-switch-__v3_usb_breaker__")
span(class="switch-inner")
span(class="switch")
+ tr
+ +menu_switch_notable("page-close-ask-switch", "Ask page close confirmation", true, true)
hr
div(class="buttons buttons-row")
button(data-force-hide-menu data-show-window="keyboard-window" class="row50") &bull; Show keyboard
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();