From 0d0dab23fb0ecf16a2abf54295746d7dbd87c2d7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 10 Nov 2021 22:27:46 +0100 Subject: Massive SQL cleanup. --- public/join.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'public/join.js') diff --git a/public/join.js b/public/join.js index a5a2e3a..ce3d0d0 100644 --- a/public/join.js +++ b/public/join.js @@ -76,8 +76,12 @@ function start_event_source() { } } -function is_your_turn(player, role) { - return (game.active_role === role || game.active_role === "Both" || game.active_role === "All"); +function is_active(player, role) { + return (game.active === role || game.active === "Both" || game.active === "All"); +} + +function is_solo() { + return players.every(p => p.user_id === players[0].user_id); } function update() { @@ -94,19 +98,19 @@ function update() { let element = document.getElementById(role_id); if (player) { if (game.status > 0) { - if (is_your_turn(player, role)) - element.className = "is_your_turn"; + if (is_active(player, role)) + element.className = "is_active"; else element.className = ""; if (player.user_id === user_id) element.innerHTML = `Play`; else - element.innerHTML = player.user_name; + element.innerHTML = player.name; } else { if ((player.user_id === user_id) || (game.owner_id === user_id)) - element.innerHTML = `\u274c ${player.user_name}`; + element.innerHTML = `\u274c ${player.name}`; else - element.innerHTML = player.user_name; + element.innerHTML = player.name; } } else { if (game.status === 0) @@ -131,7 +135,7 @@ function update() { if (game.owner_id === user_id) { window.start_button.disabled = !ready; window.start_button.classList = (game.status === 0) ? "" : "hide"; - window.delete_button.classList = (game.status === 0 || game.is_solo) ? "" : "hide"; + window.delete_button.classList = (game.status === 0 || is_solo()) ? "" : "hide"; if (game.status === 0 && ready) start_blinker("READY TO START"); else -- cgit v1.2.3