diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-06-24 17:36:09 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-06-24 17:36:30 +0200 |
commit | 3009c951931002c9021d76a1c221e3013f0cd046 (patch) | |
tree | 54a97608cc803d182aeb7e49bd7aa692b7f757a6 | |
parent | cc2f229e76e04295f6aad75dbf797c690a7aae95 (diff) | |
download | server-3009c951931002c9021d76a1c221e3013f0cd046.tar.gz |
Add "exit" button to finished games and observer view.
-rw-r--r-- | public/common/client.js | 19 | ||||
-rw-r--r-- | public/images/exit-door.svg | 1 | ||||
-rw-r--r-- | server.js | 2 |
3 files changed, 17 insertions, 5 deletions
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 @@ +<svg style="height: 512px; width: 512px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><g class="" style="" transform="translate(0,0)"><path d="M217 28.098v455.804l142-42.597V70.697zm159.938 26.88l.062 2.327V87h16V55zM119 55v117.27h18V73h62V55zm258 50v16h16v-16zm0 34v236h16V139zm-240 58.727V233H41v46h96v35.273L195.273 256zM244 232c6.627 0 12 10.745 12 24s-5.373 24-12 24-12-10.745-12-24 5.373-24 12-24zM137 339.73h-18V448h18zM377 393v14h16v-14zm0 32v23h16v-23zM32 471v18h167v-18zm290.652 0l-60 18H480v-18z" fill="#000" fill-opacity="1"></path></g></svg>
\ No newline at end of file @@ -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(` |