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