author | Wuzzy <Wuzzy@disroot.org> |
Thu, 24 Aug 2023 20:12:28 +0200 | |
changeset 16006 | f81fe8250ed9 |
parent 15747 | 4e1ea1bdd803 |
child 16007 | 20adaa127663 |
permissions | -rw-r--r-- |
15628 | 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"; |
|
59 |
var IS_LOCAL=false; // set to true to fetch flags locally. Useful for testing. |
|
60 |
var flags; |
|
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 |
||
101 |
var on_xml_loaded = function(ex) |
|
102 |
{ |
|
103 |
var resp = this.responseText; |
|
104 |
var r = />([^<]*).png</g; |
|
105 |
var x; |
|
106 |
while(x = r.exec(resp)) |
|
107 |
{ |
|
108 |
flags.push(x[1]); |
|
109 |
} |
|
110 |
on_flags_loaded(); |
|
111 |
} |
|
112 |
||
113 |
var on_xml_error = function() |
|
114 |
{ |
|
115 |
var p = document.createElement("p"); |
|
116 |
p.appendChild(document.createTextNode("ERROR: List of flags could not be fetched from the server!")); |
|
117 |
document.body.appendChild(p); |
|
118 |
} |
|
119 |
||
120 |
var on_flags_loaded; |
|
121 |
||
122 |
window.onload = function() |
|
123 |
{ |
|
124 |
// Load list of flags |
|
125 |
if (!IS_LOCAL) { |
|
126 |
// Request list of flags from repository URL |
|
127 |
var xml=new XMLHttpRequest(); |
|
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 |
|
142 |
var flag_compare = function(a, b) |
|
143 |
{ |
|
144 |
if (a === "hedgewars") |
|
16006
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15747
diff
changeset
|
145 |
return -1; |
15628 | 146 |
else if (b === "hedgewars") |
16006
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15747
diff
changeset
|
147 |
return 1; |
15628 | 148 |
else if (a.startsWith("cm_") && !b.startsWith("cm_")) |
16006
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15747
diff
changeset
|
149 |
return 1; |
15628 | 150 |
else if (!a.startsWith("cm_") && b.startsWith("cm_")) |
16006
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15747
diff
changeset
|
151 |
return -1; |
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15747
diff
changeset
|
152 |
else if (a > b) |
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15747
diff
changeset
|
153 |
return 1; |
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15747
diff
changeset
|
154 |
else if (a < b) |
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15747
diff
changeset
|
155 |
return -1; |
15628 | 156 |
else |
16006
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15747
diff
changeset
|
157 |
return 0; |
15628 | 158 |
} |
159 |
||
160 |
flags.sort(flag_compare); |
|
161 |
||
162 |
// Render flags |
|
163 |
var img; |
|
164 |
var j = 0; |
|
165 |
var toDelete = []; |
|
166 |
var a = document.createElement("a"); |
|
167 |
a.className="flag"; |
|
168 |
a.appendChild(document.createElement("div")); |
|
169 |
a.lastChild.appendChild(document.createTextNode("")); |
|
170 |
||
171 |
var flagState = 0; // 0 = hedgewars, 1 = country flag, 2 = community flag ("cm_") |
|
172 |
||
173 |
for (var i=0;i<flags.length;i++) |
|
174 |
{ |
|
175 |
var flag = flags[i]; |
|
15747 | 176 |
// Skip CPU flags |
177 |
if (flag === "cpu" || flag === "cpu_plain") |
|
178 |
continue; |
|
15628 | 179 |
|
180 |
var oldFlagState = flagState; |
|
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 |
||
193 |
var h = document.body.appendChild(a.cloneNode(true)); |
|
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() { |
|
201 |
var name = this.id.substr(7); |
|
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> |