wss
This commit is contained in:
@@ -45,7 +45,12 @@
|
||||
</html>
|
||||
|
||||
<script>
|
||||
let socket = new WebSocket("ws://" + window.location.host + "/ws");
|
||||
const socketUrl =
|
||||
(window.location.protocol.startsWith("https") ? "wss://" : "ws://") +
|
||||
window.location.host +
|
||||
"/ws";
|
||||
|
||||
let socket = new WebSocket(socketUrl);
|
||||
|
||||
socket.addEventListener("message", function (event) {
|
||||
if (event.data.startsWith("u:")) {
|
||||
@@ -68,7 +73,10 @@
|
||||
input.checked = false;
|
||||
});
|
||||
items.forEach((i) => {
|
||||
console.log(i);
|
||||
if (!i) {
|
||||
return;
|
||||
}
|
||||
console.log(i, document.getElementById("box-" + i));
|
||||
document.getElementById("box-" + i).checked = true;
|
||||
});
|
||||
return;
|
||||
@@ -82,7 +90,7 @@
|
||||
document.querySelectorAll("input").forEach((input) => {
|
||||
input.addEventListener("change", (event) => {
|
||||
if (socket.readyState !== socket.OPEN) {
|
||||
socket = new WebSocket("ws://" + window.location.host + "/ws");
|
||||
socket = new WebSocket(socketUrl);
|
||||
}
|
||||
const id = event.target.id.split("-")[1];
|
||||
const value = event.target.checked ? "+" : "-";
|
||||
|
||||
Reference in New Issue
Block a user