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 + 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 public/images/exit-door.svg (limited to 'public') 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 -- cgit v1.2.3