summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2019-11-08 02:08:56 +0300
committerDevaev Maxim <[email protected]>2019-11-08 02:08:56 +0300
commit7f1461371d561592a1445e6b0245d51ca2516761 (patch)
tree057ad775af452346068306f58258a9d2609e7b7b
parent3c1681fd2bc43dffcc75b82760d3f068af97574c (diff)
refactoring
-rw-r--r--web/share/js/kvm/atx.js6
-rw-r--r--web/share/js/kvm/hid.js14
-rw-r--r--web/share/js/kvm/msd.js32
-rw-r--r--web/share/js/kvm/stream.js16
-rw-r--r--web/share/js/login/main.js12
-rw-r--r--web/share/js/wm.js6
6 files changed, 43 insertions, 43 deletions
diff --git a/web/share/js/kvm/atx.js b/web/share/js/kvm/atx.js
index a7c6bbed..fae7fc9f 100644
--- a/web/share/js/kvm/atx.js
+++ b/web/share/js/kvm/atx.js
@@ -51,9 +51,9 @@ export function Atx() {
$("atx-power-led").className = ((state && state.leds.power) ? "led-green" : "led-gray");
$("atx-hdd-led").className = ((state && state.leds.hdd) ? "led-red" : "led-gray");
- wm.switchDisabled($("atx-power-button"), (!state || state.busy));
- wm.switchDisabled($("atx-power-button-long"), (!state || state.busy));
- wm.switchDisabled($("atx-reset-button"), (!state || state.busy));
+ wm.switchEnabled($("atx-power-button"), (state && !state.busy));
+ wm.switchEnabled($("atx-power-button-long"), (state && !state.busy));
+ wm.switchEnabled($("atx-reset-button"), (state && !state.busy));
};
var __clickButton = function(button, confirm_msg) {
diff --git a/web/share/js/kvm/hid.js b/web/share/js/kvm/hid.js
index 772b4a45..4868b0a5 100644
--- a/web/share/js/kvm/hid.js
+++ b/web/share/js/kvm/hid.js
@@ -86,9 +86,9 @@ export function Hid() {
/************************************************************************/
self.setSocket = function(ws) {
- wm.switchDisabled($("hid-pak-text"), !ws);
- wm.switchDisabled($("hid-pak-button"), !ws);
- wm.switchDisabled($("hid-reset-button"), !ws);
+ wm.switchEnabled($("hid-pak-text"), ws);
+ wm.switchEnabled($("hid-pak-button"), ws);
+ wm.switchEnabled($("hid-reset-button"), ws);
__ws = ws;
__keyboard.setSocket(ws);
__mouse.setSocket(ws);
@@ -192,8 +192,8 @@ export function Hid() {
wm.confirm(confirm_msg).then(function(ok) {
if (ok) {
- wm.switchDisabled($("hid-pak-text"), true);
- wm.switchDisabled($("hid-pak-button"), true);
+ wm.switchEnabled($("hid-pak-text"), false);
+ wm.switchEnabled($("hid-pak-button"), false);
$("hid-pak-led").className = "led-yellow-rotating-fast";
$("hid-pak-led").title = "Autotyping...";
@@ -207,8 +207,8 @@ export function Hid() {
iterate();
} else {
$("hid-pak-text").value = "";
- wm.switchDisabled($("hid-pak-text"), false);
- wm.switchDisabled($("hid-pak-button"), false);
+ wm.switchEnabled($("hid-pak-text"), true);
+ wm.switchEnabled($("hid-pak-button"), true);
$("hid-pak-led").className = "led-gray";
$("hid-pak-led").title = "";
}
diff --git a/web/share/js/kvm/msd.js b/web/share/js/kvm/msd.js
index 6150c77a..7b8654fa 100644
--- a/web/share/js/kvm/msd.js
+++ b/web/share/js/kvm/msd.js
@@ -97,7 +97,7 @@ export function Msd() {
__applyState();
});
__applyState();
- wm.switchDisabled($(`msd-${action}-button`), true);
+ wm.switchEnabled($(`msd-${action}-button`), false);
};
var __selectNewImageFile = function() {
@@ -181,17 +181,17 @@ export function Msd() {
$("msd-storage-progress-value").style.width = "0%";
}
- wm.switchDisabled($("msd-emulate-cdrom-checkbox"), (!__state.online || !__state.features.cdrom, __state.drive.connected || __state.busy));
+ wm.switchEnabled($("msd-emulate-cdrom-checkbox"), (__state.online && __state.features.cdrom && !__state.drive.connected && !__state.busy));
if (__state.features.multi) {
- wm.switchDisabled($("msd-connect-button"), (!__state.online || !__state.drive.image || __state.drive.connected || __state.busy));
+ wm.switchEnabled($("msd-connect-button"), (__state.online && __state.drive.image && !__state.drive.connected && !__state.busy));
} else {
- wm.switchDisabled($("msd-connect-button"), (!__state.online || __state.drive.connected || __state.busy));
+ wm.switchEnabled($("msd-connect-button"), (__state.online && !__state.drive.connected && !__state.busy));
}
- wm.switchDisabled($("msd-disconnect-button"), (!__state.online || !__state.drive.connected || __state.busy));
- wm.switchDisabled($("msd-select-new-image-button"), (!__state.online || __state.drive.connected || __state.busy || __upload_http));
- wm.switchDisabled($("msd-upload-new-image-button"), (!__state.online || __state.drive.connected || __state.busy || !__image_file));
- wm.switchDisabled($("msd-abort-uploading-button"), (!__state.online || !__upload_http));
- wm.switchDisabled($("msd-reset-button"), (!__state.enabled || __state.busy));
+ wm.switchEnabled($("msd-disconnect-button"), (__state.online && __state.drive.connected && !__state.busy));
+ wm.switchEnabled($("msd-select-new-image-button"), (__state.online && !__state.drive.connected && !__upload_http && !__state.busy));
+ wm.switchEnabled($("msd-upload-new-image-button"), (__state.online && !__state.drive.connected && __image_file && !__state.busy));
+ wm.switchEnabled($("msd-abort-uploading-button"), (__state.online && __upload_http));
+ wm.switchEnabled($("msd-reset-button"), (__state.enabled && !__state.busy));
$("msd-emulate-cdrom-checkbox").checked = (__state.online && __state.features.cdrom && __state.drive.cdrom);
$("msd-new-image").style.display = (__image_file ? "block" : "none");
@@ -211,13 +211,13 @@ export function Msd() {
$("msd-drive-image-size").innerHTML = "";
$("msd-storage-size").innerHTML = "";
- wm.switchDisabled($("msd-emulate-cdrom-checkbox"), true);
- wm.switchDisabled($("msd-connect-button"), true);
- wm.switchDisabled($("msd-disconnect-button"), true);
- wm.switchDisabled($("msd-select-new-image-button"), true);
- wm.switchDisabled($("msd-upload-new-image-button"), true);
- wm.switchDisabled($("msd-abort-uploading-button"), true);
- wm.switchDisabled($("msd-reset-button"), true);
+ wm.switchEnabled($("msd-emulate-cdrom-checkbox"), false);
+ wm.switchEnabled($("msd-connect-button"), false);
+ wm.switchEnabled($("msd-disconnect-button"), false);
+ wm.switchEnabled($("msd-select-new-image-button"), false);
+ wm.switchEnabled($("msd-upload-new-image-button"), false);
+ wm.switchEnabled($("msd-abort-uploading-button"), false);
+ wm.switchEnabled($("msd-reset-button"), false);
$("msd-emulate-cdrom-checkbox").checked = false;
$("msd-select-new-image-file").value = "";
diff --git a/web/share/js/kvm/stream.js b/web/share/js/kvm/stream.js
index 8338805c..6ea3362e 100644
--- a/web/share/js/kvm/stream.js
+++ b/web/share/js/kvm/stream.js
@@ -72,7 +72,7 @@ export function Streamer() {
state = state.state;
if (!$("stream-quality-slider").activated) {
- wm.switchDisabled($("stream-quality-slider"), false);
+ wm.switchEnabled($("stream-quality-slider"), true);
if ($("stream-quality-slider").value !== state.encoder.quality) {
$("stream-quality-slider").value = state.encoder.quality;
__updateQualityValue(state.encoder.quality);
@@ -81,7 +81,7 @@ export function Streamer() {
if (!$("stream-desired-fps-slider").activated) {
$("stream-desired-fps-slider").max = max_fps;
- wm.switchDisabled($("stream-desired-fps-slider"), false);
+ wm.switchEnabled($("stream-desired-fps-slider"), true);
if ($("stream-desired-fps-slider").value !== state.source.desired_fps) {
$("stream-desired-fps-slider").value = state.source.desired_fps;
__updateDesiredFpsValue(state.source.desired_fps);
@@ -103,8 +103,8 @@ export function Streamer() {
if (__ensureStream(state.stream.clients_stat)) {
$("stream-led").className = "led-green";
$("stream-led").title = "Stream is active";
- wm.switchDisabled($("stream-screenshot-button"), false);
- wm.switchDisabled($("stream-reset-button"), false);
+ wm.switchEnabled($("stream-screenshot-button"), true);
+ wm.switchEnabled($("stream-reset-button"), true);
$("stream-quality-slider").activated = false;
$("stream-desired-fps-slider").activated = false;
tools.info("Stream: active");
@@ -115,10 +115,10 @@ export function Streamer() {
} else {
$("stream-led").className = "led-gray";
$("stream-led").title = "Stream inactive";
- wm.switchDisabled($("stream-screenshot-button"), true);
- wm.switchDisabled($("stream-reset-button"), true);
- wm.switchDisabled($("stream-quality-slider"), true);
- wm.switchDisabled($("stream-desired-fps-slider"), true);
+ wm.switchEnabled($("stream-screenshot-button"), false);
+ wm.switchEnabled($("stream-reset-button"), false);
+ wm.switchEnabled($("stream-quality-slider"), false);
+ wm.switchEnabled($("stream-desired-fps-slider"), false);
tools.info("Stream: inactive");
__updateStreamWindow(false, false);
diff --git a/web/share/js/login/main.js b/web/share/js/login/main.js
index fff15caf..a76456d0 100644
--- a/web/share/js/login/main.js
+++ b/web/share/js/login/main.js
@@ -62,18 +62,18 @@ function __login() {
}
}
}, body, "application/x-www-form-urlencoded");
- __setDisabled(true);
+ __setEnabled(false);
}
}
-function __setDisabled(disabled) {
- wm.switchDisabled($("user-input"), disabled);
- wm.switchDisabled($("passwd-input"), disabled);
- wm.switchDisabled($("login-button"), disabled);
+function __setEnabled(enabled) {
+ wm.switchEnabled($("user-input"), enabled);
+ wm.switchEnabled($("passwd-input"), enabled);
+ wm.switchEnabled($("login-button"), enabled);
}
function __tryAgain() {
- __setDisabled(false);
+ __setEnabled(true);
$("passwd-input").focus();
$("passwd-input").select();
}
diff --git a/web/share/js/wm.js b/web/share/js/wm.js
index 697f4755..9369d0c0 100644
--- a/web/share/js/wm.js
+++ b/web/share/js/wm.js
@@ -156,8 +156,8 @@ function __WindowManager() {
return promise;
};
- self.switchDisabled = function(el, disabled) {
- if (disabled && document.activeElement === el) {
+ self.switchEnabled = function(el, enabled) {
+ if (!enabled && document.activeElement === el) {
let el_to_focus = (
el.closest(".modal-window")
|| el.closest(".window")
@@ -167,7 +167,7 @@ function __WindowManager() {
el_to_focus.focus();
}
}
- el.disabled = disabled;
+ el.disabled = !enabled;
};
self.showWindow = function(el_window, activate=true, center=false) {