mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-01 10:31:54 +08:00
real-time icons and buttons state
This commit is contained in:
24
kvmd/web/js/msd.js
Normal file
24
kvmd/web/js/msd.js
Normal file
@@ -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;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user