From 3009c951931002c9021d76a1c221e3013f0cd046 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 24 Jun 2021 17:36:09 +0200 Subject: Add "exit" button to finished games and observer view. --- public/common/client.js | 19 +++++++++++++++---- public/images/exit-door.svg | 1 + server.js | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 public/images/exit-door.svg diff --git a/public/common/client.js b/public/common/client.js index 7237c0a..28b4f8e 100644 --- a/public/common/client.js +++ b/public/common/client.js @@ -457,11 +457,17 @@ function send_restart(scenario) { } function on_game_over(game_over) { - if (player && player != "Observer") { + if (player) { + let exit_button = document.querySelector("#exit_button"); + if (exit_button) { + if (game_over || player == "Observer") + exit_button.classList.remove("hide"); + else + exit_button.classList.add("hide"); + } let rematch_button = document.querySelector("#rematch_button"); - if (rematch_button) - { - if (game_over) + if (rematch_button) { + if (game_over && player != "Observer") rematch_button.classList.remove("hide"); else rematch_button.classList.add("hide"); @@ -474,3 +480,8 @@ function send_rematch() { let game = params.get("game"); window.location = '/rematch/' + game; } + +function send_exit() { + let title = window.location.pathname.split("/")[1]; + window.location = '/info/' + title; +} diff --git a/public/images/exit-door.svg b/public/images/exit-door.svg new file mode 100644 index 0000000..5e59298 --- /dev/null +++ b/public/images/exit-door.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server.js b/server.js index c06bee0..fbad44b 100644 --- a/server.js +++ b/server.js @@ -649,7 +649,7 @@ const QUERY_COUNT_OPEN_GAMES = db.prepare("SELECT COUNT(*) FROM games WHERE owne const QUERY_DELETE_GAME = db.prepare("DELETE FROM games WHERE game_id = ?"); const QUERY_REMATCH_FIND = db.prepare(` - SELECT game_id FROM games WHERE status=0 AND description=? + SELECT game_id FROM games WHERE status<3 AND description=? `).pluck(); const QUERY_REMATCH_CREATE = db.prepare(` -- cgit v1.2.3