diff --git a/gambling.js b/gambling.js index d77b1c8..6791cfb 100644 --- a/gambling.js +++ b/gambling.js @@ -134,7 +134,6 @@ app.get("/balance", authenticateToken, (request, response) => { "bearerAuth": [] }] */ const username = request.user.username; - console.log(username); const allUsers = get_data(); const me = allUsers.find(u => u.username === username); if (!me) { @@ -184,13 +183,11 @@ async function createLobby() { let data = await response.json(); let lobbyId = data.deck_id await fetch(`https://www.deckofcardsapi.com/api/deck/${lobbyId}/pile/players/add/?cards=`) - console.log(lobbyId); return lobbyId; } async function joinLobby(lobbyId, player_name) { let response = await fetch(`https://www.deckofcardsapi.com/api/deck/${lobbyId}/pile/${player_name}/add/?cards=`) - console.log(response); } diff --git a/public/frontend_home.js b/public/frontend_home.js index 59366e8..2506af2 100644 --- a/public/frontend_home.js +++ b/public/frontend_home.js @@ -49,8 +49,6 @@ document.addEventListener("DOMContentLoaded", async () => { } catch (error) { console.log("Balance error:", error); } - - // Logout logoutButton.addEventListener("click", async (e) => { e.preventDefault(); try { @@ -63,14 +61,10 @@ document.addEventListener("DOMContentLoaded", async () => { console.log("Logout error:", err); } }); - - // Host Lobby and join immediately hostButton.addEventListener("click", async (e) => { e.preventDefault(); - const username = await getUsernameFromToken(); if (!username) return alert("User not authenticated"); - try { const res = await fetch(`/lobby/create?username=${username}`); if (res.redirected) { @@ -78,10 +72,8 @@ document.addEventListener("DOMContentLoaded", async () => { const lobbyId = joinURL.searchParams.get("lobbyId"); const joinRes = await fetch(joinURL.href); const {lobbyId: finalLobbyId} = await joinRes.json(); - document.getElementById("lobby-id").textContent = finalLobbyId; document.getElementById("lobby-room").classList.remove("hidden"); - setInterval(async () => { const res = await fetch(`/lobby/players?lobbyId=${finalLobbyId}`); const data = await res.json(); @@ -108,20 +100,17 @@ document.addEventListener("DOMContentLoaded", async () => { const joinError = document.getElementById("join-error"); joinError.classList.add("hidden"); // hide any previous error joinError.textContent = ""; - if (!lobbyId) { joinError.textContent = "Please enter a lobby ID."; joinError.classList.remove("hidden"); return; } - const username = await getUsernameFromToken(); if (!username) { joinError.textContent = "User not authenticated."; joinError.classList.remove("hidden"); return; } - try { const joinRes = await fetch(`/lobby/join?lobbyId=${lobbyId}&username=${username}`); if (joinRes.ok) {