From 1793733e53626d0a216476587da449a6fe5471a6 Mon Sep 17 00:00:00 2001 From: cay Date: Fri, 10 Apr 2026 11:18:24 +0100 Subject: [PATCH] rtjsytr --- public/js/chat.js | 23 ------------- sockets/chat.js | 88 ----------------------------------------------- 2 files changed, 111 deletions(-) delete mode 100644 sockets/chat.js diff --git a/public/js/chat.js b/public/js/chat.js index 93707aa..d3e23b6 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -86,26 +86,3 @@ socket.on("systemMessage", (data) => { updateChat(); }); - -socket.on("onlineUsers", (users) => { - console.log("Online Users:", users); - const list = document.getElementById("online-list"); - - list.innerHTML = ""; - users.sort(); - users.forEach((user) => { - const div = document.createElement("div"); - - const name = typeof user === "object" ? user.name : user; - - div.innerHTML = ` ${name}`; - - div.onclick = () => { - document.getElementById("chat-text").value = "/w " + name + " "; - - document.getElementById("chat-text").focus(); - }; - - list.appendChild(div); - }); -}); diff --git a/sockets/chat.js b/sockets/chat.js deleted file mode 100644 index d3e23b6..0000000 --- a/sockets/chat.js +++ /dev/null @@ -1,88 +0,0 @@ -const socket = io(); -window._socket = socket; // Globale Referenz für arena.js und andere Module -const username = - typeof window.playerName === "object" - ? window.playerName.name - : window.playerName; - -socket.emit("register", username); -const chatTitle = document.getElementById("chat-title"); - -let channel = "global"; - -const chatBox = document.getElementById("chat-messages"); - -let history = { - global: [], - guild: [], - private: [], -}; - -function updateChat() { - chatBox.value = history[channel].join("\n"); - - chatBox.scrollTop = chatBox.scrollHeight; -} - -document.querySelectorAll(".chat-channels button").forEach((btn) => { - btn.onclick = () => { - document - .querySelectorAll(".chat-channels button") - .forEach((b) => b.classList.remove("active")); - - btn.classList.add("active"); - - channel = btn.dataset.channel; - - // Titel ändern - if (channel === "global") chatTitle.innerText = "Globalchat"; - if (channel === "guild") chatTitle.innerText = "Gildenchat"; - if (channel === "private") chatTitle.innerText = "Privatchat"; - - updateChat(); - }; -}); - -document.getElementById("chat-send").onclick = () => { - const text = document.getElementById("chat-text").value; - - if (!text) return; - - if (text.startsWith("/w ")) { - const parts = text.split(" "); - - const target = parts[1]; - - const message = parts.slice(2).join(" "); - - socket.emit("whisper", { - to: target, - message: message, - }); - } else { - socket.emit("chatMessage", { - channel: channel, - message: text, - }); - } - - document.getElementById("chat-text").value = ""; -}; - -socket.on("chatMessage", (data) => { - const line = `${data.user}: ${data.message}`; - - history[data.channel].push(line); - - if (history[data.channel].length > 50) history[data.channel].shift(); - - if (data.channel === channel) updateChat(); -}); - -socket.on("systemMessage", (data) => { - const line = "[System] " + data.message; - - history[channel].push(line); - - updateChat(); -});