diff options
author | Devaev Maxim <[email protected]> | 2018-07-14 05:26:51 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-07-14 05:26:51 +0300 |
commit | 9853990075056232f2c1c5454c1e9e34c39710ee (patch) | |
tree | 04f114cd0f65499a2c0879a9455fc74fe6eb01f0 | |
parent | 2b8d6b215cf61cd04d21d7d1931985eeb36cccb3 (diff) |
improved js
-rw-r--r-- | kvmd/web/js/kvmd.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/kvmd/web/js/kvmd.js b/kvmd/web/js/kvmd.js index e6d00f31..044908e1 100644 --- a/kvmd/web/js/kvmd.js +++ b/kvmd/web/js/kvmd.js @@ -17,10 +17,10 @@ function __startSessionPoller() { ws.onmessage = function(event) { // console.log("KVMD:", event.data); event = JSON.parse(event.data); - if (event.msg_type == "event") { - if (event.msg.event == "pong") { + if (event.msg_type === "event") { + if (event.msg.event === "pong") { __pingServer.missed_heartbeats = 0; - } else if (event.msg.event == "atx_state") { + } else if (event.msg.event === "atx_state") { leds = event.msg.event_attrs.leds; document.getElementById("atx-power-led").className = (leds.power ? "led-on" : "led-off"); document.getElementById("atx-hdd-led").className = (leds.hdd ? "led-busy" : "led-off"); @@ -67,8 +67,8 @@ function __setSessionStatus(status) { function __installHidHandlers(ws) { var http = __request("GET", "/kvmd/hid", function() { - if (http.readyState == 4) { - if (http.status == 200) { + if (http.readyState === 4) { + if (http.status === 200) { features = JSON.parse(http.responseText).result.features; if (features.keyboard) { // https://www.codeday.top/2017/05/03/24906.html @@ -154,7 +154,7 @@ __onMouseMove.pos = {x: 0, y:0}; function __handleMouseMove(ws) { var pos = __onMouseMove.pos; - if (pos.x != __handleMouseMove.old_pos.x || pos.y != __handleMouseMove.old_pos.y) { + if (pos.x !== __handleMouseMove.old_pos.x || pos.y !== __handleMouseMove.old_pos.y) { ws.send(JSON.stringify({ event_type: "mouse_move", to: pos, @@ -203,10 +203,10 @@ function clickAtxButton(el_button) { if (button && confirm(confirm_msg)) { __setAtxButtonsBusy(true); var http = __request("POST", "/kvmd/atx/click?button=" + button, function() { - if (http.readyState == 4) { - if (http.status == 409) { + if (http.readyState === 4) { + if (http.status === 409) { alert("Performing another ATX operation for other client, please try again later"); - } else if (http.status != 200) { + } else if (http.status !== 200) { alert("Click error:", http.responseText); } __setAtxButtonsBusy(false); @@ -229,11 +229,11 @@ function __setAtxButtonsBusy(busy) { // ----------------------------------------------------------------------------- function __startStreamPoller() { var http = __request("GET", "/streamer/?action=snapshot", function() { - if (http.readyState == 2 || http.readyState == 4) { + if (http.readyState === 2 || http.readyState === 4) { var status = http.status; http.onreadystatechange = null; http.abort(); - if (status != 200) { + if (status !== 200) { console.log("Refreshing stream ..."); __startStreamPoller.last = false; document.getElementById("stream-image").className = "stream-image-off"; @@ -252,7 +252,7 @@ __startStreamPoller.last = false; function __refreshStream() { var http = __request("GET", "/kvmd/streamer", function() { - if (http.readyState == 4 && http.status == 200) { + if (http.readyState === 4 && http.status === 200) { size = JSON.parse(http.responseText).result.size; el_stream_box = document.getElementById("stream-image"); el_stream_box.style.width = size.width + "px"; @@ -265,8 +265,8 @@ function __refreshStream() { function clickResetStreamButton(el_button) { __setButtonBusy(el_button, true); var http = __request("POST", "/kvmd/streamer/reset", function() { - if (http.readyState == 4) { - if (http.status != 200) { + if (http.readyState === 4) { + if (http.status !== 200) { alert("Can't reset stream:", http.responseText); } __setButtonBusy(el_button, false); |