design fix, refactoring

This commit is contained in:
Devaev Maxim
2018-11-22 06:22:48 +03:00
parent a4357162f4
commit d3073b9d7e
9 changed files with 47 additions and 27 deletions

View File

@@ -141,13 +141,14 @@ function Hid() {
clipboard_codes.push(codes);
}
});
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 " + (__codes_delay * codes_count * 2 / 1000) + " seconds.<br>"
+ "<br>Are you sure you want to continue?<br>"
);
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) {

View File

@@ -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) {

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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);