misc/hats_js_anim.xhtml
changeset 15563 af4bcdbf2c8f
parent 15562 799fd0a6d3bf
child 15564 732b82f44c83
equal deleted inserted replaced
15562:799fd0a6d3bf 15563:af4bcdbf2c8f
     4 <!-- There is, at present, no official xsd for (X)HTML5. A pity. Usefulness would depend on the parser and extensions made by the site.  -->
     4 <!-- There is, at present, no official xsd for (X)HTML5. A pity. Usefulness would depend on the parser and extensions made by the site.  -->
     5     <title>Hedgewars Hats</title>
     5     <title>Hedgewars Hats</title>
     6 
     6 
     7     <style type="text/css">
     7     <style type="text/css">
     8 * {padding: 0; margin: 0; }
     8 * {padding: 0; margin: 0; }
     9 body
     9 body 
    10 {
    10 {
    11     background: url('//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/Nature/Sky.png') fixed no-repeat bottom left;
    11     background: url('//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/Nature/Sky.png') fixed no-repeat bottom left;
    12     background-color: #0B203D;
    12     background-color: #0B203D;
    13     color: #FFD902;
    13     color: #FFD902;
    14     -moz-background-size: 200%;
    14     -moz-background-size: 200%;
    15     background-size: 100% 100%;
    15     background-size: 100% 100%;
    16     font-family: sans-serif;
    16     font-family: sans-serif;
    17 }
    17 }
    18 form, p
    18 h1 { text-shadow: 0 0 2px white; color: black;}
    19 {
    19 a 
    20     background-color: #0B203D;
       
    21     padding: 1em;
       
    22     margin: 1em;
       
    23     border-style: solid;
       
    24     border-radius: 5px;
       
    25     border-width: 2px;
       
    26     border-color: #FFD902;
       
    27 }
       
    28 h1 {
       
    29     text-shadow: 0 0 2px white;
       
    30     color: black;
       
    31     margin:10px;
       
    32 }
       
    33 a
       
    34 {
    20 {
    35     margin-top: 12px;
    21     margin-top: 12px;
    36     margin-left: 20px;
    22     margin-left: 20px;
    37     float: left;
    23     float: left;
    38     height: 32px;
    24     height: 32px;
    56     width: 32px;
    42     width: 32px;
    57 }
    43 }
    58     </style>
    44     </style>
    59     <script type="application/ecmascript">
    45     <script type="application/ecmascript">
    60 //<![CDATA[
    46 //<![CDATA[
    61 var IS_LOCAL=false; // set to true to fetch hats locally. Useful for testing.
    47 /* javascript version of a sprite sheet - this could be pretty trivially done in pure HTML, but maintenance
    62 var masks;
       
    63 if (IS_LOCAL) {
       
    64 /* JavaScript version of a sprite sheet - this could be pretty trivially done in pure HTML, but maintenance
       
    65 would be easier with a server-side portion. list of sprites could be gotten from server, but would require XSS whitelisting */
    48 would be easier with a server-side portion. list of sprites could be gotten from server, but would require XSS whitelisting */
    66 // Last updated: 1.0.0
    49 /*var masks = ['2001suit2', '2001suit', '4gsuif', 'AkuAku', 'android', 'angel', 'anzac', 'apple', 'ash', 'Balrog', 'banana', 'Bandit', 'bat', 'beaver', 'beefeater', 'Blanka', 'BlankaToothless', 'BlueCap', 'BlueHair', 'bobby2v', 'bobby', 'Bob', 'BrainSlugMouth', 'BrainSlug', 'britishpithhelmet', 'britmedic', 'britsapper', 'Bub', 'Bunny', 'bushhider', 'charlesdegaulle', 'charmander', 'chef', 'chikorita', 'Chunli', 'clown-copper', 'clown-crossed', 'clown', 'Coonskin3', 'Cororon', 'Cowboy', 'crown', 'cyborg', 'darthvader', 'Deer', 'desertgrenadier01', 'desertgrenadier02', 'desertgrenadier04', 'desertgrenadier05', 'desertgrenadierofficer', 'desertmedic', 'desertsapper1', 'desertsapper2', 'diglett', 'Disguise', 'Dragon', 'dwarf', 'eastertop', 'Elvis', 'Eva_00b', 'Eva_00y', 'Falcon', 'frenchwwigasmask', 'frenchwwihelmet', 'Gasmask', 'Geordi', 'germanwiimedichelmet', 'germanwwihelmetmustache', 'germanwwiipithhelmetdes', 'germanwwitankhelmet', 'Glasses', 'GreenCap', 'GreenHair', 'grenadier1', 'GreyHair', 'Guile', 'hedgehogk', 'HogInTheHat', 'hogpharoah', 'Honda', 'IndianChief', 'infernalhorns', 'InfernalHorns', 'Jason', 'jigglypuff', 'judo', 'junior', 'Ken', 'KirbyMask', 'kiss_criss', 'kiss_frehley', 'kiss_simmons', 'kiss_stanley', 'knight', 'Kululun', 'Ladle', 'lambda', 'Laminaria', 'laurel', 'lemon', 'link', 'lugia', 'Luigi', 'Mario', 'MegaHogX', 'metalband', 'mexicansunbrero', 'mickey_ears', 'Moose', 'mp3', 'mudkip', 'Mummy', 'naruto', 'NinjaFull', 'NinjaStraight', 'NinjaTriangle', 'OldMan', 'OrangeHair', 'orange', 'Pantsu', 'Pig', 'pikachu', 'PinkHair', 'pinksunhat', 'pirate_jack_bandana', 'pirate_jack', 'plainpith', 'Plunger', 'policecap', 'porkey', 'PrincessDaisy', 'PrincessPeach', 'Pumpkin_Hat', 'PurpleHair', 'quotecap', 'Rain', 'Rambo', 'rasta', 'RedCap', 'RedHair', 'RobinHood', 'royalguard', 'RSR', 'Ryu', 'Samurai', 'Samus', 'Santa', 'SauceBoatSilver', 'ShaggyYeti', 'sheep', 'ShortHair_Black', 'ShortHair_Brown', 'ShortHair_Grey', 'ShortHair_Red', 'ShortHair_Yellow', 'Skull', 'Sleepwalker', 'slowpoke', 'Sniper', 'Sonic', 'sovietcomrade2', 'sovietcomrade', 'SparkleSuperFun', 'SparkssHelmet', 'spartan', 'spcartman', 'spidey', 'spkenny', 'spkyle', 'spstan', 'squirtle', 'sth_AmyClassic', 'sth_Amy', 'sth_Eggman', 'sth_Knux', 'sth_Metal', 'sth_Shadow', 'sth_Sonic', 'sth_Super', 'sth_Tails', 'stormcloud', 'stormtrooper', 'StrawHatEyes', 'StrawHatFacial', 'StrawHat', 'Sunglasses', 'SunWukong', 'Teacup', 'Teapot', 'terminatorc', 'Terminator_Glasses', 'thug', 'Toad', 'tophats', 'touhou_chen', 'touhou_marisa', 'touhou_patchouli', 'touhou_remelia', 'touhou_suwako', 'touhou_yukari', 'trenchgrenadier1', 'trenchgrenadier2', 'trenchgrenadier3', 'ushanka', 'vampirichog', 'Vega', 'venom', 'Viking', 'voltorb', 'Wario', 'WhySoSerious', 'WizardHat', 'YellowCap', 'YellowHair', 'Zombi'];*/
    67 masks = ['4gsuif','AkuAku','android','angel','anzac','Bandit','barrelhider','bb_bob','bb_bub','bb_cororon','bb_kululun','beefeater','beefeaterhat','bishop','bobby','bobby2v','bubble','bushhider','cap_blue','cap_green','cap_junior','cap_red','cap_thinking','cap_yellow','car','chef','chuckl','clown','clown-copper','clown-crossed','constructor','Coonskin3','Cowboy','cratehider','crown','cyborg1','cyborg2','cyclops','Dan','Dauber','DayAndNight','Disguise','dish_Ladle','dish_SauceBoatSilver','dish_Teacup','dish_Teapot','doctor','Dragon','dwarf','eastertop','Einstein','Elvis','Eva_00b','Eva_00y','Evil','flag_french','flag_germany','flag_italy','flag_usa','footballhelmet','fr_apple','fr_banana','fr_lemon','fr_orange','fr_pumpkin','fr_tomato','Gasmask','Glasses','hair_blue','hair_green','hair_grey','hair_orange','hair_pink','hair_purple','hair_red','hair_yellow','HogInTheHat','hogpharoah','IndianChief','InfernalHorns','Jason','jester','Joker','judo','kiss_criss','kiss_frehley','kiss_simmons','kiss_stanley','knight','lambda','lambdahat','Laminaria','lamp','laurel','leprechaun','mechanicaltoy','MegaHogX','metalband','Meteorhelmet','mexicansunbrero','mickey_ears','Moustache','Moustache_glasses','mp3','Mummy','mv_Spidey','mv_Venom','naruto','NinjaFull','NinjaStraight','NinjaTriangle','noface','ntd_Falcon','ntd_Kirby','ntd_Link','ntd_Samus','nurse','nursehat','OldMan','Pantsu','pinksunhat','pirate_bandana','pirate_eyepatch','pirate_hat','pirate_jack','pirate_jack_bandana','Plunger',
    50 var masks = [];
    68 'poke_ash','poke_ash_hat','poke_charmander','poke_chikorita','poke_diglett','poke_jigglypuff','poke_lugia','poke_mudkip','poke_pikachu','poke_slowpoke','poke_squirtle','poke_voltorb','policecap','policegirl','punkman','quotecap','Rain','Rambo','RamboClean','rasta','RobinHood','royalguard','RSR','Samurai','Santa','scif_2001O','scif_2001Y','scif_BrainSlug','scif_BrainSlug2','scif_cosmonaut','scif_cyberpunk','scif_Geordi','scif_SparkssHelmet','scif_swDarthvader','scif_swStormtrooper','sf_balrog','sf_blanka','sf_blankatoothless','sf_chunli','sf_guile','sf_guile_hat','sf_honda','sf_ken','sf_ryu','sf_vega','sf_vega_hat','ShaggyYeti','ShortHair_Black','ShortHair_Brown','ShortHair_Grey','ShortHair_Red','ShortHair_Yellow','simple_green','simple_red','simple_yellow','Skull','Sleepwalker','sm_daisy','sm_luigi','sm_mario','sm_peach','sm_toad','sm_wario','Sniper','snorkel','snowhog','SparkleSuperFun','spartan','spcartman','spkenny','spkyle','spstan','sth_Amy','sth_AmyClassic','sth_Eggman','sth_Knux','sth_Metal','sth_Shadow','sth_Sonic','sth_SonicClassic','sth_Super','sth_Tails','stormcloud',
       
    69 'StrawHat','StrawHatEyes','StrawHatFacial','Sunglasses','SunWukong','swordsmensquire','TeamHeadband','TeamSoldier','TeamWheatley','Terminator_Glasses','tf_demoman','tf_scout','thug','thugclean','tiara','tophats','touhou_chen','touhou_marisa','touhou_patchouli','touhou_remelia','touhou_suwako','touhou_yukari','ushanka','vampirichog','vc_gakupo','vc_gumi','vc_kaito','vc_len','vc_luka','vc_meiko','vc_miku','vc_rin','Viking','war_airwarden02','war_airwarden03','war_americanww2helmet','war_britmedic','war_britpthhelmet','war_britsapper','war_desertgrenadier1','war_desertgrenadier2','war_desertgrenadier4','war_desertgrenadier5','war_desertmedic','war_desertofficer','war_desertsapper1','war_desertsapper2','war_frenchww1gasmask','war_frenchww1helmet','war_germanww1helmet2','war_germanww1tankhelm','war_germanww2medic','war_germanww2pith','war_grenadier1','war_plainpith','war_sovietcomrade1','war_sovietcomrade2','war_trenchfrench01','war_trenchfrench02','war_trenchgrenadier1','war_trenchgrenadier2','war_trenchgrenadier3','war_UNPeacekeeper01','war_UNPeacekeeper02','WhySoSerious','WizardHat','Zombi','zoo_Bat','zoo_Beaver','zoo_Bunny','zoo_chicken','zoo_crocodile','zoo_Deer','zoo_elephant','zoo_fish','zoo_frog','zoo_Hedgehog','zoo_Moose','zoo_octopus','zoo_Pig','zoo_Porkey','zoo_Sheep','zoo_snail','zoo_turtle'
       
    70 ,'NoHat','cap_team','hair_team','TeamTophat'
       
    71 ];
       
    72 }
       
    73 else
       
    74 {
       
    75 masks = [];
       
    76 }
       
    77 
       
    78 var themes = {
    51 var themes = {
    79 // Last updated: 1.0.0
    52 "Cave":1,
       
    53 "Golf":1,
       
    54 "Stage":1,
       
    55 "Island":0,
       
    56 "Eyes":0,
       
    57 "Deepspace":0,
       
    58 "Jungle":1,
       
    59 "Cake":0,
       
    60 "Compost":1,
       
    61 "Planes":0,
       
    62 "Olympics":1,
       
    63 "Bath":1,
       
    64 "Cheese":0,
       
    65 "Desert":1,
       
    66 "Christmas":1,
       
    67 "CrazyMission":0,
       
    68 "Sheep":1,
       
    69 "Brick":0,
       
    70 "Underwater":1,
       
    71 "City":1,
       
    72 "EarthRise":0,
       
    73 "Blox":0,
       
    74 "Hell":0,
       
    75 "Bamboo":1,
       
    76 "Freeway":0,
       
    77 "Nature":1,
    80 "Art":1,
    78 "Art":1,
    81 "Beach":1,
       
    82 "Bamboo":1,
       
    83 "Bath":1,
       
    84 "Blox":0,
       
    85 "Brick":0,
       
    86 "Cake":0,
       
    87 "Castle":1,
       
    88 "Cave":1,
       
    89 "City":1,
       
    90 "Cheese":0,
       
    91 "Christmas":1,
       
    92 "Compost":1,
       
    93 "CrazyMission":0,
       
    94 "Deepspace":0,
       
    95 "Desert":1,
       
    96 "EarthRise":0,
       
    97 "Eyes":0,
       
    98 "Freeway":0,
       
    99 "Fruit":1,
       
   100 "Halloween":1,
    79 "Halloween":1,
   101 "Hell":0,
       
   102 "Hoggywood":1,
       
   103 "Island":0,
       
   104 "Jungle":1,
       
   105 "Golf":1,
       
   106 "Nature":1,
       
   107 "Olympics":1,
       
   108 "Planes":0,
       
   109 "Sheep":1,
       
   110 "Snow":1,
    80 "Snow":1,
   111 "Stage":1,
    81 "Castle":1};
   112 "Underwater":1};
       
   113 var girder;
    82 var girder;
   114 var animationInterval;
    83 var animationInterval;
   115 
       
   116 var staticMasks = [];
       
   117 
       
   118 window.onload = function()
    84 window.onload = function()
   119 {
    85 {
   120     // Load list of hats
    86     var xml=new XMLHttpRequest();
   121     if (!IS_LOCAL) {
    87     xml.open("GET", "/hedgewars/file/tip/share/hedgewars/Data/Graphics/Hats/", false);
   122         // Request list of hats from repository URL
    88     xml.send(null);
   123         var xml=new XMLHttpRequest();
    89     /*var resp = xml.responseXML; unfortunately not served as XHTML
   124         xml.open("GET", "/hedgewars/file/tip/share/hedgewars/Data/Graphics/Hats/", false);
    90     var a = resp.getElementsByTagName("a");
   125         try {
    91     for(var i=0;i<a.length;i++);
   126            xml.send(null);
    92         if (/\.png/.test(a[0].href)) m.push(a[0].replace(/.png/,''));*/
   127         } catch (NetworkError) {
       
   128            var p = document.createElement("p");
       
   129            p.appendChild(document.createTextNode("ERROR: List of hats could not be fetched from the server!"));
       
   130            document.body.appendChild(p);
       
   131            return;
       
   132         }
       
   133     }
       
   134 
    93 
   135     // Exclude NoHat as uninteresting. Exclude team hats as we can't properly display them yet
    94     var resp = xml.responseText;
   136     // TODO: Add support for team hats
    95     var r = />([^<]*).png</g;
   137     var disallowedMasks = {
    96     var x;
   138         "NoHat":true,
    97     while(x = r.exec(resp)) 
   139         "hair_team":true,
    98         if (!/NoHat|hair_team|cap_team|TeamTophat/.test(x[1])) // Exclude NoHat as uninteresting. hair_team, cap_team and TeamTophat as repetitive team hats
   140         "cap_team":true,
    99             masks.push(x[1]);
   141         "TeamTophat":true,
       
   142     };
       
   143 
       
   144     // Render girders
       
   145     var s = document.styleSheets[0].cssRules;
       
   146     for(var i=0;i<s.length;i++)
       
   147     {
       
   148         if (s[i].selectorText.toLowerCase() === ".girder")
       
   149             girder = s[i];
       
   150     }
       
   151 
       
   152     var a = document.createElement("a");
       
   153     var g = document.createElement("div");
       
   154     g.className="girder";
       
   155     a.appendChild(document.createElement("div"));
       
   156     a.lastChild.appendChild(document.createTextNode(""));
       
   157 
       
   158     // Render hats
       
   159     var missingMasks = [];
       
   160     var img;
       
   161     for (var i=0;i<masks.length;i++)
       
   162     {
       
   163         if (disallowedMasks[masks[i]] === true) {
       
   164             missingMasks.push(masks[i]);
       
   165             continue;
       
   166         }
       
   167         var h = document.body.appendChild(a.cloneNode(true));
       
   168         if (IS_LOCAL)
       
   169             h.href = "../share/hedgewars/Data/Graphics/Hats/"+masks[i]+".png";
       
   170         else
       
   171             h.href = "//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Hats/"+masks[i]+".png";
       
   172 
       
   173         img = new Image();
       
   174         img.onload = function() {
       
   175             var name = this.id.substr(7);
       
   176             if (this.height === 32) {
       
   177                 staticMasks[name] = true;
       
   178             }
       
   179             this.remove();
       
   180         }
       
   181         img.src = h.href;
       
   182         img.id = "__mask_"+masks[i];
       
   183 
       
   184         h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
       
   185         h.lastChild.lastChild.data = masks[i];
       
   186         h.title = masks[i];
       
   187         h.idle = Math.floor(Math.random()*19);
       
   188         if (i%17 === 16 || i === masks.length-1)
       
   189             document.body.appendChild(g.cloneNode(false));
       
   190     }
       
   191     document.body.appendChild(g.cloneNode(false));
       
   192 
       
   193     // List missing hats
       
   194     var missingMasksStr = "";
       
   195     for (var i=0; i<missingMasks.length; i++)
       
   196     {
       
   197         if (missingMasks[i] === "NoHat")
       
   198             continue;
       
   199         missingMasksStr = missingMasksStr + missingMasks[i];
       
   200         if (i<missingMasks.length-1)
       
   201             missingMasksStr = missingMasksStr + ", ";
       
   202     }
       
   203     var pm = document.createElement("p");
       
   204     pm.appendChild(document.createTextNode("Other hats: " + missingMasksStr));
       
   205     document.body.appendChild(pm);
       
   206 
       
   207     // Quick and dirty animation
       
   208     animationInterval = setInterval(animateHogs, 128);
       
   209 
       
   210     // Theme selection drop-down list
       
   211     var form = document.body.appendChild(document.createElement("form"));
       
   212 
   100 
   213     var opt = document.createElement("option");
   101     var opt = document.createElement("option");
   214     opt.appendChild(document.createTextNode(""));
   102     opt.appendChild(document.createTextNode(""));
   215 
   103     var sel = document.body.appendChild(document.createElement("select"));
   216     var label = document.createElement("label");
       
   217     label.htmlFor = "theme_select";
       
   218     label.appendChild(document.createTextNode("Theme: "));
       
   219     form.appendChild(label);
       
   220 
       
   221     var sel = form.appendChild(document.createElement("select"));
       
   222     sel.id = "theme_select";
       
   223     sel.onchange = switchTheme;
   104     sel.onchange = switchTheme;
   224     for(var theme in themes)
   105     for(var theme in themes)
   225     {
   106     {
   226         sel.appendChild(opt.cloneNode(true));
   107         sel.appendChild(opt.cloneNode(true));
   227         sel.lastChild.value = theme;
   108         sel.lastChild.value = theme;
   228         sel.lastChild.lastChild.data = theme;
   109         sel.lastChild.lastChild.data = theme;
   229         if(theme === "Nature")
   110         if(theme === "Nature") sel.lastChild.selected = true;
   230             sel.lastChild.selected = true;
       
   231     }
   111     }
   232     form.appendChild(document.createElement("br"));
       
   233 
       
   234     // Checkbox: Switch animation
       
   235     var chk = document.createElement("input");
   112     var chk = document.createElement("input");
   236     chk.id = "anim";
       
   237     chk.type = "checkbox";
   113     chk.type = "checkbox";
   238     chk.onclick = switchAnim;
   114     chk.onclick = switchAnim;
   239     chk.checked = true;
   115     document.body.appendChild(chk);
   240     form.appendChild(chk);
   116     chk = chk.cloneNode(false);
   241     label = document.createElement("label");
       
   242     label.htmlFor = "anim";
       
   243     label.appendChild(document.createTextNode("Animate hats"));
       
   244     form.appendChild(label);
       
   245 
       
   246     form.appendChild(document.createElement("br"));
       
   247 
       
   248     // Checkbox: Hide girders
       
   249     chk = document.createElement("input");
       
   250     chk.id = "hide_girders";
       
   251     chk.type = "checkbox";
       
   252     chk.onclick = hideGirders;
   117     chk.onclick = hideGirders;
   253     chk.checked = true;
   118     document.body.appendChild(chk);
   254     form.appendChild(chk);
   119     var s = document.styleSheets[0].cssRules;
   255     label = document.createElement("label");
   120     for(var i=0;i<s.length;i++)
   256     label.htmlFor = "hide_girders";
   121         if (s[i].selectorText.toLowerCase() === ".girder") girder = s[i];
   257     label.appendChild(document.createTextNode("Show girders"));
   122         
   258     form.appendChild(label);
   123     var a = document.createElement("a");
   259 
   124     var g = document.createElement("div");
   260     document.body.appendChild(form);
   125     g.className="girder";
   261 
   126     a.appendChild(document.createElement("div"));
   262 
   127     a.lastChild.appendChild(document.createTextNode(""));
       
   128     for (var i=0;i<masks.length;i++)
       
   129     {
       
   130         var h = document.body.appendChild(a.cloneNode(true));
       
   131         h.href = "//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Hats/"+masks[i]+".png";
       
   132         h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
       
   133         h.lastChild.lastChild.data = masks[i];
       
   134         h.title = masks[i];
       
   135         h.idle = Math.floor(Math.random()*19);
       
   136         if (i%17 === 16 || i === masks.length-1) document.body.appendChild(g.cloneNode(false));
       
   137     }
       
   138     
       
   139 /* quick and dirty animation */
       
   140 animationInterval = setInterval(animateHogs, 128);
   263 }
   141 }
   264 
   142 
   265 function animateHogs()
   143 function animateHogs()
   266 {
   144 {
   267     var a = document.getElementsByTagName("a");
   145     var a = document.getElementsByTagName("a");
   268     for (var i=0;i<a.length;i++)
   146     for (var i=0;i<a.length;i++)
   269     {
   147     {
   270         // Cycle through hedgehog and hat animation frames
       
   271 
       
   272         // Hedgehog
       
   273         a[i].style.backgroundPosition=Math.floor(a[i].idle/16)*-32+"px "+(a[i].idle%16)*-32+"px";
   148         a[i].style.backgroundPosition=Math.floor(a[i].idle/16)*-32+"px "+(a[i].idle%16)*-32+"px";
   274 
   149         a[i].firstChild.style.backgroundPosition=Math.floor(a[i].idle/16)*-32+"px "+(a[i].idle%16)*-32+"px";
   275         // Hat
       
   276         if (staticMasks[masks[i]]) {
       
   277             // Hat offset for static hats
       
   278             if (a[i].idle === 2 || a[i].idle === 7 || a[i].idle === 12)
       
   279                 a[i].firstChild.style.marginTop="-4px";
       
   280             else if (a[i].idle === 16)
       
   281                 a[i].firstChild.style.marginTop="-6px";
       
   282             else
       
   283                 a[i].firstChild.style.marginTop="-5px";
       
   284 
       
   285             a[i].firstChild.style.backgroundPosition="0px 0px";
       
   286         }
       
   287         else
       
   288         {
       
   289             // Animated hat frames
       
   290             a[i].firstChild.style.backgroundPosition=Math.floor(a[i].idle/16)*-32+"px "+(a[i].idle%16)*-32+"px";
       
   291         }
       
   292 
       
   293         // Next frame
       
   294         a[i].idle++;
   150         a[i].idle++;
   295         if (a[i].idle > 18)
   151         if (a[i].idle > 18) a[i].idle = 0;
   296             a[i].idle = 0;
       
   297     }
   152     }
   298 }
   153 }
   299 
   154 
   300 // Turn on or off hog+hat animation
       
   301 function switchAnim()
   155 function switchAnim()
   302 {
   156 {
   303     if (animationInterval)
   157     if (animationInterval) 
   304     {
   158     {
   305         clearInterval(animationInterval);
   159         clearInterval(animationInterval);
   306         animationInterval = null;
   160         animationInterval = null;
   307     }
   161     }
   308     else animationInterval = setInterval(animateHogs, 128);
   162     else animationInterval = setInterval(animateHogs, 128);
   309 }
   163 }
   310 
   164 
   311 // Turn on or off girders
       
   312 function hideGirders()
   165 function hideGirders()
   313 {
   166 {
   314     var g = document.getElementsByClassName("girder");
   167     var g = document.getElementsByClassName("girder");
   315     for(var i=0;i<g.length;i++)
   168     for(var i=0;i<g.length;i++) 
   316         if (this.checked)
   169         if (this.checked)
       
   170             g[i].className = "girder hide";
       
   171         else
   317             g[i].className = "girder";
   172             g[i].className = "girder";
   318         else
   173     
   319             g[i].className = "girder hide";
       
   320 
       
   321 }
   174 }
   322 
   175 
   323 // Select theme according to drop-down list value
       
   324 function switchTheme()
   176 function switchTheme()
   325 {
   177 {
   326     var prefix;
   178     document.body.style.backgroundImage='url("//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/'+this.value+'/Sky.png")';
   327     if (IS_LOCAL)
   179     if (themes[this.value])
   328         prefix = "//hg.hedgewars.org/hedgewars/raw-file/tip";
   180         girder.style.backgroundImage='url("//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/'+this.value+'/Girder.png")';
   329     else
   181     else
   330         prefix = "..";
   182         girder.style.backgroundImage='url("//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Girder.png")';
   331     document.body.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+this.value+'/Sky.png")';
       
   332     if (themes[this.value])
       
   333         girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+this.value+'/Girder.png")';
       
   334     else
       
   335         girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Graphics/Girder.png")';
       
   336 }
   183 }
   337 //]]>
   184 //]]>
   338     </script>
   185     </script>
   339 </head>
   186 </head>
   340 <body>
   187 <body>
   341 <h1>List of Hedgewars hats</h1>
   188 <h1>List of Hedgewars hats</h1>
   342 <noscript>
   189 <noscript>
   343 <p><strong>ERROR</strong>: We're so sorry, but this webpage only works with JavaScript enabled. It seems JavaScript is disabled or not supported in your browser.<br/>
   190 <p><strong>ERROR</strong>: We're so sorry, but this webpage only works with JavaScript enabled. It seems JavaScript is disabled or not supported in your browser.</p>
   344 Normally, this webpage would display an animated preview of the hats in Hedgewars.</p>
   191 <p>Normally, this webpage would display an animated preview of the hats in Hedgewars.</p>
   345 </noscript>
   192 </noscript>
   346 </body>
   193 </body>
   347 </html>
   194 </html>