diff options
author | Devaev Maxim <[email protected]> | 2018-07-17 00:44:38 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-07-17 00:44:38 +0300 |
commit | 514aac8d82241e2907d4d7672765912020d742dc (patch) | |
tree | e25570aa37d14a9fb8a31758212fc0985c131e27 /kvmd/web/js/msd.js | |
parent | caf7f4c99bce4533e7fc1b9f7aeaaf605baf819c (diff) |
real-time icons and buttons state
Diffstat (limited to 'kvmd/web/js/msd.js')
-rw-r--r-- | kvmd/web/js/msd.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/kvmd/web/js/msd.js b/kvmd/web/js/msd.js new file mode 100644 index 00000000..5ae851ea --- /dev/null +++ b/kvmd/web/js/msd.js @@ -0,0 +1,24 @@ +var msd = new function() { + this.loadInitialState = function() { + var http = tools.makeRequest("GET", "/kvmd/msd", function() { + if (http.readyState === 4) { + if (http.status === 200) { + msd.setState(JSON.parse(http.responseText).result); + } else { + setTimeout(msd.loadInitialState, 1000); + } + } + }); + }; + + this.setState = function(state) { + if (state.connected_to == "server") { + cls = "led-on"; + } else if (state.busy) { + cls = "led-msd-writing"; + } else { + cls = "led-off"; + } + $("msd-led").className = cls; + }; +}; |