From 976662df8310b145f23ac22360a3bd9e38ed65a1 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Fri, 13 Aug 2021 16:39:56 +0300 Subject: bindSimpleSwitch() --- web/share/js/kvm/atx.js | 6 +----- web/share/js/kvm/hid.js | 5 +---- web/share/js/kvm/mouse.js | 5 +---- 3 files changed, 3 insertions(+), 13 deletions(-) (limited to 'web/share/js/kvm') diff --git a/web/share/js/kvm/atx.js b/web/share/js/kvm/atx.js index fb1e0d28..b0978b2c 100644 --- a/web/share/js/kvm/atx.js +++ b/web/share/js/kvm/atx.js @@ -36,11 +36,7 @@ export function Atx() { $("atx-power-led").title = "Power Led"; $("atx-hdd-led").title = "Disk Activity Led"; - $("atx-ask-switch").checked = tools.storage.getBool("atx.ask", true); - tools.el.setOnClick($("atx-ask-switch"), function() { - tools.storage.setBool("atx.ask", $("atx-ask-switch").checked); - }, false); - + tools.storage.bindSimpleSwitch($("atx-ask-switch"), "atx.ask", true); for (let args of [ ["atx-power-button", "power", "Are you sure you want to press the power button?"], diff --git a/web/share/js/kvm/hid.js b/web/share/js/kvm/hid.js index 6dfad27b..017eecba 100644 --- a/web/share/js/kvm/hid.js +++ b/web/share/js/kvm/hid.js @@ -74,10 +74,7 @@ export function Hid(__getResolution) { window.addEventListener("pagehide", __releaseAll); window.addEventListener("blur", __releaseAll); - $("hid-pak-ask-switch").checked = tools.storage.getBool("hid.pak.ask", true); - tools.el.setOnClick($("hid-pak-ask-switch"), function() { - tools.storage.setBool("hid.pak.ask", $("hid-pak-ask-switch").checked); - }, false); + tools.storage.bindSimpleSwitch($("hid-pak-ask-switch"), "hid.pak.ask", true); $("hid-pak-keymap-selector").addEventListener("change", function() { tools.storage.set("hid.pak.keymap", $("hid-pak-keymap-selector").value); diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js index c3215d55..cfc70bff 100644 --- a/web/share/js/kvm/mouse.js +++ b/web/share/js/kvm/mouse.js @@ -61,10 +61,7 @@ export function Mouse(__getResolution, __recordWsEvent) { $("stream-box").onwheel = __streamWheelHandler; $("stream-box").ontouchstart = (event) => __streamTouchMoveHandler(event); - $("hid-mouse-squash-switch").checked = tools.storage.getBool("hid.mouse.squash", true); - tools.el.setOnClick($("hid-mouse-squash-switch"), function() { - tools.storage.setBool("hid.mouse.squash", $("hid-mouse-squash-switch").checked); - }, false); + tools.storage.bindSimpleSwitch($("hid-mouse-squash-switch"), "hid.mouse.squash", true); setInterval(__sendMove, 100); }; -- cgit v1.2.3