|
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") |
|
145 return false; |
|
146 else if (b === "hedgewars") |
|
147 return true; |
|
148 else if (a.startsWith("cm_") && !b.startsWith("cm_")) |
|
149 return true; |
|
150 else if (!a.startsWith("cm_") && b.startsWith("cm_")) |
|
151 return false; |
|
152 else |
|
153 return a > b; |
|
154 } |
|
155 |
|
156 flags.sort(flag_compare); |
|
157 |
|
158 // Render flags |
|
159 var img; |
|
160 var j = 0; |
|
161 var toDelete = []; |
|
162 var a = document.createElement("a"); |
|
163 a.className="flag"; |
|
164 a.appendChild(document.createElement("div")); |
|
165 a.lastChild.appendChild(document.createTextNode("")); |
|
166 |
|
167 var flagState = 0; // 0 = hedgewars, 1 = country flag, 2 = community flag ("cm_") |
|
168 |
|
169 for (var i=0;i<flags.length;i++) |
|
170 { |
|
171 var flag = flags[i]; |
|
172 |
|
173 var oldFlagState = flagState; |
|
174 if (flagState === 0 && flag !== "hedgewars") |
|
175 flagState++; |
|
176 else if (flagState === 1 && flag.startsWith("cm_")) |
|
177 flagState++; |
|
178 if (flagState !== oldFlagState) |
|
179 { |
|
180 j = 0; |
|
181 document.body.appendChild(document.createElement("br")); |
|
182 document.body.appendChild(document.createElement("br")); |
|
183 document.body.appendChild(document.createElement("br")); |
|
184 } |
|
185 |
|
186 var h = document.body.appendChild(a.cloneNode(true)); |
|
187 if (IS_LOCAL) |
|
188 h.href = "../share/hedgewars/Data/Graphics/Flags/"+flag+".png"; |
|
189 else |
|
190 h.href = "//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Flags/"+flag+".png"; |
|
191 |
|
192 img = new Image(); |
|
193 img.onload = function() { |
|
194 var name = this.id.substr(7); |
|
195 if (this.height === 32) { |
|
196 staticMasks[name] = true; |
|
197 } |
|
198 this.remove(); |
|
199 } |
|
200 img.src = h.href; |
|
201 img.id = "__flag_"+flag; |
|
202 |
|
203 h.lastChild.style.backgroundImage = 'url("'+h.href+'")'; |
|
204 h.lastChild.lastChild.data = flag; |
|
205 h.title = flag; |
|
206 |
|
207 if (j%17 === 16 || i === flags.length-1) |
|
208 { |
|
209 document.body.appendChild(document.createElement("br")); |
|
210 document.body.appendChild(document.createElement("br")); |
|
211 j = 0; |
|
212 } else |
|
213 j++; |
|
214 } |
|
215 |
|
216 } |
|
217 |
|
218 //]]> |
|
219 </script> |
|
220 </head> |
|
221 <body> |
|
222 <h1>List of Hedgewars flags</h1> |
|
223 <noscript> |
|
224 <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/> |
|
225 Normally, this webpage would display a preview of the flags in Hedgewars.</p> |
|
226 </noscript> |
|
227 </body> |
|
228 </html> |