]> git.cworth.org Git - empires-html/commitdiff
Fix the gear toggle to work the first time it is clicked master
authorCarl Worth <cworth@cworth.org>
Tue, 12 May 2020 01:22:04 +0000 (18:22 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 12 May 2020 01:22:04 +0000 (18:22 -0700)
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

index 994ed1a4e84680a24cb5815bc9dd72708f79ec6b..a0df9134df1e87de86b9e722a07a141bc6606397 100644 (file)
@@ -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() {