misc/flags_js.xhtml
author unC0Rr
Wed, 20 Nov 2024 21:37:47 +0100
branchtransitional_engine
changeset 16038 d903f8d2395a
parent 15978 20adaa127663
permissions -rw-r--r--
- Update corrosion - Implement installation of targets imported with corrosion
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";
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
    59
let IS_LOCAL=false; // set to true to fetch flags locally. Useful for testing.
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
    60
let flags;
15605
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
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   101
let on_xml_loaded = function(ex)
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   102
{
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   103
    let resp = this.responseText;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   104
    let r = />([^<]*).png</g;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   105
    let x;
15605
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
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   113
let on_xml_error = function()
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   114
{
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   115
    let p = document.createElement("p");
15605
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
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   120
let on_flags_loaded;
15605
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
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   127
        let xml=new XMLHttpRequest();
15605
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
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   142
    let flag_compare = function(a, b)
15605
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")
15977
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15725
diff changeset
   145
            return -1;
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   146
        else if (b === "hedgewars")
15977
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15725
diff changeset
   147
            return 1;
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   148
        else if (a.startsWith("cm_") && !b.startsWith("cm_"))
15977
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15725
diff changeset
   149
            return 1;
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   150
        else if (!a.startsWith("cm_") && b.startsWith("cm_"))
15977
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15725
diff changeset
   151
            return -1;
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15725
diff changeset
   152
        else if (a > b)
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15725
diff changeset
   153
            return 1;
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15725
diff changeset
   154
        else if (a < b)
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15725
diff changeset
   155
            return -1;
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   156
        else
15977
f81fe8250ed9 Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents: 15725
diff changeset
   157
            return 0;
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   158
    }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   159
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   160
    flags.sort(flag_compare);
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   161
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   162
    // Render flags
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   163
    let img;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   164
    let j = 0;
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   165
    let toDelete = [];
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   166
    let a = document.createElement("a");
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   167
    a.className="flag";
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   168
    a.appendChild(document.createElement("div"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   169
    a.lastChild.appendChild(document.createTextNode(""));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   170
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   171
    let flagState = 0; // 0 = hedgewars, 1 = country flag, 2 = community flag ("cm_")
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   172
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   173
    for (let i=0;i<flags.length;i++)
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   174
    {
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   175
        let flag = flags[i];
15725
4e1ea1bdd803 Flags preview: Hide CPU flags
Wuzzy <Wuzzy2@mail.ru>
parents: 15605
diff changeset
   176
        // Skip CPU flags
4e1ea1bdd803 Flags preview: Hide CPU flags
Wuzzy <Wuzzy2@mail.ru>
parents: 15605
diff changeset
   177
        if (flag === "cpu" || flag === "cpu_plain")
4e1ea1bdd803 Flags preview: Hide CPU flags
Wuzzy <Wuzzy2@mail.ru>
parents: 15605
diff changeset
   178
            continue;
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   179
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   180
        let oldFlagState = flagState;
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   181
        if (flagState === 0 && flag !== "hedgewars")
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   182
            flagState++;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   183
        else if (flagState === 1 && flag.startsWith("cm_"))
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   184
            flagState++;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   185
        if (flagState !== oldFlagState)
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   186
        {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   187
            j = 0;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   188
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   189
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   190
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   191
        }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   192
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   193
        let h = document.body.appendChild(a.cloneNode(true));
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   194
        if (IS_LOCAL)
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   195
            h.href = "../share/hedgewars/Data/Graphics/Flags/"+flag+".png";
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   196
        else
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   197
            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
   198
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   199
        img = new Image();
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   200
        img.onload = function() {
15978
20adaa127663 Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents: 15977
diff changeset
   201
            let name = this.id.substr(7);
15605
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   202
            if (this.height === 32) {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   203
                staticMasks[name] = true;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   204
            }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   205
            this.remove();
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   206
        }
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   207
        img.src = h.href;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   208
        img.id = "__flag_"+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
        h.lastChild.style.backgroundImage = 'url("'+h.href+'")';
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   211
        h.title = flag;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   212
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   213
        if (j%17 === 16 || i === flags.length-1)
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   214
        {
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   215
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   216
            document.body.appendChild(document.createElement("br"));
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   217
            j = 0;
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   218
        } else
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   219
            j++;
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
}
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   223
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   224
//]]>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   225
    </script>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   226
</head>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   227
<body>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   228
<h1>List of Hedgewars flags</h1>
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
<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
   231
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
   232
</noscript>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   233
</body>
969bc30928da Add flags and graves preview pages
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   234
</html>