summaryrefslogtreecommitdiff
path: root/web/js/kvm
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-11-22 06:22:48 +0300
committerDevaev Maxim <[email protected]>2018-11-22 06:26:58 +0300
commitd3073b9d7e479b979e98043b4f878da306adae6a (patch)
tree9115c037b1dd7b6e3bed4f4ea7ec4a1aa6157fbb /web/js/kvm
parenta4357162f452e89121e56500b7b6cba314eb46dd (diff)
design fix, refactoring
Diffstat (limited to 'web/js/kvm')
-rw-r--r--web/js/kvm/hid.js15
-rw-r--r--web/js/kvm/keyboard.js5
-rw-r--r--web/js/kvm/msd.js2
-rw-r--r--web/js/kvm/session.js11
-rw-r--r--web/js/kvm/stream.js6
5 files changed, 21 insertions, 18 deletions
diff --git a/web/js/kvm/hid.js b/web/js/kvm/hid.js
index 5b13480f..69b34144 100644
--- a/web/js/kvm/hid.js
+++ b/web/js/kvm/hid.js
@@ -141,13 +141,14 @@ function Hid() {
clipboard_codes.push(codes);
}
});
-
- var confirm_msg = (
- "You are going to automatically type " + codes_count
- + " characters from the system clipboard."
- + " It will take " + (__codes_delay * codes_count * 2 / 1000) + " seconds.<br>"
- + "<br>Are you sure you want to continue?<br>"
- );
+ var time = __codes_delay * codes_count * 2 / 1000;
+
+ var confirm_msg = `
+ You are going to automatically type ${codes_count} characters from the system clipboard.
+ It will take ${time} seconds.<br>
+ <br>
+ Are you sure you want to continue?
+ `;
ui.confirm(confirm_msg).then(function(ok) {
if (ok) {
diff --git a/web/js/kvm/keyboard.js b/web/js/kvm/keyboard.js
index ee9a7ba1..8a08a8aa 100644
--- a/web/js/kvm/keyboard.js
+++ b/web/js/kvm/keyboard.js
@@ -83,7 +83,7 @@ function Keyboard() {
if (event.preventDefault) {
event.preventDefault();
}
- var el_key = document.querySelector("[data-key='" + event.code + "']");
+ var el_key = document.querySelector(`[data-key='${event.code}']`);
if (el_key && !event.repeat) {
__commonHandler(el_key, state, "pressed");
if (__mac_cmd_hook) {
@@ -168,7 +168,8 @@ function Keyboard() {
};
var __resolveKeys = function(el_key) {
- return document.querySelectorAll("[data-key='" + el_key.getAttribute("data-key") + "']");
+ var code = el_key.getAttribute("data-key");
+ return document.querySelectorAll(`[data-key='${code}']`);
};
var __sendKey = function(el_key, state) {
diff --git a/web/js/kvm/msd.js b/web/js/kvm/msd.js
index bbc86370..c59563b7 100644
--- a/web/js/kvm/msd.js
+++ b/web/js/kvm/msd.js
@@ -73,7 +73,7 @@ function Msd() {
__applyState();
});
__applyState();
- $("msd-switch-to-" + to + "-button").disabled = true;
+ $(`msd-switch-to-${to}-button`).disabled = true;
};
var __selectNewImageFile = function() {
diff --git a/web/js/kvm/session.js b/web/js/kvm/session.js
index 19166a9a..ebddff7b 100644
--- a/web/js/kvm/session.js
+++ b/web/js/kvm/session.js
@@ -15,13 +15,13 @@ function Session() {
var __init__ = function() {
$("link-led").title = "Not connected yet...";
- __loadKvmdVersion();
+ __loadKvmdInfo();
__startPoller();
};
/********************************************************************************/
- var __loadKvmdVersion = function() {
+ var __loadKvmdInfo = function() {
var http = tools.makeRequest("GET", "/kvmd/info", function() {
if (http.readyState === 4) {
if (http.status === 200) {
@@ -40,9 +40,9 @@ function Session() {
}
}
$("about-version-kvmd").innerHTML = info.version.kvmd;
- $("about-version-streamer").innerHTML = info.version.streamer + " (" + info.streamer + ")";
+ $("about-version-streamer").innerHTML = `${info.version.streamer} (${info.streamer})`;
} else {
- setTimeout(__loadKvmdVersion, 1000);
+ setTimeout(__loadKvmdInfo, 1000);
}
}
});
@@ -54,7 +54,8 @@ function Session() {
var http = tools.makeRequest("GET", "/ws_auth", function() {
if (http.readyState === 4) {
if (http.status === 200) {
- __ws = new WebSocket((location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/kvmd/ws");
+ var proto = (location.protocol === "https:" ? "wss" : "ws");
+ __ws = new WebSocket(`${proto}://${location.host}/kvmd/ws`);
__ws.onopen = __wsOpenHandler;
__ws.onmessage = __wsMessageHandler;
__ws.onerror = __wsErrorHandler;
diff --git a/web/js/kvm/stream.js b/web/js/kvm/stream.js
index 32a8cad8..d543701f 100644
--- a/web/js/kvm/stream.js
+++ b/web/js/kvm/stream.js
@@ -156,8 +156,8 @@ function Streamer() {
var el_grab = document.querySelector("#stream-window-header .window-grab");
var el_info = $("stream-info");
if (online) {
- var fps_suffix = (__client_fps >= 0 ? " / " + __client_fps + " fps" : "");
- el_grab.innerHTML = el_info.innerHTML = "Stream &ndash; " + __resolution.width + "x" + __resolution.height + fps_suffix;
+ var fps_suffix = (__client_fps >= 0 ? ` / ${__client_fps} fps` : "");
+ el_grab.innerHTML = el_info.innerHTML = `Stream &ndash; ${__resolution.width}x${__resolution.height}${fps_suffix}`;
} else {
el_grab.innerHTML = el_info.innerHTML = "Stream &ndash; offline";
}
@@ -183,7 +183,7 @@ function Streamer() {
};
var __sendParam = function(name, value) {
- var http = tools.makeRequest("POST", "/kvmd/streamer/set_params?" + name + "=" + value, function() {
+ var http = tools.makeRequest("POST", `/kvmd/streamer/set_params?${name}=${value}`, function() {
if (http.readyState === 4) {
if (http.status !== 200) {
ui.error("Can't configure stream:<br>", http.responseText);