misc/hats_js_anim.xhtml
author Wuzzy <Wuzzy2@mail.ru>
Sat, 16 May 2020 01:04:27 +0200
changeset 15583 3c1c5ff824f7
parent 13513 7e188a28f078
child 15584 799fd0a6d3bf
permissions -rw-r--r--
Many improvements and fixes for hats webpage * Fix static hats not being animated properly * Make widges more user-friendly * Add local mode to hats webpage to make testing easier (IS_LOCAL variable) * Cleanup code * Update themes list * Update list of local hats
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; }
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
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
{
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    11
    background: url('https://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
}
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    18
form, p
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    19
{
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    20
    background-color: #0B203D;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    21
    padding: 1em;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    22
    margin: 1em;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    23
    border-style: solid;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    24
    border-radius: 5px;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    25
    border-width: 2px;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    26
    border-color: #FFD902;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    27
}
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    28
h1 {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    29
    text-shadow: 0 0 2px white;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    30
    color: black;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    31
    margin:10px;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    32
}
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    33
a
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
    34
{
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
    35
    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
    36
    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
    37
    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
    38
    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
    39
    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
    40
    color: transparent;
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    41
    background-image: url("https://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
    42
}
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
.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
    44
{
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
    45
    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
    46
    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
    47
    clear: left;
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    48
    background-image: url('https://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
    49
    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
    50
}
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
    51
.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
    52
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
    53
{
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
    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
    55
    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
    56
    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
    57
}
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
    </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
    59
    <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
    60
//<![CDATA[
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    61
var IS_LOCAL=false; // set to true to fetch hats locally. Useful for testing.
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    62
var masks;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    63
if (IS_LOCAL) {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    64
/* 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
    65
would be easier with a server-side portion. list of sprites could be gotten from server, but would require XSS whitelisting */
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    66
// Last updated: 1.0.0
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    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',
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    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',
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    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'
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    70
,'NoHat','cap_team','hair_team','TeamTophat'
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    71
];
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    72
}
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    73
else
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    74
{
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    75
masks = [];
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    76
}
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    77
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
    78
var themes = {
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    79
// Last updated: 1.0.0
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    80
"Art":1,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    81
"Beach":1,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    82
"Bamboo":1,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    83
"Bath":1,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    84
"Blox":0,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    85
"Brick":0,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    86
"Cake":0,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    87
"Castle":1,
6936
8af2bf10ee62 theme tweaks
nemo
parents: 6419
diff changeset
    88
"Cave":1,
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    89
"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
    90
"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
    91
"Christmas":1,
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    92
"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
    93
"CrazyMission":0,
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    94
"Deepspace":0,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    95
"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
    96
"EarthRise":0,
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    97
"Eyes":0,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    98
"Freeway":0,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
    99
"Fruit":1,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   100
"Halloween":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
"Hell":0,
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   102
"Hoggywood":1,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   103
"Island":0,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   104
"Jungle":1,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   105
"Golf":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
   106
"Nature":1,
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   107
"Olympics":1,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   108
"Planes":0,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   109
"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
   110
"Snow":1,
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   111
"Stage":1,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   112
"Underwater":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
   113
var 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
   114
var animationInterval;
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   115
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   116
var staticMasks = [];
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   117
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
   118
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
   119
{
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   120
    // Load list of hats
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   121
    if (!IS_LOCAL) {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   122
        // Request list of hats from repository URL
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   123
        var xml=new XMLHttpRequest();
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   124
        xml.open("GET", "/hedgewars/file/tip/share/hedgewars/Data/Graphics/Hats/", false);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   125
        try {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   126
           xml.send(null);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   127
        } catch (NetworkError) {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   128
           var p = document.createElement("p");
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   129
           p.appendChild(document.createTextNode("ERROR: List of hats could not be fetched from the server!"));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   130
           document.body.appendChild(p);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   131
           return;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   132
        }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   133
    }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   134
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   135
    // Exclude NoHat as uninteresting. Exclude team hats as we can't properly display them yet
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   136
    // TODO: Add support for team hats
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   137
    var disallowedMasks = {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   138
        "NoHat":true,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   139
        "hair_team":true,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   140
        "cap_team":true,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   141
        "TeamTophat":true,
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   142
    };
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   143
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   144
    // Render girders
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   145
    var s = document.styleSheets[0].cssRules;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   146
    for(var i=0;i<s.length;i++)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   147
    {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   148
        if (s[i].selectorText.toLowerCase() === ".girder")
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   149
            girder = s[i];
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   150
    }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   151
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   152
    var a = document.createElement("a");
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   153
    var g = document.createElement("div");
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   154
    g.className="girder";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   155
    a.appendChild(document.createElement("div"));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   156
    a.lastChild.appendChild(document.createTextNode(""));
5778
45fe3fa062b1 Load list of hats dynamically.
nemo
parents: 5763
diff changeset
   157
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   158
    // Render hats
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   159
    var missingMasks = [];
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   160
    var img;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   161
    for (var i=0;i<masks.length;i++)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   162
    {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   163
        if (disallowedMasks[masks[i]] === true) {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   164
            missingMasks.push(masks[i]);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   165
            continue;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   166
        }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   167
        var h = document.body.appendChild(a.cloneNode(true));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   168
        if (IS_LOCAL)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   169
            h.href = "../share/hedgewars/Data/Graphics/Hats/"+masks[i]+".png";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   170
        else
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   171
            h.href = "https://hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Hats/"+masks[i]+".png";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   172
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   173
        img = new Image();
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   174
        img.onload = function() {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   175
            var name = this.id.substr(7);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   176
            if (this.height === 32) {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   177
                staticMasks[name] = true;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   178
            }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   179
            this.remove();
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   180
        }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   181
        img.src = h.href;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   182
        img.id = "__mask_"+masks[i];
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   183
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   184
        h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   185
        h.lastChild.lastChild.data = masks[i];
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   186
        h.title = masks[i];
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   187
        h.idle = Math.floor(Math.random()*19);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   188
        if (i%17 === 16 || i === masks.length-1)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   189
            document.body.appendChild(g.cloneNode(false));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   190
    }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   191
    document.body.appendChild(g.cloneNode(false));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   192
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   193
    // List missing hats
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   194
    var missingMasksStr = "";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   195
    for (var i=0; i<missingMasks.length; i++)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   196
    {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   197
        if (missingMasks[i] === "NoHat")
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   198
            continue;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   199
        missingMasksStr = missingMasksStr + missingMasks[i];
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   200
        if (i<missingMasks.length-1)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   201
            missingMasksStr = missingMasksStr + ", ";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   202
    }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   203
    var pm = document.createElement("p");
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   204
    pm.appendChild(document.createTextNode("Other hats: " + missingMasksStr));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   205
    document.body.appendChild(pm);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   206
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   207
    // Quick and dirty animation
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   208
    animationInterval = setInterval(animateHogs, 128);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   209
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   210
    // Theme selection drop-down list
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   211
    var form = document.body.appendChild(document.createElement("form"));
5778
45fe3fa062b1 Load list of hats dynamically.
nemo
parents: 5763
diff changeset
   212
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
   213
    var opt = document.createElement("option");
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
   214
    opt.appendChild(document.createTextNode(""));
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   215
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   216
    var label = document.createElement("label");
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   217
    label.htmlFor = "theme_select";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   218
    label.appendChild(document.createTextNode("Theme: "));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   219
    form.appendChild(label);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   220
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   221
    var sel = form.appendChild(document.createElement("select"));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   222
    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
   223
    sel.onchange = 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
   224
    for(var theme in themes)
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
   225
    {
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
   226
        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
   227
        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
   228
        sel.lastChild.lastChild.data = theme;
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   229
        if(theme === "Nature")
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   230
            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
   231
    }
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   232
    form.appendChild(document.createElement("br"));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   233
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   234
    // Checkbox: Switch 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
   235
    var chk = document.createElement("input");
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   236
    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
   237
    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
   238
    chk.onclick = switchAnim;
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   239
    chk.checked = true;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   240
    form.appendChild(chk);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   241
    label = document.createElement("label");
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   242
    label.htmlFor = "anim";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   243
    label.appendChild(document.createTextNode("Animate hats"));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   244
    form.appendChild(label);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   245
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   246
    form.appendChild(document.createElement("br"));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   247
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   248
    // Checkbox: Hide girders
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   249
    chk = document.createElement("input");
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   250
    chk.id = "hide_girders";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   251
    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
   252
    chk.onclick = hideGirders;
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   253
    chk.checked = true;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   254
    form.appendChild(chk);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   255
    label = document.createElement("label");
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   256
    label.htmlFor = "hide_girders";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   257
    label.appendChild(document.createTextNode("Show girders"));
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   258
    form.appendChild(label);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   259
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   260
    document.body.appendChild(form);
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   261
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   262
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
   263
}
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
   264
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
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
   266
{
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
   267
    var a = document.getElementsByTagName("a");
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
   268
    for (var i=0;i<a.length;i++)
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
   269
    {
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   270
        // Cycle through hedgehog and hat animation frames
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   271
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   272
        // 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
   273
        a[i].style.backgroundPosition=Math.floor(a[i].idle/16)*-32+"px "+(a[i].idle%16)*-32+"px";
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   274
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   275
        // Hat
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   276
        if (staticMasks[masks[i]]) {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   277
            // Hat offset for static hats
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   278
            if (a[i].idle === 2 || a[i].idle === 7 || a[i].idle === 12)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   279
                a[i].firstChild.style.marginTop="-4px";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   280
            else if (a[i].idle === 16)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   281
                a[i].firstChild.style.marginTop="-6px";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   282
            else
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   283
                a[i].firstChild.style.marginTop="-5px";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   284
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   285
            a[i].firstChild.style.backgroundPosition="0px 0px";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   286
        }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   287
        else
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   288
        {
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   289
            // Animated hat frames
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   290
            a[i].firstChild.style.backgroundPosition=Math.floor(a[i].idle/16)*-32+"px "+(a[i].idle%16)*-32+"px";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   291
        }
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   292
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   293
        // 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
   294
        a[i].idle++;
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   295
        if (a[i].idle > 18)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   296
            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
   297
    }
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
   298
}
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
   299
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   300
// 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
   301
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
   302
{
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   303
    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
   304
    {
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
   305
        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
   306
        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
   307
    }
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
   308
    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
   309
}
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
   310
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   311
// 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
   312
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
   313
{
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
    var g = document.getElementsByClassName("girder");
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   315
    for(var 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
   316
        if (this.checked)
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   317
            g[i].className = "girder";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   318
        else
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
   319
            g[i].className = "girder hide";
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   320
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
   321
}
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
   322
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   323
// 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
   324
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
   325
{
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   326
    var prefix;
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   327
    if (IS_LOCAL)
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   328
        prefix = "https://hg.hedgewars.org/hedgewars/raw-file/tip";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   329
    else
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   330
        prefix = "..";
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   331
    document.body.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+this.value+'/Sky.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
   332
    if (themes[this.value])
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   333
        girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+this.value+'/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
   334
    else
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   335
        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
   336
}
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
   337
//]]>
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
   338
    </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
   339
</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
   340
<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
   341
<h1>List of Hedgewars hats</h1>
13409
697aaee36684 Add <noscript> fallback for hats preview webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 12927
diff changeset
   342
<noscript>
15583
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   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/>
3c1c5ff824f7 Many improvements and fixes for hats webpage
Wuzzy <Wuzzy2@mail.ru>
parents: 13513
diff changeset
   344
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
   345
</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
   346
</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
   347
</html>