misc/flags_js.xhtml
author unC0Rr
Tue, 05 Sep 2023 17:01:46 +0200
branchtransitional_engine
changeset 16007 96d0e6149d3d
parent 15725 4e1ea1bdd803
child 15977 f81fe8250ed9
permissions -rw-r--r--
Fix type
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     1
<!DOCTYPE HTML>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     2
<html xmlns="http://www.w3.org/1999/xhtml">
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     3
<head>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
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.  -->
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     5
    <title>Hedgewars Flags</title>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     6
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     7
    <style type="text/css">
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     8
* {padding: 0; margin: 0; }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     9
body
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    10
{
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    11
    background-color: #0B203D;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    12
    color: #FFD902;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    13
    background-size: 100% 100%;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    14
    font-family: sans-serif;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    15
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    16
form, p
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    17
{
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    18
    background-color: #0B203D;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    19
    padding: 1em;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    20
    margin: 1em;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    21
    border-style: solid;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    22
    border-radius: 5px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    23
    border-width: 2px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    24
    border-color: #FFD902;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    25
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    26
h1 {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    27
    margin:10px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    28
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    29
a {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    30
    color: #BFBED0;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    31
    text-decoration: none;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    32
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    33
.flag
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    34
{
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    35
    margin-top: 12px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    36
    margin-left: 20px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    37
    float: left;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    38
    border-radius: 3px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    39
    border-color: white;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    40
    border-width: 1px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    41
    border-style: solid;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    42
    height: 17px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    43
    width: 24px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    44
    color: transparent;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    45
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    46
a div
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    47
{
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    48
    height: 15px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    49
    width: 22px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    50
    border-radius: 3px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    51
    border-color: black;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    52
    border-width: 1px;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    53
    border-style: solid;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    54
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    55
    </style>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    56
    <script type="application/ecmascript">
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    57
//<![CDATA[
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    58
"use strict";
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    59
var IS_LOCAL=false; // set to true to fetch flags locally. Useful for testing.
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    60
var flags;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    61
if (IS_LOCAL) {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    62
/* JavaScript version of a sprite sheet - this could be pretty trivially done in pure HTML, but maintenance
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    63
would be easier with a server-side portion. list of sprites could be gotten from server, but would require XSS whitelisting */
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    64
// Last updated: 1.0.0
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    65
flags=["afghanistan","albania","algeria","american_samoa","andorra","angola","anguilla","antigua_and_barbuda","arabemirates",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    66
"argentina","armenia","aruba","australia","austria","azerbaijan","bahamas","bahrain","bangladesh","barbados","belarus","belgium",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    67
"belize","benin","bhutan","bolivia","bosnia_and_herzegovina","botswana","brazil","brunei","bulgaria","burkina_faso","burundi",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    68
"cambodia","cameroon","canada","cape_verde","central_african_republic","chad","chile","china","christmas_island","cm_42",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    69
"cm_anarchy","cm_balls","cm_balrog","cm_bars","cm_belarus","cm_binary","cm_birdy","cm_bloodyblade","cm_brittany","cm_bubbles",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    70
"cm_bustamove","cm_cheese","cm_cog","cm_crossedswords","cm_crosshair","cm_cyborg","cm_danger_fire","cm_danger_stripes",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    71
"cm_dragonrb","cm_duckhead","cm_earth2","cm_earth","cm_eyeofhorus","cm_eyes","cm_face","cm_fcw","cm_female","cm_firstaid",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    72
"cm_flames","cm_flower","cm_galaxy","cm_girder","cm_grenade","cm_hax0r","cm_heart","cm_hellish","cm_hurrah","cm_hw2",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    73
"cm_hw","cm_iluvu","cm_kiwi","cm_lips","cm_magicskull","cm_male","cm_mog","cm_music","cm_pacman2","cm_pacman","cm_pentagram",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    74
"cm_piet","cm_pirate","cm_pokemon","cm_scout","cm_shoppa","cm_sine","cm_skull","cm_sonic","cm_soviet","cm_spider","cm_star",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    75
"cm_swordshield2","cm_swordshield","cm_test","cm_vampire","cm_waves","cm_yinyang","colombia","comoros",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    76
"congo-brazzaville","congo_kinshasa","cook_islands","costa_rica","cote_divoire","croatia","cuba","cyprus",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    77
"czech_republic","denmark","djibouti","dominican_republic","dominica","easttimor","ecuador","egypt","el_salvador",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    78
"equatorial_guinea","eritrea","esperanto","estonia","ethiopia","europeanunion","fiji","finland","france","gabon","gambia",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    79
"georgia","germany","ghana","greece","grenada","guam","guatemala","guinea","guyana","haiti","hedgewars","honduras","hungary",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    80
"iceland","india","indonesia","iran","iraq","ireland","israel","italy","jamaica","japan","jordan","kazakhstan","kenya","kiribati",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    81
"kuwait","kyrgyzstan","laos","latvia","lebanon","lesotho","liberia","libya","liechtenstein","lithuania","luxembourg","macau",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    82
"macedonia","madagascar","malawi","malaysia","maldives","mali","malta","marshall_islands","mauritania","mauritius",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    83
"mexico","micronesia","moldova","monaco","mongolia","montenegro","montserrat","morocco","mozambique","myanmar","namibia","nauru",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    84
"nepal","netherlands","new_zealand","nicaragua","nigeria","niger","niue","northern_mariana","northkorea","norway","oman",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    85
"pakistan","palau","palestine","panama","papua_new_guinea","paraguay","peru","philippines","poland","portugal","puerto_rico",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    86
"qatar","quebec","romania","russian_federation","rwanda","saint_kitts_and_nevis","saint_lucia","saint_vincent_and_the_grenadines",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    87
"samoa","san_marino","saotomeandprincipe","saudiarabia","senegal","serbia_and_montenegro","serbia","seychelles","sicily",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    88
"sierra_leone","singapore","slovakia","slovenia","solomon_islands","somalia","south_africa","south_korea","south_sudan","spain",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    89
"sri_lanka","sudan","suisse","suriname","swaziland","sweden","syrian_arab_republic","taiwan","tajikistan","tanzania","thailand",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    90
"tibet","timor_leste","togo","tokelau","tonga","trinidad_and_tobago","tunisia","turkey","turkmenistan","tuvalu","uganda","ukraine",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    91
"uk_scotland","united_arab_emirates","united_kingdom","united_states","uruguay","uzbekistan","vanuatu","vatican","venezuela","vietnam",
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    92
"western_sahara","yemen","yugoslavia","zambia","zimbabwe"
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    93
//,"cpu","cpu_plain"
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    94
];
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    95
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    96
else
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    97
{
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    98
flags = [];
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    99
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   100
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   101
var on_xml_loaded = function(ex)
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   102
{
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   103
    var resp = this.responseText;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   104
    var r = />([^<]*).png</g;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   105
    var x;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   106
    while(x = r.exec(resp))
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   107
    {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   108
        flags.push(x[1]);
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   109
    }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   110
    on_flags_loaded();
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   111
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   112
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   113
var on_xml_error = function()
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   114
{
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   115
    var p = document.createElement("p");
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   116
    p.appendChild(document.createTextNode("ERROR: List of flags could not be fetched from the server!"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   117
    document.body.appendChild(p);
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   118
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   119
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   120
var on_flags_loaded;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   121
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   122
window.onload = function()
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   123
{
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   124
    // Load list of flags
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   125
    if (!IS_LOCAL) {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   126
        // Request list of flags from repository URL
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   127
        var xml=new XMLHttpRequest();
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   128
        xml.open("GET", "//hg.hedgewars.org/hedgewars/file/tip/share/hedgewars/Data/Graphics/Flags/");
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   129
        xml.addEventListener("error", on_xml_error);
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   130
        xml.onload = on_xml_loaded;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   131
        xml.send();
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   132
    }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   133
    else
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   134
    {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   135
        on_flags_loaded();
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   136
    }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   137
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   138
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   139
on_flags_loaded = function()
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   140
{
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   141
    // Sort flags
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   142
    var flag_compare = function(a, b)
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   143
    {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   144
        if (a === "hedgewars")
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   145
            return false;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   146
        else if (b === "hedgewars")
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   147
            return true;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   148
        else if (a.startsWith("cm_") && !b.startsWith("cm_"))
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   149
            return true;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   150
        else if (!a.startsWith("cm_") && b.startsWith("cm_"))
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   151
            return false;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   152
        else
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   153
            return a > b;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   154
    }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   155
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   156
    flags.sort(flag_compare);
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   157
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   158
    // Render flags
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   159
    var img;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   160
    var j = 0;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   161
    var toDelete = [];
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   162
    var a = document.createElement("a");
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   163
    a.className="flag";
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   164
    a.appendChild(document.createElement("div"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   165
    a.lastChild.appendChild(document.createTextNode(""));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   166
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   167
    var flagState = 0; // 0 = hedgewars, 1 = country flag, 2 = community flag ("cm_")
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   168
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   169
    for (var i=0;i<flags.length;i++)
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   170
    {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   171
        var flag = flags[i];
15725
4e1ea1bdd803 Flags preview: Hide CPU flags
Wuzzy <Wuzzy2@mail.ru>
parents: 15605
diff changeset
   172
        // Skip CPU flags
4e1ea1bdd803 Flags preview: Hide CPU flags
Wuzzy <Wuzzy2@mail.ru>
parents: 15605
diff changeset
   173
        if (flag === "cpu" || flag === "cpu_plain")
4e1ea1bdd803 Flags preview: Hide CPU flags
Wuzzy <Wuzzy2@mail.ru>
parents: 15605
diff changeset
   174
            continue;
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   175
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   176
        var oldFlagState = flagState;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   177
        if (flagState === 0 && flag !== "hedgewars")
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   178
            flagState++;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   179
        else if (flagState === 1 && flag.startsWith("cm_"))
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   180
            flagState++;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   181
        if (flagState !== oldFlagState)
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   182
        {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   183
            j = 0;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   184
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   185
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   186
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   187
        }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   188
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   189
        var h = document.body.appendChild(a.cloneNode(true));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   190
        if (IS_LOCAL)
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   191
            h.href = "../share/hedgewars/Data/Graphics/Flags/"+flag+".png";
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   192
        else
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   193
            h.href = "//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Flags/"+flag+".png";
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   194
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   195
        img = new Image();
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   196
        img.onload = function() {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   197
            var name = this.id.substr(7);
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   198
            if (this.height === 32) {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   199
                staticMasks[name] = true;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   200
            }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   201
            this.remove();
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   202
        }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   203
        img.src = h.href;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   204
        img.id = "__flag_"+flag;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   205
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   206
        h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   207
        h.lastChild.lastChild.data = flag;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   208
        h.title = flag;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   209
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   210
        if (j%17 === 16 || i === flags.length-1)
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   211
        {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   212
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   213
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   214
            j = 0;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   215
        } else
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   216
            j++;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   217
    }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   218
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   219
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   220
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   221
//]]>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   222
    </script>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   223
</head>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   224
<body>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   225
<h1>List of Hedgewars flags</h1>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   226
<noscript>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   227
<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/>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   228
Normally, this webpage would display a preview of the flags in Hedgewars.</p>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   229
</noscript>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   230
</body>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   231
</html>