diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-11-10 22:27:46 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-11-13 18:38:17 +0100 |
commit | 0d0dab23fb0ecf16a2abf54295746d7dbd87c2d7 (patch) | |
tree | 84c1ba816d81659860630fa7eb5a798605425161 /public/join.js | |
parent | 66450e7666abdaced2347825a4b9e13bc0528251 (diff) | |
download | server-0d0dab23fb0ecf16a2abf54295746d7dbd87c2d7.tar.gz |
Massive SQL cleanup.
Diffstat (limited to 'public/join.js')
-rw-r--r-- | public/join.js | 20 |
1 files changed, 12 insertions, 8 deletions
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 = `<a href="/play/${game.game_id}/${role}">Play</a>`; else - element.innerHTML = player.user_name; + element.innerHTML = player.name; } else { if ((player.user_id === user_id) || (game.owner_id === user_id)) - element.innerHTML = `<a class="red" href="javascript:send('/part/${game.game_id}/${role}')">\u274c</a> ${player.user_name}`; + element.innerHTML = `<a class="red" href="javascript:send('/part/${game.game_id}/${role}')">\u274c</a> ${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 |