summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-05-17 10:40:20 +0300
committerDevaev Maxim <[email protected]>2021-05-17 10:40:20 +0300
commit274d609b71de508d66b96baa24ad80ad8b4885eb (patch)
treee23bb955769ce7904e1c2d3d174071760a864578
parenta4c9a0b117e7805129bf19d31ba9f7166622c579 (diff)
refactoring
-rw-r--r--web/share/js/kvm/session.js3
-rw-r--r--web/share/js/tools.js2
2 files changed, 3 insertions, 2 deletions
diff --git a/web/share/js/kvm/session.js b/web/share/js/kvm/session.js
index 894dc6f1..b8fee992 100644
--- a/web/share/js/kvm/session.js
+++ b/web/share/js/kvm/session.js
@@ -205,8 +205,7 @@ export function Session() {
let http = tools.makeRequest("GET", "/api/auth/check", function() {
if (http.readyState === 4) {
if (http.status === 200) {
- let proto = (location.protocol === "https:" ? "wss" : "ws");
- __ws = new WebSocket(`${proto}://${location.host}/api/ws`);
+ __ws = new WebSocket(`${tools.https ? "wss" : "ws"}://${location.host}/api/ws`);
__ws.onopen = __wsOpenHandler;
__ws.onmessage = __wsMessageHandler;
__ws.onerror = __wsErrorHandler;
diff --git a/web/share/js/tools.js b/web/share/js/tools.js
index 521cb1a0..02c6e637 100644
--- a/web/share/js/tools.js
+++ b/web/share/js/tools.js
@@ -240,6 +240,8 @@ export var tools = new function() {
};
};
this.info("Browser:", this.browser);
+
+ this.https = (location.protocol === "https:");
};
export var $ = (id) => document.getElementById(id);