diff options
Diffstat (limited to 'web/js/kvm')
-rw-r--r-- | web/js/kvm/atx.js | 6 | ||||
-rw-r--r-- | web/js/kvm/hid.js | 14 | ||||
-rw-r--r-- | web/js/kvm/keyboard.js | 14 | ||||
-rw-r--r-- | web/js/kvm/msd.js | 14 | ||||
-rw-r--r-- | web/js/kvm/stream.js | 16 |
5 files changed, 29 insertions, 35 deletions
diff --git a/web/js/kvm/atx.js b/web/js/kvm/atx.js index d637c742..9ef0c063 100644 --- a/web/js/kvm/atx.js +++ b/web/js/kvm/atx.js @@ -18,9 +18,9 @@ function Atx() { $("atx-power-led").className = (state.leds.power ? "led-green" : "led-gray"); $("atx-hdd-led").className = (state.leds.hdd ? "led-red" : "led-gray"); - $("atx-power-button").disabled = state.busy; - $("atx-power-button-long").disabled = state.busy; - $("atx-reset-button").disabled = state.busy; + ui.switchDisabled($("atx-power-button"), state.busy); + ui.switchDisabled($("atx-power-button-long"), state.busy); + ui.switchDisabled($("atx-reset-button"), state.busy); }; self.clearState = function() { diff --git a/web/js/kvm/hid.js b/web/js/kvm/hid.js index e7877484..c837b809 100644 --- a/web/js/kvm/hid.js +++ b/web/js/kvm/hid.js @@ -54,9 +54,9 @@ function Hid() { /********************************************************************************/ self.setSocket = function(ws) { - $("hid-pak-text").disabled = !ws; - $("hid-pak-button").disabled = !ws; - $("hid-reset-button").disabled = !ws; + ui.switchDisabled($("hid-pak-text"), !ws); + ui.switchDisabled($("hid-pak-button"), !ws); + ui.switchDisabled($("hid-reset-button"), !ws); __ws = ws; __keyboard.setSocket(ws); __mouse.setSocket(ws); @@ -154,8 +154,8 @@ function Hid() { ui.confirm(confirm_msg).then(function(ok) { if (ok) { - $("hid-pak-text").disabled = true; - $("hid-pak-button").disabled = true; + ui.switchDisabled($("hid-pak-text"), true); + ui.switchDisabled($("hid-pak-button"), true); $("hid-pak-led").className = "led-yellow-rotating-fast"; $("hid-pak-led").title = "Autotyping..."; @@ -169,8 +169,8 @@ function Hid() { iterate(); } else { $("hid-pak-text").value = ""; - $("hid-pak-text").disabled = false; - $("hid-pak-button").disabled = false; + ui.switchDisabled($("hid-pak-text"), false); + ui.switchDisabled($("hid-pak-button"), false); $("hid-pak-led").className = "led-gray"; $("hid-pak-led").title = ""; } diff --git a/web/js/kvm/keyboard.js b/web/js/kvm/keyboard.js index 273038fa..3c821406 100644 --- a/web/js/kvm/keyboard.js +++ b/web/js/kvm/keyboard.js @@ -21,9 +21,8 @@ function Keyboard() { $("stream-window").onfocus = __updateLeds; $("stream-window").onblur = __updateLeds; - window.addEventListener("focus", __updateLeds); - window.addEventListener("pagehide", __updateLeds); - window.addEventListener("blur", __updateLeds); + window.addEventListener("focusin", __updateLeds); + window.addEventListener("focusout", __updateLeds); Array.prototype.forEach.call($$("key"), function(el_key) { tools.setOnDown(el_key, () => __clickHandler(el_key, true)); @@ -67,14 +66,9 @@ function Keyboard() { }; var __updateLeds = function() { - tools.info("Update leds"); + tools.debug("Keyboard: update leds"); if ( - __ws - && ( - document.activeElement === $("stream-window") - || document.activeElement === $("keyboard-window") - ) - && ( + __ws && ( $("stream-window").classList.contains("window-active") || $("keyboard-window").classList.contains("window-active") ) diff --git a/web/js/kvm/msd.js b/web/js/kvm/msd.js index 057dec5b..4ce5d464 100644 --- a/web/js/kvm/msd.js +++ b/web/js/kvm/msd.js @@ -61,7 +61,7 @@ function Msd() { __applyState(); }); __applyState(); - $(`msd-switch-to-${to}-button`).disabled = true; + ui.switchDisabled($(`msd-switch-to-${to}-button`), true); }; var __selectNewImageFile = function() { @@ -120,12 +120,12 @@ function Msd() { $("msd-current-image-size").innerHTML = (__state.in_operate && __state.info.image ? __formatSize(__state.info.image.size) : "None"); $("msd-storage-size").innerHTML = (__state.in_operate ? __formatSize(__state.info.size) : "Unavailable"); - $("msd-switch-to-kvm-button").disabled = (!__state.in_operate || __state.connected_to === "kvm" || __state.busy); - $("msd-switch-to-server-button").disabled = (!__state.in_operate || __state.connected_to === "server" || __state.busy); - $("msd-select-new-image-button").disabled = (!__state.in_operate || __state.connected_to !== "kvm" || __state.busy || __upload_http); - $("msd-upload-new-image-button").disabled = (!__state.in_operate || __state.connected_to !== "kvm" || __state.busy || !__image_file); - $("msd-abort-uploading-button").disabled = (!__state.in_operate || !__upload_http); - $("msd-reset-button").disabled = (!__state.in_operate || __upload_http); + ui.switchDisabled($("msd-switch-to-kvm-button"), (!__state.in_operate || __state.connected_to === "kvm" || __state.busy)); + ui.switchDisabled($("msd-switch-to-server-button"), (!__state.in_operate || __state.connected_to === "server" || __state.busy)); + ui.switchDisabled($("msd-select-new-image-button"), (!__state.in_operate || __state.connected_to !== "kvm" || __state.busy || __upload_http)); + ui.switchDisabled($("msd-upload-new-image-button"), (!__state.in_operate || __state.connected_to !== "kvm" || __state.busy || !__image_file)); + ui.switchDisabled($("msd-abort-uploading-button"), (!__state.in_operate || !__upload_http)); + ui.switchDisabled($("msd-reset-button"), (!__state.in_operate || __upload_http)); $("msd-new-image").style.display = (__image_file ? "block" : "none"); $("msd-progress").setAttribute("data-label", "Waiting for upload ..."); diff --git a/web/js/kvm/stream.js b/web/js/kvm/stream.js index 4efaefed..52e01fc4 100644 --- a/web/js/kvm/stream.js +++ b/web/js/kvm/stream.js @@ -49,7 +49,7 @@ function Streamer() { } if (!$("stream-quality-slider").activated) { - $("stream-quality-slider").disabled = false; + ui.switchDisabled($("stream-quality-slider"), false); if ($("stream-quality-slider").value !== source.quality) { $("stream-quality-slider").value = source.quality; __updateQualityValue(source.quality); @@ -57,7 +57,7 @@ function Streamer() { } if (!$("stream-desired-fps-slider").activated) { - $("stream-desired-fps-slider").disabled = false; + ui.switchDisabled($("stream-desired-fps-slider"), false); if ($("stream-desired-fps-slider").value !== source.desired_fps) { $("stream-desired-fps-slider").value = source.desired_fps; __updateDesiredFpsValue(source.desired_fps); @@ -101,8 +101,8 @@ function Streamer() { $("stream-box").classList.remove("stream-box-inactive"); $("stream-led").className = "led-green"; $("stream-led").title = "Stream is active"; - $("stream-screenshot-button").disabled = false; - $("stream-reset-button").disabled = false; + ui.switchDisabled($("stream-screenshot-button"), false); + ui.switchDisabled($("stream-reset-button"), false); tools.info("Stream: acquired"); __prev = true; } @@ -121,10 +121,10 @@ function Streamer() { $("stream-box").classList.add("stream-box-inactive"); $("stream-led").className = "led-gray"; $("stream-led").title = "Stream inactive"; - $("stream-screenshot-button").disabled = true; - $("stream-reset-button").disabled = true; - $("stream-quality-slider").disabled = true; - $("stream-desired-fps-slider").disabled = true; + ui.switchDisabled($("stream-screenshot-button"), true); + ui.switchDisabled($("stream-reset-button"), true); + ui.switchDisabled($("stream-quality-slider"), true); + ui.switchDisabled($("stream-desired-fps-slider"), true); __client_key = tools.makeId(); __client_id = ""; |