From: Carl Worth Date: Tue, 12 May 2020 01:22:04 +0000 (-0700) Subject: Fix the gear toggle to work the first time it is clicked X-Git-Url: https://git.cworth.org/git?p=empires-html;a=commitdiff_plain;h=add3b74cb709a9ad898b3499e148dfbb95f54ddc 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. --- 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() {