]> gitweb.michael.orlitzky.com - charm-bypass.git/commitdiff
index.html.in: use classList for the night/day toggle
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 11 Sep 2025 01:59:56 +0000 (21:59 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 11 Sep 2025 01:59:56 +0000 (21:59 -0400)
This is a little bit more robust than simply declaring that the sky
element will never have any other classes.

index.html.in

index 244f7429aad6f77dae1e9e111b42b6ca57ef3ccd..e2b4b2a6eb051746306d87bb18daf0265e190243 100644 (file)
       function swap_day_night() {
         const sky = document.getElementById("sky");
 
-        if (sky.getAttribute("class") == "night") {
-          sky.setAttribute("class", "");
+        if (sky.classList.contains("night")) {
+          sky.classList.remove("night");
         }
         else {
-          sky.setAttribute("class", "night");
+          sky.classList.add("night");
         }
       }