From abfeff003020d0435219e24c14a5029cda4eba0f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 6 Oct 2022 00:40:54 +0200 Subject: Make main menu links actual links. --- public/common/play.css | 6 ++++++ public/common/play.js | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/public/common/play.css b/public/common/play.css index 02a667d..8e23a91 100644 --- a/public/common/play.css +++ b/public/common/play.css @@ -189,6 +189,7 @@ footer { } .menu_item { padding: 4px 8px; + cursor: pointer; } .menu_item:hover { background-color: black; @@ -197,6 +198,11 @@ footer { .menu_item:hover img { filter: invert(100%); } +a.menu_item { + display: block; + text-decoration: none; + color: black; +} /* TOOL BAR */ diff --git a/public/common/play.js b/public/common/play.js index 25f237a..ec7cd9b 100644 --- a/public/common/play.js +++ b/public/common/play.js @@ -1010,10 +1010,20 @@ function add_main_menu_item(text, onclick) { popup.insertBefore(item, sep) } +function add_main_menu_item_link(text, url) { + let popup = document.querySelector(".menu_popup") + let sep = document.getElementById("main_menu_separator") + let item = document.createElement("a") + item.className = "menu_item" + item.href = url + item.textContent = text + popup.insertBefore(item, sep) +} + init_main_menu() -if (params.role !== "Observer") { - add_main_menu_item("Go home", () => window.open("/games/active", "_self")) - add_main_menu_item("Go to next game", () => window.open("/games/next", "_self")) +if (params.mode === "play" && params.role !== "Observer") { + add_main_menu_item_link("Go home", "/games/active") + add_main_menu_item_link("Go to next game", "/games/next") } else { - add_main_menu_item("Go home", () => window.open("/", "_self")) + add_main_menu_item_link("Go home", "/") } -- cgit v1.2.3