refactoring

This commit is contained in:
Devaev Maxim 2021-05-17 10:40:20 +03:00
parent a4c9a0b117
commit 274d609b71
2 changed files with 3 additions and 2 deletions

View File

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

View File

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