misc/hats_js_anim.xhtml
branchhedgeroid
changeset 15515 7030706266df
parent 13512 7e188a28f078
equal deleted inserted replaced
7861:bc7b6aa5d67a 15515:7030706266df
     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('http://hedgewars.googlecode.com/hg/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;
       
    13     color: #FFD902;
    12     -moz-background-size: 200%;
    14     -moz-background-size: 200%;
    13     background-size: 100% 100%;
    15     background-size: 100% 100%;
    14     font-family: sans-serif;
    16     font-family: sans-serif;
    15 }
    17 }
    16 h1 { text-shadow: 0 0 2px white; }
    18 h1 { text-shadow: 0 0 2px white; color: black;}
    17 a 
    19 a 
    18 {
    20 {
    19     margin-top: 12px;
    21     margin-top: 12px;
    20     margin-left: 20px;
    22     margin-left: 20px;
    21     float: left;
    23     float: left;
    22     height: 32px;
    24     height: 32px;
    23     width: 32px;
    25     width: 32px;
    24     color: transparent;
    26     color: transparent;
    25     background-image: url("http://hedgewars.googlecode.com/hg/share/hedgewars/Data/Graphics/Hedgehog/Idle.png");
    27     background-image: url("//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Hedgehog/Idle.png");
    26 }
    28 }
    27 .girder
    29 .girder
    28 {
    30 {
    29     width: 100%;
    31     width: 100%;
    30     height: 30px;
    32     height: 30px;
    31     clear: left;
    33     clear: left;
    32     background-image: url('http://hedgewars.googlecode.com/hg/share/hedgewars/Data/Themes/Nature/Girder.png');
    34     background-image: url('//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/Nature/Girder.png');
    33     background-repeat: repeat-x;
    35     background-repeat: repeat-x;
    34 }
    36 }
    35 .hide { visibility: hidden; }
    37 .hide { visibility: hidden; }
    36 a div
    38 a div
    37 {
    39 {
    41 }
    43 }
    42     </style>
    44     </style>
    43     <script type="application/ecmascript">
    45     <script type="application/ecmascript">
    44 //<![CDATA[
    46 //<![CDATA[
    45 /* javascript version of a sprite sheet - this could be pretty trivially done in pure HTML, but maintenance
    47 /* javascript version of a sprite sheet - this could be pretty trivially done in pure HTML, but maintenance
    46 would be easier with a server-side portion. list of sprites could be gotten from googlecode, 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 */
    47 /*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'];*/
    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'];*/
    48 var masks = [];
    50 var masks = [];
    49 var themes = {
    51 var themes = {
    50 "Cave":1,
    52 "Cave":1,
    51 "Golf":1,
    53 "Golf":1,
    80 var girder;
    82 var girder;
    81 var animationInterval;
    83 var animationInterval;
    82 window.onload = function()
    84 window.onload = function()
    83 {
    85 {
    84     var xml=new XMLHttpRequest();
    86     var xml=new XMLHttpRequest();
    85     xml.open("GET", "/hg/share/hedgewars/Data/Graphics/Hats/", false);
    87     xml.open("GET", "/hedgewars/file/tip/share/hedgewars/Data/Graphics/Hats/", false);
    86     xml.send(null);
    88     xml.send(null);
    87     /*var resp = xml.responseXML; unfortunately not served as XHTML
    89     /*var resp = xml.responseXML; unfortunately not served as XHTML
    88     var a = resp.getElementsByTagName("a");
    90     var a = resp.getElementsByTagName("a");
    89     for(var i=0;i<a.length;i++);
    91     for(var i=0;i<a.length;i++);
    90         if (/\.png/.test(a[0].href)) m.push(a[0].replace(/.png/,''));*/
    92         if (/\.png/.test(a[0].href)) m.push(a[0].replace(/.png/,''));*/
    91 
    93 
    92     var resp = xml.responseText;
    94     var resp = xml.responseText;
    93     var r = />([^<]*).png</g;
    95     var r = />([^<]*).png</g;
    94     var x;
    96     var x;
    95     while(x = r.exec(resp)) 
    97     while(x = r.exec(resp)) 
    96         if (!/^Team|NoHat/.test(x[1])) // Exclude team coloured ones as repetitive, NoHat one as uninteresting
    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
    97             masks.push(x[1]);
    99             masks.push(x[1]);
    98 
   100 
    99     var opt = document.createElement("option");
   101     var opt = document.createElement("option");
   100     opt.appendChild(document.createTextNode(""));
   102     opt.appendChild(document.createTextNode(""));
   101     var sel = document.body.appendChild(document.createElement("select"));
   103     var sel = document.body.appendChild(document.createElement("select"));
   103     for(var theme in themes)
   105     for(var theme in themes)
   104     {
   106     {
   105         sel.appendChild(opt.cloneNode(true));
   107         sel.appendChild(opt.cloneNode(true));
   106         sel.lastChild.value = theme;
   108         sel.lastChild.value = theme;
   107         sel.lastChild.lastChild.data = theme;
   109         sel.lastChild.lastChild.data = theme;
   108         if(theme == "Nature") sel.lastChild.selected = true;
   110         if(theme === "Nature") sel.lastChild.selected = true;
   109     }
   111     }
   110     var chk = document.createElement("input");
   112     var chk = document.createElement("input");
   111     chk.type = "checkbox";
   113     chk.type = "checkbox";
   112     chk.onclick = switchAnim;
   114     chk.onclick = switchAnim;
   113     document.body.appendChild(chk);
   115     document.body.appendChild(chk);
   114     chk = chk.cloneNode(false);
   116     chk = chk.cloneNode(false);
   115     chk.onclick = hideGirders;
   117     chk.onclick = hideGirders;
   116     document.body.appendChild(chk);
   118     document.body.appendChild(chk);
   117     var s = document.styleSheets[0].cssRules;
   119     var s = document.styleSheets[0].cssRules;
   118     for(var i=0;i<s.length;i++)
   120     for(var i=0;i<s.length;i++)
   119         if (s[i].selectorText.toLowerCase()==".girder") girder = s[i];
   121         if (s[i].selectorText.toLowerCase() === ".girder") girder = s[i];
   120         
   122         
   121     var a = document.createElement("a");
   123     var a = document.createElement("a");
   122     var g = document.createElement("div");
   124     var g = document.createElement("div");
   123     g.className="girder";
   125     g.className="girder";
   124     a.appendChild(document.createElement("div"));
   126     a.appendChild(document.createElement("div"));
   125     a.lastChild.appendChild(document.createTextNode(""));
   127     a.lastChild.appendChild(document.createTextNode(""));
   126     for (var i=0;i<masks.length;i++)
   128     for (var i=0;i<masks.length;i++)
   127     {
   129     {
   128         var h = document.body.appendChild(a.cloneNode(true));
   130         var h = document.body.appendChild(a.cloneNode(true));
   129         h.href = "http://hedgewars.googlecode.com/hg/share/hedgewars/Data/Graphics/Hats/"+masks[i]+".png";
   131         h.href = "//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Hats/"+masks[i]+".png";
   130         h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
   132         h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
   131         h.lastChild.lastChild.data = masks[i];
   133         h.lastChild.lastChild.data = masks[i];
   132         h.title = masks[i];
   134         h.title = masks[i];
   133         h.idle = Math.floor(Math.random()*19);
   135         h.idle = Math.floor(Math.random()*19);
   134         if (i%17==16 || i==masks.length-1) document.body.appendChild(g.cloneNode(false));
   136         if (i%17 === 16 || i === masks.length-1) document.body.appendChild(g.cloneNode(false));
   135     }
   137     }
   136     
   138     
   137 /* quick and dirty animation */
   139 /* quick and dirty animation */
   138 animationInterval = setInterval(animateHogs, 128);
   140 animationInterval = setInterval(animateHogs, 128);
   139 }
   141 }
   171     
   173     
   172 }
   174 }
   173 
   175 
   174 function switchTheme()
   176 function switchTheme()
   175 {
   177 {
   176     document.body.style.backgroundImage='url("http://hedgewars.googlecode.com/hg/share/hedgewars/Data/Themes/'+this.value+'/Sky.png")';
   178     document.body.style.backgroundImage='url("//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/'+this.value+'/Sky.png")';
   177     if (themes[this.value])
   179     if (themes[this.value])
   178         girder.style.backgroundImage='url("http://hedgewars.googlecode.com/hg/share/hedgewars/Data/Themes/'+this.value+'/Girder.png")';
   180         girder.style.backgroundImage='url("//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/'+this.value+'/Girder.png")';
   179     else
   181     else
   180         girder.style.backgroundImage='url("http://hedgewars.googlecode.com/hg/share/hedgewars/Data/Graphics/Girder.png")';
   182         girder.style.backgroundImage='url("//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Girder.png")';
   181 }
   183 }
   182 //]]>
   184 //]]>
   183     </script>
   185     </script>
   184 </head>
   186 </head>
   185 <body>
   187 <body>
   186 <h1>List of Hedgewars hats</h1>
   188 <h1>List of Hedgewars hats</h1>
       
   189 <noscript>
       
   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>
       
   191 <p>Normally, this webpage would display an animated preview of the hats in Hedgewars.</p>
       
   192 </noscript>
   187 </body>
   193 </body>
   188 </html>
   194 </html>