Clean up flag/grave/hats XHTML preview pages
authorWuzzy <Wuzzy@disroot.org>
Thu, 24 Aug 2023 20:12:28 +0200
changeset 15977 f81fe8250ed9
parent 15976 4d682779bd29
child 15978 20adaa127663
Clean up flag/grave/hats XHTML preview pages
misc/flags_js.xhtml
misc/graves_js_anim.xhtml
misc/hats_js_anim.xhtml
--- a/misc/flags_js.xhtml	Tue Aug 22 22:19:28 2023 +0200
+++ b/misc/flags_js.xhtml	Thu Aug 24 20:12:28 2023 +0200
@@ -142,15 +142,19 @@
     var flag_compare = function(a, b)
     {
         if (a === "hedgewars")
-            return false;
+            return -1;
         else if (b === "hedgewars")
-            return true;
+            return 1;
         else if (a.startsWith("cm_") && !b.startsWith("cm_"))
-            return true;
+            return 1;
         else if (!a.startsWith("cm_") && b.startsWith("cm_"))
-            return false;
+            return -1;
+        else if (a > b)
+            return 1;
+        else if (a < b)
+            return -1;
         else
-            return a > b;
+            return 0;
     }
 
     flags.sort(flag_compare);
@@ -204,7 +208,6 @@
         img.id = "__flag_"+flag;
 
         h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
-        h.lastChild.lastChild.data = flag;
         h.title = flag;
 
         if (j%17 === 16 || i === flags.length-1)
--- a/misc/graves_js_anim.xhtml	Tue Aug 22 22:19:28 2023 +0200
+++ b/misc/graves_js_anim.xhtml	Thu Aug 24 20:12:28 2023 +0200
@@ -183,7 +183,6 @@
             h.href = "//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Graves/"+graves[i]+".png";
 
         h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
-        h.lastChild.lastChild.data = graves[i];
         h.title = graves[i];
         h.idle = Math.floor(Math.random()*16);
         if (j%8 === 7 || i === graves.length-1)
@@ -227,7 +226,7 @@
     form.appendChild(chk);
     label = document.createElement("label");
     label.htmlFor = "anim";
-    label.appendChild(document.createTextNode("Animate graves"));
+    label.appendChild(document.createTextNode(" Animate graves"));
     form.appendChild(label);
 
     form.appendChild(document.createElement("br"));
@@ -241,12 +240,12 @@
     form.appendChild(chk);
     label = document.createElement("label");
     label.htmlFor = "hide_girders";
-    label.appendChild(document.createTextNode("Show girders"));
+    label.appendChild(document.createTextNode(" Show girders"));
     form.appendChild(label);
 
     document.body.appendChild(form);
 
-
+    switchTheme();
 }
 
 function animateGraves()
@@ -300,9 +299,10 @@
         prefix = "//hg.hedgewars.org/hedgewars/raw-file/tip";
     else
         prefix = "..";
-    document.body.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+this.value+'/Sky.png")';
-    if (themes[this.value])
-        girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+this.value+'/Girder.png")';
+    var theme = this.value || "Nature";
+    document.body.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+theme+'/Sky.png")';
+    if (themes[theme])
+        girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+theme+'/Girder.png")';
     else
         girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Graphics/Girder.png")';
 }
--- a/misc/hats_js_anim.xhtml	Tue Aug 22 22:19:28 2023 +0200
+++ b/misc/hats_js_anim.xhtml	Thu Aug 24 20:12:28 2023 +0200
@@ -34,7 +34,7 @@
     color: #BFBED0;
     text-decoration: none;
 }
-.hat
+.hat, .hatLocal
 {
     margin-top: 12px;
     margin-left: 20px;
@@ -42,8 +42,15 @@
     height: 32px;
     width: 32px;
     color: transparent;
+}
+.hat
+{
     background-image: url("//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Hedgehog/Idle.png");
 }
+.hatLocal
+{
+    background-image: url("../share/hedgewars/Data/Graphics/Hedgehog/Idle.png");
+}
 .girder
 {
     width: 100%;
@@ -177,7 +184,11 @@
     var a = document.createElement("a");
     var g = document.createElement("div");
     g.className="girder";
-    a.className="hat";
+    if (IS_LOCAL) {
+        a.className="hatLocal";
+    } else {
+        a.className="hat";
+    }
     a.appendChild(document.createElement("div"));
     a.lastChild.appendChild(document.createTextNode(""));
 
@@ -211,7 +222,6 @@
         img.id = "__mask_"+masks[i];
 
         h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
-        h.lastChild.lastChild.data = masks[i];
         h.title = masks[i];
         h.idle = Math.floor(Math.random()*19);
         if (j%17 === 16 || i === masks.length-1)
@@ -241,6 +251,7 @@
             if (i < missingMasks.length -1)
                 pm.appendChild(document.createTextNode(", "));
         }
+        document.body.appendChild(document.createElement("br"));
         document.body.appendChild(pm);
     }
 
@@ -280,7 +291,7 @@
     form.appendChild(chk);
     label = document.createElement("label");
     label.htmlFor = "anim";
-    label.appendChild(document.createTextNode("Animate hats"));
+    label.appendChild(document.createTextNode(" Animate hats"));
     form.appendChild(label);
 
     form.appendChild(document.createElement("br"));
@@ -294,12 +305,12 @@
     form.appendChild(chk);
     label = document.createElement("label");
     label.htmlFor = "hide_girders";
-    label.appendChild(document.createTextNode("Show girders"));
+    label.appendChild(document.createTextNode(" Show girders"));
     form.appendChild(label);
 
     document.body.appendChild(form);
 
-
+    switchTheme();
 }
 
 function animateHogs()
@@ -307,7 +318,7 @@
     var a = document.getElementsByTagName("a");
     for (var i=0;i<a.length;i++)
     {
-        if (a[i].className !== "hat")
+        if (a[i].className !== "hat" && a[i].className !== "hatLocal")
             continue;
         // Cycle through hedgehog and hat animation frames
 
@@ -371,9 +382,10 @@
         prefix = "//hg.hedgewars.org/hedgewars/raw-file/tip";
     else
         prefix = "..";
-    document.body.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+this.value+'/Sky.png")';
-    if (themes[this.value])
-        girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+this.value+'/Girder.png")';
+    var theme = this.value || "Nature";
+    document.body.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+theme+'/Sky.png")';
+    if (themes[theme])
+        girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+theme+'/Girder.png")';
     else
         girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Graphics/Girder.png")';
 }