summaryrefslogtreecommitdiff
path: root/kvmd/web/js/atx.js
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-07-17 00:44:38 +0300
committerDevaev Maxim <[email protected]>2018-07-17 00:44:38 +0300
commit514aac8d82241e2907d4d7672765912020d742dc (patch)
treee25570aa37d14a9fb8a31758212fc0985c131e27 /kvmd/web/js/atx.js
parentcaf7f4c99bce4533e7fc1b9f7aeaaf605baf819c (diff)
real-time icons and buttons state
Diffstat (limited to 'kvmd/web/js/atx.js')
-rw-r--r--kvmd/web/js/atx.js26
1 files changed, 19 insertions, 7 deletions
diff --git a/kvmd/web/js/atx.js b/kvmd/web/js/atx.js
index 0779f584..0167ae6f 100644
--- a/kvmd/web/js/atx.js
+++ b/kvmd/web/js/atx.js
@@ -1,10 +1,22 @@
var atx = new function() {
- this.setLedsState = function(leds) {
- $("atx-power-led").className = (leds.power ? "led-on" : "led-off");
- $("atx-hdd-led").className = (leds.hdd ? "led-hdd-busy" : "led-off");
+ this.loadInitialState = function() {
+ var http = tools.makeRequest("GET", "/kvmd/atx", function() {
+ if (http.readyState === 4) {
+ if (http.status === 200) {
+ atx.setButtonsBusy(JSON.parse(http.responseText).result.busy);
+ } else {
+ setTimeout(atx.loadInitialState, 1000);
+ }
+ }
+ });
+ };
+
+ this.setState = function(state) {
+ $("atx-power-led").className = (state.leds.power ? "led-on" : "led-off");
+ $("atx-hdd-led").className = (state.leds.hdd ? "led-hdd-busy" : "led-off");
};
- this.clearLeds = function() {
+ this.clearState = function() {
[
"atx-power-led",
"atx-hdd-led",
@@ -35,7 +47,7 @@ var atx = new function() {
}
if (button && confirm(confirm_msg)) {
- __setButtonsBusy(true);
+ // atx.setButtonsBusy(true);
var http = tools.makeRequest("POST", "/kvmd/atx/click?button=" + button, function() {
if (http.readyState === 4) {
if (http.status === 409) {
@@ -43,13 +55,13 @@ var atx = new function() {
} else if (http.status !== 200) {
alert("Click error:", http.responseText);
}
- __setButtonsBusy(false);
+ // atx.setButtonsBusy(false);
}
}, timeout);
}
};
- var __setButtonsBusy = function(busy) {
+ this.setButtonsBusy = function(busy) {
[
"atx-power-button",
"atx-power-button-long",