From add3b74cb709a9ad898b3499e148dfbb95f54ddc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 11 May 2020 18:22:04 -0700 Subject: [PATCH] Fix the gear toggle to work the first time it is clicked Apparently, the first time this condition is executed, the host_tools.style.display attribute is not "none" but is instead some sort of empty value. With the old code, this made a first click on the gear do nothing, (setting it to "none" but not toggling visibility) and then a second click would make the host tools appear. With this change to reverse the logic to look for an explicit value of "block" (which is set only after the first click) the gear button works reliably on every click including the first. --- empires-client.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/empires-client.js b/empires-client.js index 994ed1a..a0df913 100644 --- a/empires-client.js +++ b/empires-client.js @@ -30,10 +30,12 @@ function register(form) { function toggle_host_tools() { const host_tools = document.getElementById("host-tools"); - if (host_tools.style.display === "none") - host_tools.style.display = "block"; - else + console.log("Toggling, host_tools.style.display is '" + host_tools.style.display + "'"); + + if (host_tools.style.display === "block") host_tools.style.display = "none"; + else + host_tools.style.display = "block"; } function post_reveal() { -- 2.43.0