misc/hats_js_anim.xhtml
author alfadur
Mon, 25 Mar 2024 00:23:41 +0300
changeset 16027 14fe5bfe9862
parent 16007 20adaa127663
permissions -rw-r--r--
grow network buffer periodically
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
     1
<!DOCTYPE HTML>
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
     2
<html xmlns="http://www.w3.org/1999/xhtml">
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
     3
<head>
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
     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.  -->
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
     5
    <title>Hedgewars Hats</title>
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
     6
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
     7
    <style type="text/css">
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
     8
* {padding: 0; margin: 0; }
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
     9
body
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    10
{
15587
ff58b2a18d85 Hats webpage: Remove protocol from URLs to fix CORS fail
Wuzzy <Wuzzy2@mail.ru>
parents: 15586
diff changeset
    11
    background: url('//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/Nature/Sky.png') fixed no-repeat bottom left;
13410
7487e683c6b6 More fallback styling for hat preview webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13409
diff changeset
    12
    background-color: #0B203D;
7487e683c6b6 More fallback styling for hat preview webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13409
diff changeset
    13
    color: #FFD902;
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    14
    -moz-background-size: 200%;
6419
6a464d0a5c13 Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents: 5779
diff changeset
    15
    background-size: 100% 100%;
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    16
    font-family: sans-serif;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    17
}
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    18
form, p
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    19
{
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    20
    background-color: #0B203D;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    21
    padding: 1em;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    22
    margin: 1em;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    23
    border-style: solid;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    24
    border-radius: 5px;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    25
    border-width: 2px;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    26
    border-color: #FFD902;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    27
}
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    28
h1 {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    29
    text-shadow: 0 0 2px white;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    30
    color: black;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    31
    margin:10px;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    32
}
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    33
a {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    34
    color: #BFBED0;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    35
    text-decoration: none;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    36
}
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
    37
.hat, .hatLocal
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    38
{
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    39
    margin-top: 12px;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    40
    margin-left: 20px;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    41
    float: left;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    42
    height: 32px;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    43
    width: 32px;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    44
    color: transparent;
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
    45
}
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
    46
.hat
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
    47
{
15587
ff58b2a18d85 Hats webpage: Remove protocol from URLs to fix CORS fail
Wuzzy <Wuzzy2@mail.ru>
parents: 15586
diff changeset
    48
    background-image: url("//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Hedgehog/Idle.png");
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    49
}
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
    50
.hatLocal
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
    51
{
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
    52
    background-image: url("../share/hedgewars/Data/Graphics/Hedgehog/Idle.png");
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
    53
}
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    54
.girder
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    55
{
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    56
    width: 100%;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    57
    height: 30px;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    58
    clear: left;
15587
ff58b2a18d85 Hats webpage: Remove protocol from URLs to fix CORS fail
Wuzzy <Wuzzy2@mail.ru>
parents: 15586
diff changeset
    59
    background-image: url('//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/Nature/Girder.png');
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    60
    background-repeat: repeat-x;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    61
}
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    62
.hide { visibility: hidden; }
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    63
a div
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    64
{
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    65
    margin-top: -5px;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    66
    height: 32px;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    67
    width: 32px;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    68
}
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    69
    </style>
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    70
    <script type="application/ecmascript">
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
    71
//<![CDATA[
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
    72
let IS_LOCAL=false; // set to true to fetch graves locally. Useful for testing.
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
    73
let masks;
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    74
if (IS_LOCAL) {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    75
/* JavaScript version of a sprite sheet - this could be pretty trivially done in pure HTML, but maintenance
13513
7e188a28f078 Remove and replace old googlecode references
Wuzzy <Wuzzy2@mail.ru>
parents: 13410
diff changeset
    76
would be easier with a server-side portion. list of sprites could be gotten from server, but would require XSS whitelisting */
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    77
// Last updated: 1.0.0
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    78
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',
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    79
'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',
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    80
'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'
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    81
,'NoHat','cap_team','hair_team','TeamTophat'
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    82
];
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    83
}
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    84
else
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    85
{
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    86
masks = [];
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    87
}
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    88
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
    89
