diff options
author | Devaev Maxim <[email protected]> | 2019-02-08 03:02:58 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-02-08 03:02:58 +0300 |
commit | e22426155dc3a05c8ce15fc7fbfd3df80aa57bfb (patch) | |
tree | 669587d077973b28145481387bff2d152d57695c /web/share/js | |
parent | 686f2a8bd4bdd9abc76aa0ebeca48e80faeef60f (diff) |
hid: led-yellow preferred
Diffstat (limited to 'web/share/js')
-rw-r--r-- | web/share/js/kvm/keyboard.js | 32 | ||||
-rw-r--r-- | web/share/js/kvm/mouse.js | 26 |
2 files changed, 36 insertions, 22 deletions
diff --git a/web/share/js/kvm/keyboard.js b/web/share/js/kvm/keyboard.js index cdf686c7..9b898925 100644 --- a/web/share/js/kvm/keyboard.js +++ b/web/share/js/kvm/keyboard.js @@ -72,24 +72,30 @@ function Keyboard() { }; var __updateLeds = function() { - tools.debug("Keyboard: update leds"); - if ( - __ws && ( - $("stream-window").classList.contains("window-active") - || $("keyboard-window").classList.contains("window-active") - ) - ) { + var is_captured = ( + $("stream-window").classList.contains("window-active") + || $("keyboard-window").classList.contains("window-active") + ); + var led = "led-gray"; + var title = "Keyboard free"; + + if (__ws) { if (__ok) { - $("hid-keyboard-led").className = "led-green"; - $("hid-keyboard-led").title = "Keyboard captured"; + if (is_captured) { + led = "led-green"; + title = "Keyboard captured"; + } } else { - $("hid-keyboard-led").className = "led-yellow"; - $("hid-keyboard-led").title = "Keyboard captured, HID offline"; + led = "led-yellow"; + title = (is_captured ? "Keyboard captured, HID offline" : "Keyboard free, HID offline"); } } else { - $("hid-keyboard-led").className = "led-gray"; - $("hid-keyboard-led").title = "Keyboard free"; + if (is_captured) { + title = "Keyboard captured, Pi-KVM offline"; + } } + $("hid-keyboard-led").className = led; + $("hid-keyboard-led").title = title; }; var __keyboardHandler = function(event, state) { diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js index 3f81a833..13807ec7 100644 --- a/web/share/js/kvm/mouse.js +++ b/web/share/js/kvm/mouse.js @@ -61,19 +61,27 @@ function Mouse() { }; var __updateLeds = function() { - if (__ws && (__stream_hovered || tools.browser.is_ios)) { - // Mouse is always available on iOS via touchscreen - if (__ok) { - $("hid-mouse-led").className = "led-green"; - $("hid-mouse-led").title = "Mouse tracked"; + var is_captured = (__stream_hovered || tools.browser.is_ios); + var led = "led-gray"; + var title = "Mouse free"; + + if (__ws) { + if (__ok) { + if (is_captured) { + led = "led-green"; + title = "Mouse captured"; + } } else { - $("hid-mouse-led").className = "led-yellow"; - $("hid-mouse-led").title = "Mouse tracked, HID offline"; + led = "led-yellow"; + title = (is_captured ? "Mouse captured, HID offline" : "Mouse free, HID offline"); } } else { - $("hid-mouse-led").className = "led-gray"; - $("hid-mouse-led").title = "Mouse free"; + if (is_captured) { + title = "Mouse captured, Pi-KVM offline"; + } } + $("hid-mouse-led").className = led; + $("hid-mouse-led").title = title; }; var __buttonHandler = function(event, state) { |