This commit is contained in:
JurajKubrican
2024-12-30 22:12:50 +01:00
parent e7a353943c
commit 3839a3d74a
2 changed files with 11 additions and 14 deletions

View File

@@ -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 ? "+" : "-";