let themes = {
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    90
// Last updated: 1.0.0
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    91
"Art":1,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    92
"Beach":1,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    93
"Bamboo":1,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    94
"Bath":1,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    95
//"Blox":0, //unused, has no Sky.png or Border.png
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    96
"Brick":0,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    97
"Cake":0,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
    98
"Castle":1,
15585
af4bcdbf2c8f Backed out changesets 799fd0a6d3bf+3c1c5ff824f7
Wuzzy <Wuzzy2@mail.ru>
parents: 15584
diff changeset
    99
"Cave":1,
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   100
"City":1,
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   101
"Cheese":0,
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   102
"Christmas":1,
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   103
"Compost":1,
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   104
"CrazyMission":0,
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   105
"Deepspace":0,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   106
"Desert":1,
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   107
"EarthRise":0,
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   108
"Eyes":0,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   109
"Freeway":0,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   110
"Fruit":1,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   111
"Halloween":1,
15585
af4bcdbf2c8f Backed out changesets 799fd0a6d3bf+3c1c5ff824f7
Wuzzy <Wuzzy2@mail.ru>
parents: 15584
diff changeset
   112
"Hell":0,
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   113
"Hoggywood":1,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   114
"Island":0,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   115
"Jungle":1,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   116
"Golf":1,
15585
af4bcdbf2c8f Backed out changesets 799fd0a6d3bf+3c1c5ff824f7
Wuzzy <Wuzzy2@mail.ru>
parents: 15584
diff changeset
   117
"Nature":1,
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   118
"Olympics":1,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   119
"Planes":0,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   120
"Sheep":1,
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   121
"Snow":1,
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   122
"Stage":1,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   123
"Underwater":1};
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   124
let girder;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   125
let animationInterval;
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   126
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   127
let staticMasks = [];
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   128
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   129
on_xml_loaded = function(ex)
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   130
{
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   131
    let resp = this.responseText;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   132
    let r = />([^<]*).png</g;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   133
    let x;
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   134
    while(x = r.exec(resp))
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   135
    {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   136
        masks.push(x[1]);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   137
    }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   138
    on_hats_loaded();
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   139
}
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   140
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   141
on_xml_error = function()
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   142
{
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   143
    let p = document.createElement("p");
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   144
    p.appendChild(document.createTextNode("ERROR: List of hats could not be fetched from the server!"));
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   145
    document.body.appendChild(p);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   146
}
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   147
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   148
window.onload = function()
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   149
{
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   150
    // Load list of hats
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   151
    if (!IS_LOCAL) {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   152
        // Request list of hats from repository URL
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   153
        let xml=new XMLHttpRequest();
15587
ff58b2a18d85 Hats webpage: Remove protocol from URLs to fix CORS fail
Wuzzy <Wuzzy2@mail.ru>
parents: 15586
diff changeset
   154
        xml.open("GET", "//hg.hedgewars.org/hedgewars/file/tip/share/hedgewars/Data/Graphics/Hats/");
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   155
        xml.addEventListener("error", on_xml_error);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   156
        xml.onload = on_xml_loaded;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   157
        xml.send();
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   158
    }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   159
    else
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   160
    {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   161
        on_hats_loaded();
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   162
    }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   163
}
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   164
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   165
on_hats_loaded = function()
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   166
{
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   167
    // Exclude NoHat as uninteresting. Exclude team hats as we can't properly display them yet
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   168
    // TODO: Add support for team hats
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   169
    let disallowedMasks = {
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   170
        "NoHat":true,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   171
        "hair_team":true,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   172
        "cap_team":true,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   173
        "TeamTophat":true,
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   174
    };
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   175
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   176
    // Render girders
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   177
    let s = document.styleSheets[0].cssRules;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   178
    for(let i=0;i<s.length;i++)
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   179
    {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   180
        if (s[i].selectorText.toLowerCase() === ".girder")
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   181
            girder = s[i];
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   182
    }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   183
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   184
    let a = document.createElement("a");
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   185
    let g = document.createElement("div");
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   186
    g.className="girder";
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   187
    if (IS_LOCAL) {
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   188
        a.className="hatLocal";
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   189
    } else {
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   190
        a.className="hat";
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   191
    }
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   192
    a.appendChild(document.createElement("div"));
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   193
    a.lastChild.appendChild(document.createTextNode(""));
5778
45fe3fa062b1 Load list of hats dynamically.
nemo
parents: 5763
diff changeset
   194
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   195
    // Render hats
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   196
    let missingMasks = [];
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   197
    let img;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   198
    let j = 0;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   199
    let toDelete = [];
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   200
    for (let i=0;i<masks.length;i++)
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   201
    {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   202
        if (disallowedMasks[masks[i]] === true) {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   203
            missingMasks.push(masks[i]);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   204
            toDelete.push(i);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   205
            continue;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   206
        }
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   207
        let h = document.body.appendChild(a.cloneNode(true));
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   208
        if (IS_LOCAL)
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   209
            h.href = "../share/hedgewars/Data/Graphics/Hats/"+masks[i]+".png";
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   210
        else
15587
ff58b2a18d85 Hats webpage: Remove protocol from URLs to fix CORS fail
Wuzzy <Wuzzy2@mail.ru>
parents: 15586
diff changeset
   211
            h.href = "//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Hats/"+masks[i]+".png";
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   212
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   213
        img = new Image();
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   214
        img.onload = function() {
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   215
            let name = this.id.substr(7);
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   216
            if (this.height === 32) {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   217
                staticMasks[name] = true;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   218
            }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   219
            this.remove();
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   220
        }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   221
        img.src = h.href;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   222
        img.id = "__mask_"+masks[i];
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   223
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   224
        h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   225
        h.title = masks[i];
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   226
        h.idle = Math.floor(Math.random()*19);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   227
        if (j%17 === 16 || i === masks.length-1)
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   228
            document.body.appendChild(g.cloneNode(false));
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   229
        j++;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   230
    }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   231
    // Cleanup masks array
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   232
    for (let i=0; i<toDelete.length; i++)
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   233
        masks.splice(toDelete[i], 1);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   234
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   235
    // List missing hats
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   236
    if (missingMasks.length > 0)
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   237
    {
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   238
        let pm = document.createElement("p");
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   239
        pm.appendChild(document.createTextNode("Other hats: "));
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   240
        for (let i=0; i<missingMasks.length; i++)
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   241
        {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   242
            if (missingMasks[i] === "NoHat")
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   243
                continue;
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   244
            let link = document.createElement("a");
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   245
            if (IS_LOCAL)
15588
909ef1f3ef19 Hats webpage: Fix "other hats" section listing wrong hats
Wuzzy <Wuzzy2@mail.ru>
parents: 15587
diff changeset
   246
                link.href = "../share/hedgewars/Data/Graphics/Hats/"+missingMasks[i]+".png";
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   247
            else
15588
909ef1f3ef19 Hats webpage: Fix "other hats" section listing wrong hats
Wuzzy <Wuzzy2@mail.ru>
parents: 15587
diff changeset
   248
                link.href = "//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Hats/"+missingMasks[i]+".png";
909ef1f3ef19 Hats webpage: Fix "other hats" section listing wrong hats
Wuzzy <Wuzzy2@mail.ru>
parents: 15587
diff changeset
   249
            link.appendChild(document.createTextNode(missingMasks[i]));
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   250
            pm.appendChild(link);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   251
            if (i < missingMasks.length -1)
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   252
                pm.appendChild(document.createTextNode(", "));
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   253
        }
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   254
        document.body.appendChild(document.createElement("br"));
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   255
        document.body.appendChild(pm);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   256
    }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   257
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   258
    // Quick and dirty animation
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   259
    animationInterval = setInterval(animateHogs, 128);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   260
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   261
    // Theme selection drop-down list
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   262
    let form = document.body.appendChild(document.createElement("form"));
5778
45fe3fa062b1 Load list of hats dynamically.
nemo
parents: 5763
diff changeset
   263
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   264
    let opt = document.createElement("option");
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   265
    opt.appendChild(document.createTextNode(""));
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   266
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   267
    let label = document.createElement("label");
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   268
    label.htmlFor = "theme_select";
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   269
    label.appendChild(document.createTextNode("Theme: "));
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   270
    form.appendChild(label);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   271
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   272
    let sel = form.appendChild(document.createElement("select"));
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   273
    sel.id = "theme_select";
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   274
    sel.onchange = switchTheme;
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   275
    for(let theme in themes)
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   276
    {
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   277
        sel.appendChild(opt.cloneNode(true));
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   278
        sel.lastChild.value = theme;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   279
        sel.lastChild.lastChild.data = theme;
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   280
        if(theme === "Nature")
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   281
            sel.lastChild.selected = true;
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   282
    }
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   283
    form.appendChild(document.createElement("br"));
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   284
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   285
    // Checkbox: Switch animation
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   286
    let chk = document.createElement("input");
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   287
    chk.id = "anim";
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   288
    chk.type = "checkbox";
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   289
    chk.onclick = switchAnim;
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   290
    chk.checked = true;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   291
    form.appendChild(chk);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   292
    label = document.createElement("label");
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   293
    label.htmlFor = "anim";
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   294
    label.appendChild(document.createTextNode(" Animate hats"));
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   295
    form.appendChild(label);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   296
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   297
    form.appendChild(document.createElement("br"));
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   298
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   299
    // Checkbox: Hide girders
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   300
    chk = document.createElement("input");
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   301
    chk.id = "hide_girders";
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   302
    chk.type = "checkbox";
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   303
    chk.onclick = hideGirders;
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   304
    chk.checked = true;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   305
    form.appendChild(chk);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   306
    label = document.createElement("label");
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   307
    label.htmlFor = "hide_girders";
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   308
    label.appendChild(document.createTextNode(" Show girders"));
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   309
    form.appendChild(label);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   310
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   311
    document.body.appendChild(form);
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   312
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   313
    switchTheme();
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   314
}
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   315
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   316
function animateHogs()
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   317
{
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   318
    let a = document.getElementsByTagName("a");
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   319
    for (let i=0;i<a.length;i++)
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   320
    {
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   321
        if (a[i].className !== "hat" && a[i].className !== "hatLocal")
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   322
            continue;
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   323
        // Cycle through hedgehog and hat animation frames
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   324
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   325
        // Hedgehog
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   326
        a[i].style.backgroundPosition=Math.floor(a[i].idle/16)*-32+"px "+(a[i].idle%16)*-32+"px";
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   327
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   328
        let maskName = a[i].title;
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   329
        // Hat
15590
de1b31c2d2f2 Hats webpage: Fix another incorrect static hat check
Wuzzy <Wuzzy2@mail.ru>
parents: 15589
diff changeset
   330
        if (staticMasks[maskName] === true) {
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   331
            // Hat offset for static hats
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   332
            if (a[i].idle === 2 || a[i].idle === 7 || a[i].idle === 12)
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   333
                a[i].firstChild.style.marginTop="-4px";
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   334
            else if (a[i].idle === 16)
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   335
                a[i].firstChild.style.marginTop="-6px";
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   336
            else
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   337
                a[i].firstChild.style.marginTop="-5px";
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   338
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   339
            a[i].firstChild.style.backgroundPosition="0px 0px";
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   340
        }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   341
        else
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   342
        {
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   343
            // Animated hat frames
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   344
            a[i].firstChild.style.backgroundPosition=Math.floor(a[i].idle/16)*-32+"px "+(a[i].idle%16)*-32+"px";
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   345
        }
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   346
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   347
        // Next frame
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   348
        a[i].idle++;
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   349
        if (a[i].idle > 18)
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   350
            a[i].idle = 0;
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   351
    }
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   352
}
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   353
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   354
// Turn on or off hog+hat animation
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   355
function switchAnim()
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   356
{
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   357
    if (animationInterval)
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   358
    {
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   359
        clearInterval(animationInterval);
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   360
        animationInterval = null;
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   361
    }
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   362
    else animationInterval = setInterval(animateHogs, 128);
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   363
}
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   364
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   365
// Turn on or off girders
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   366
function hideGirders()
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   367
{
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   368
    let g = document.getElementsByClassName("girder");
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   369
    for(let i=0;i<g.length;i++)
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   370
        if (this.checked)
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   371
            g[i].className = "girder";
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   372
        else
15585
af4bcdbf2c8f Backed out changesets 799fd0a6d3bf+3c1c5ff824f7
Wuzzy <Wuzzy2@mail.ru>
parents: 15584
diff changeset
   373
            g[i].className = "girder hide";
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   374
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   375
}
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   376
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   377
// Select theme according to drop-down list value
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   378
function switchTheme()
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   379
{
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   380
    let prefix;
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   381
    if (!IS_LOCAL)
15587
ff58b2a18d85 Hats webpage: Remove protocol from URLs to fix CORS fail
Wuzzy <Wuzzy2@mail.ru>
parents: 15586
diff changeset
   382
        prefix = "//hg.hedgewars.org/hedgewars/raw-file/tip";
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   383
    else
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   384
        prefix = "..";
16007
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 16006
diff changeset
   385
    let theme = this.value || "Nature";
16006
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   386
    document.body.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+theme+'/Sky.png")';
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   387
    if (themes[theme])
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15590
diff changeset
   388
        girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+theme+'/Girder.png")';
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   389
    else
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   390
        girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Graphics/Girder.png")';
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   391
}
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   392
//]]>
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   393
    </script>
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   394
</head>
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   395
<body>
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   396
<h1>List of Hedgewars hats</h1>
13409
697aaee36684 Add <noscript> fallback for hats preview webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 12927
diff changeset
   397
<noscript>
15586
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   398
<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/>
732b82f44c83 Hats webpage: Many improvements and fixes (2nd try)
Wuzzy <Wuzzy2@mail.ru>
parents: 15585
diff changeset
   399
Normally, this webpage would display an animated preview of the hats in Hedgewars.</p>
13409
697aaee36684 Add <noscript> fallback for hats preview webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 12927
diff changeset
   400
</noscript>
5071
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   401
</body>
0b931e96bee9 Adding a hat test page to version control. Also kind of a test to see if it will be served with the right content type by google code
nemo
parents:
diff changeset
   402
</html>