mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 09:01:54 +08:00
refactoring
This commit is contained in:
@@ -28,13 +28,13 @@ function Atx() {
|
||||
|
||||
self.setState = function(state) {
|
||||
__setButtonsBusy(state.busy);
|
||||
$("atx-power-led").className = (state.leds.power ? "led-on" : "led-off");
|
||||
$("atx-hdd-led").className = (state.leds.hdd ? "led-hdd-busy" : "led-off");
|
||||
$("atx-power-led").className = (state.leds.power ? "led-green" : "led-gray");
|
||||
$("atx-hdd-led").className = (state.leds.hdd ? "led-red" : "led-gray");
|
||||
};
|
||||
|
||||
self.clearState = function() {
|
||||
$("atx-power-led").className = "led-off";
|
||||
$("atx-hdd-led").className = "led-off";
|
||||
$("atx-power-led").className = "led-gray";
|
||||
$("atx-hdd-led").className = "led-gray";
|
||||
};
|
||||
|
||||
var __clickButton = function(button, timeout, confirm_msg) {
|
||||
|
||||
@@ -153,7 +153,7 @@ function Hid() {
|
||||
if (ok) {
|
||||
$("hid-pak-text").disabled = true;
|
||||
$("hid-pak-button").disabled = true;
|
||||
$("hid-pak-led").className = "led-hid-pak-typing";
|
||||
$("hid-pak-led").className = "led-yellow-rotating-fast";
|
||||
$("hid-pak-led").title = "Autotyping...";
|
||||
|
||||
tools.debug("Paste-as-keys:", text);
|
||||
@@ -168,7 +168,7 @@ function Hid() {
|
||||
$("hid-pak-text").value = "";
|
||||
$("hid-pak-text").disabled = false;
|
||||
$("hid-pak-button").disabled = false;
|
||||
$("hid-pak-led").className = "led-off";
|
||||
$("hid-pak-led").className = "led-gray";
|
||||
$("hid-pak-led").title = "";
|
||||
}
|
||||
});
|
||||
|
||||
@@ -71,10 +71,10 @@ function Keyboard() {
|
||||
|
||||
var __updateLeds = function() {
|
||||
if (__ws && (document.activeElement === $("stream-window") || document.activeElement === $("keyboard-window"))) {
|
||||
$("hid-keyboard-led").className = "led-on";
|
||||
$("hid-keyboard-led").className = "led-green";
|
||||
$("hid-keyboard-led").title = "Keyboard captured";
|
||||
} else {
|
||||
$("hid-keyboard-led").className = "led-off";
|
||||
$("hid-keyboard-led").className = "led-gray";
|
||||
$("hid-keyboard-led").title = "Keyboard free";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,10 +55,10 @@ function Mouse() {
|
||||
|
||||
var __updateLeds = function() {
|
||||
if (__ws && __stream_hovered) {
|
||||
$("hid-mouse-led").className = "led-on";
|
||||
$("hid-mouse-led").className = "led-green";
|
||||
$("hid-mouse-led").title = "Mouse tracked";
|
||||
} else {
|
||||
$("hid-mouse-led").className = "led-off";
|
||||
$("hid-mouse-led").className = "led-gray";
|
||||
$("hid-mouse-led").title = "Mouse free";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -103,18 +103,18 @@ function Msd() {
|
||||
var __applyState = function() {
|
||||
if (__state.connected_to === "server") {
|
||||
$("msd-another-another-user-uploads").style.display = "none";
|
||||
$("msd-led").className = "led-on";
|
||||
$("msd-led").className = "led-green";
|
||||
$("msd-status").innerHTML = $("msd-led").title = "Connected to Server";
|
||||
$("msd-another-another-user-uploads").style.display = "none";
|
||||
} else if (__state.busy) {
|
||||
if (!__upload_http) {
|
||||
$("msd-another-another-user-uploads").style.display = "block";
|
||||
}
|
||||
$("msd-led").className = "led-msd-writing";
|
||||
$("msd-led").className = "led-yellow-rotating-fast";
|
||||
$("msd-status").innerHTML = $("msd-led").title = "Uploading new image";
|
||||
} else {
|
||||
$("msd-another-another-user-uploads").style.display = "none";
|
||||
$("msd-led").className = "led-off";
|
||||
$("msd-led").className = "led-gray";
|
||||
if (__state.in_operate) {
|
||||
$("msd-status").innerHTML = $("msd-led").title = "Connected to KVM";
|
||||
} else {
|
||||
|
||||
@@ -33,12 +33,12 @@ function Session(atx, hid, msd) {
|
||||
};
|
||||
|
||||
var __startPoller = function() {
|
||||
$("link-led").className = "led-link-connecting";
|
||||
$("link-led").className = "led-yellow";
|
||||
$("link-led").title = "Connecting...";
|
||||
var http = tools.makeRequest("GET", "/wsauth", function() {
|
||||
if (http.readyState === 4) {
|
||||
if (http.status === 200) {
|
||||
__ws = new WebSocket((location.protocol == "https:" ? "wss" : "ws") + "://" + location.host + "/kvmd/ws");
|
||||
__ws = new WebSocket((location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/kvmd/ws");
|
||||
__ws.onopen = __wsOpenHandler;
|
||||
__ws.onmessage = __wsMessageHandler;
|
||||
__ws.onerror = __wsErrorHandler;
|
||||
@@ -51,7 +51,7 @@ function Session(atx, hid, msd) {
|
||||
};
|
||||
|
||||
var __wsOpenHandler = function(event) {
|
||||
$("link-led").className = "led-on";
|
||||
$("link-led").className = "led-green";
|
||||
$("link-led").title = "Connected";
|
||||
tools.debug("WebSocket opened:", event);
|
||||
atx.loadInitialState();
|
||||
@@ -85,7 +85,7 @@ function Session(atx, hid, msd) {
|
||||
};
|
||||
|
||||
var __wsCloseHandler = function(event) {
|
||||
$("link-led").className = "led-off";
|
||||
$("link-led").className = "led-gray";
|
||||
tools.debug("WebSocket closed:", event);
|
||||
if (__ping_timer) {
|
||||
clearInterval(__ping_timer);
|
||||
@@ -95,7 +95,7 @@ function Session(atx, hid, msd) {
|
||||
atx.clearState();
|
||||
__ws = null;
|
||||
setTimeout(function() {
|
||||
$("link-led").className = "led-link-connecting";
|
||||
$("link-led").className = "led-yellow";
|
||||
setTimeout(__startPoller, 500);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ function Stream() {
|
||||
tools.info("Refreshing stream ...");
|
||||
$("stream-image").className = "stream-image-inactive";
|
||||
$("stream-box").classList.add("stream-box-inactive");
|
||||
$("stream-led").className = "led-off";
|
||||
$("stream-led").className = "led-gray";
|
||||
$("stream-led").title = "Stream inactive";
|
||||
$("stream-screenshot-button").disabled = true;
|
||||
$("stream-quality-slider").disabled = true;
|
||||
@@ -56,7 +56,7 @@ function Stream() {
|
||||
__prev_state = false;
|
||||
|
||||
} else if (http.status === 200) {
|
||||
if ($("stream-quality-slider").value != response.source.quality && !__quality_timer) {
|
||||
if ($("stream-quality-slider").value !== response.source.quality && !__quality_timer) {
|
||||
$("stream-quality-slider").value = response.source.quality;
|
||||
$("stream-quality-value").innerHTML = response.source.quality + "%";
|
||||
}
|
||||
@@ -88,7 +88,7 @@ function Stream() {
|
||||
$("stream-image").src = "/streamer/stream?t=" + new Date().getTime();
|
||||
$("stream-image").className = "stream-image-active";
|
||||
$("stream-box").classList.remove("stream-box-inactive");
|
||||
$("stream-led").className = "led-on";
|
||||
$("stream-led").className = "led-green";
|
||||
$("stream-led").title = "Stream is active";
|
||||
$("stream-screenshot-button").disabled = false;
|
||||
$("stream-quality-slider").disabled = false;
|
||||
|
||||
Reference in New Issue
Block a user