diff --git a/html/index.html b/html/index.html index a3b3c76..dfa399e 100644 --- a/html/index.html +++ b/html/index.html @@ -72,7 +72,6 @@

The Word Search Game

- diff --git a/html/lobby.js b/html/lobby.js deleted file mode 100644 index 677ecd5..0000000 --- a/html/lobby.js +++ /dev/null @@ -1,79 +0,0 @@ -document.addEventListener("DOMContentLoaded", function() { - const socket = new WebSocket("ws://" + window.location.hostname + ":9105"); - const gameSelect = document.getElementById("gameSelect"); - const modeSelect = document.getElementById("modeSelect"); - const confirmButton = document.getElementById("confirmButton"); - const startButton = document.getElementById("startButton"); - const leaveButton = document.getElementById("leaveButton"); - const refreshButton = document.getElementById("refreshButton"); - const gameTable = document.getElementById("gameListSection"); - - socket.onopen = function() { - console.log("WebSocket connection opened."); - requestGameList(); - }; - - socket.onmessage = function(event) { - const data = JSON.parse(event.data); - if (data.type === "gameListUpdate") { - updateGameList(data.games); - } - }; - - socket.onerror = function(error) { - console.error("WebSocket error:", error); - }; - - socket.onclose = function() { - console.log("WebSocket connection closed."); - }; - - confirmButton.addEventListener('click', function() { - const gameIndex = gameSelect.selectedIndex; - const modeIndex = modeSelect.selectedIndex; - if (gameIndex >= 0 && modeIndex >= 0) { - joinGame(gameSelect.value, modeSelect.options[modeSelect.selectedIndex].text); - } else { - alert('Please select both a game and a mode.'); - } - }); - - refreshButton.addEventListener('click', function() { - requestGameList(); - }); - - function requestGameList() { - socket.send(JSON.stringify({ type: "requestGameList" })); - } - - function joinGame(gameId, mode) { - const message = { - type: "joinGame", - gameId: gameId, - mode: mode - }; - socket.send(JSON.stringify(message)); - } - - function updateGameList(games) { - while (gameTable.rows.length > 1) { - gameTable.deleteRow(1); - } - - // Add new rows for each game - games.forEach(function(game) { - let row = gameTable.insertRow(); - let nameCell = row.insertCell(0); - let joinCell = row.insertCell(1); - let playersCell = row.insertCell(2); - - nameCell.textContent = game.name; - joinCell.innerHTML = ``; - playersCell.textContent = game.players.join(", "); - }); - } -}); - - - -