You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
701 B
JavaScript

// NOT ELEGANT SOLUTION FOR LOCAL DEV
let path = document.URL.startsWith("http://127.0.0.1") ? "" : "/soupboat/skimmer/socket.io";
let socket = io("http://127.0.0.1:5000", {
path: path,
});
socket.on("connect", function () {
socket.emit("handle", { id: socket.id });
});
socket.on("add bowl", (data) => addBowl(data.id));
socket.on("remove bowl", (data) => removeBowl(data.id));
const container = document.getElementById("container");
function addBowl(id) {
let bowl = document.createElement("div");
bowl.classList.add("bowl");
bowl.innerHTML = id;
bowl.dataset.bowl = id;
container.appendChild(bowl);
}
function removeBowl(id) {
container.querySelector(`[data-bowl=${id}]`).remove();
}