|
|
@ -18,10 +18,23 @@
|
|
|
|
).innerHTML += `<span style="color: ${color}">${text}</span><br>`;
|
|
|
|
).innerHTML += `<span style="color: ${color}">${text}</span><br>`;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(location.protocol);
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
|
|
|
|
location.protocol == "https:"
|
|
|
|
|
|
|
|
? "wss://"
|
|
|
|
|
|
|
|
: "ws://" +
|
|
|
|
|
|
|
|
location.host +
|
|
|
|
|
|
|
|
location.pathname.replace(new RegExp("\/" + "$"), "") +
|
|
|
|
|
|
|
|
"/echo/"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const socket = new WebSocket(
|
|
|
|
const socket = new WebSocket(
|
|
|
|
location.protocol == "https"
|
|
|
|
location.protocol == "https:"
|
|
|
|
? "wss://"
|
|
|
|
? "wss://"
|
|
|
|
: "ws://" + location.host + location.pathname + "/echo/"
|
|
|
|
: "ws://" +
|
|
|
|
|
|
|
|
location.host +
|
|
|
|
|
|
|
|
location.pathname.replace(new RegExp("\/" + "$"), "") +
|
|
|
|
|
|
|
|
"/echo/"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
socket.addEventListener("message", (ev) => {
|
|
|
|
socket.addEventListener("message", (ev) => {
|
|
|
|
log("<<< " + ev.data, "blue");
|
|
|
|
log("<<< " + ev.data, "blue");
|
|
|
|