author | unC0Rr |
Tue, 03 Sep 2024 13:56:35 +0200 | |
branch | transitional_engine |
changeset 16058 | 9cbd18220eb7 |
parent 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 Graves</title> |
|
6 |
||
7 |
<style type="text/css"> |
|
8 |
* {padding: 0; margin: 0; } |
|
9 |
body |
|
10 |
{ |
|
11 |
background: url('//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/Nature/Sky.png') fixed no-repeat bottom left; |
|
12 |
background-color: #0B203D; |
|
13 |
color: #FFD902; |
|
14 |
-moz-background-size: 200%; |
|
15 |
background-size: 100% 100%; |
|
16 |
font-family: sans-serif; |
|
17 |
} |
|
18 |
form, p |
|
19 |
{ |
|
20 |
background-color: #0B203D; |
|
21 |
padding: 1em; |
|
22 |
margin: 1em; |
|
23 |
border-style: solid; |
|
24 |
border-radius: 5px; |
|
25 |
border-width: 2px; |
|
26 |
border-color: #FFD902; |
|
27 |
} |
|
28 |
h1 { |
|
29 |
text-shadow: 0 0 2px white; |
|
30 |
color: black; |
|
31 |
margin:10px; |
|
32 |
} |
|
33 |
a { |
|
34 |
color: #BFBED0; |
|
35 |
text-decoration: none; |
|
36 |
} |
|
37 |
.grave |
|
38 |
{ |
|
39 |
margin-top: 12px; |
|
40 |
margin-left: 20px; |
|
41 |
float: left; |
|
42 |
height: 32px; |
|
43 |
width: 32px; |
|
44 |
color: transparent; |
|
45 |
} |
|
46 |
.girder |
|
47 |
{ |
|
48 |
width: 100%; |
|
49 |
height: 30px; |
|
50 |
clear: left; |
|
51 |
background-image: url('//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Themes/Nature/Girder.png'); |
|
52 |
background-repeat: repeat-x; |
|
53 |
} |
|
54 |
.hide { visibility: hidden; } |
|
55 |
a div |
|
56 |
{ |
|
15629
c61dddd7c1a8
Graves preview page: Change grave margin
Wuzzy <Wuzzy2@mail.ru>
parents:
15628
diff
changeset
|
57 |
margin-top: 6px; |
15628 | 58 |
height: 32px; |
59 |
width: 32px; |
|
60 |
} |
|
61 |
</style> |
|
62 |
<script type="application/ecmascript"> |
|
63 |
//<![CDATA[ |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
64 |
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:
16006
diff
changeset
|
65 |
let graves; |
15628 | 66 |
if (IS_LOCAL) { |
67 |
/* JavaScript version of a sprite sheet - this could be pretty trivially done in pure HTML, but maintenance |
|
68 |
would be easier with a server-side portion. list of sprites could be gotten from server, but would require XSS whitelisting */ |
|
69 |
// Last updated: 1.0.0 |
|
70 |
graves=["Badger","Bone","bp2","bubble","Cherry","chest","Clover","coffin", |
|
71 |
"deadhog","dragonball","Duck2","Earth","Egg","eyecross","Flower","Ghost", |
|
72 |
"Grave","heart","money","mouton1","octopus","Old_Apple","pi","plant2", |
|
73 |
"plant3","Plinko","pokeball","pyramid","ring","Rip","Rubberduck","Simple", |
|
74 |
"Simple_reversed","skull","star","Statue","TV","Whisky","Yin_and_Yang"]; |
|
75 |
} |
|
76 |
else |
|
77 |
{ |
|
78 |
graves = []; |
|
79 |
} |
|
80 |
||
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
81 |
let themes = { |
15628 | 82 |
// Last updated: 1.0.0 |
83 |
"Art":1, |
|
84 |
"Beach":1, |
|
85 |
"Bamboo":1, |
|
86 |
"Bath":1, |
|
87 |
//"Blox":0, //unused, has no Sky.png or Border.png |
|
88 |
"Brick":0, |
|
89 |
"Cake":0, |
|
90 |
"Castle":1, |
|
91 |
"Cave":1, |
|
92 |
"City":1, |
|
93 |
"Cheese":0, |
|
94 |
"Christmas":1, |
|
95 |
"Compost":1, |
|
96 |
"CrazyMission":0, |
|
97 |
"Deepspace":0, |
|
98 |
"Desert":1, |
|
99 |
"EarthRise":0, |
|
100 |
"Eyes":0, |
|
101 |
"Freeway":0, |
|
102 |
"Fruit":1, |
|
103 |
"Halloween":1, |
|
104 |
"Hell":0, |
|
105 |
"Hoggywood":1, |
|
106 |
"Island":0, |
|
107 |
"Jungle":1, |
|
108 |
"Golf":1, |
|
109 |
"Nature":1, |
|
110 |
"Olympics":1, |
|
111 |
"Planes":0, |
|
112 |
"Sheep":1, |
|
113 |
"Snow":1, |
|
114 |
"Stage":1, |
|
115 |
"Underwater":1}; |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
116 |
let girder; |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
117 |
let animationInterval; |
15628 | 118 |
|
119 |
on_xml_loaded = function(ex) |
|
120 |
{ |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
121 |
let resp = this.responseText; |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
122 |
let r = />([^<]*).png</g; |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
123 |
let x; |
15628 | 124 |
while(x = r.exec(resp)) |
125 |
{ |
|
126 |
graves.push(x[1]); |
|
127 |
} |
|
128 |
on_graves_loaded(); |
|
129 |
} |
|
130 |
||
131 |
on_xml_error = function() |
|
132 |
{ |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
133 |
let p = document.createElement("p"); |
15628 | 134 |
p.appendChild(document.createTextNode("ERROR: List of graves could not be fetched from the server!")); |
135 |
document.body.appendChild(p); |
|
136 |
} |
|
137 |
||
138 |
window.onload = function() |
|
139 |
{ |
|
140 |
// Load list of graves |
|
141 |
if (!IS_LOCAL) { |
|
142 |
// Request list of graves from repository URL |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
143 |
let xml=new XMLHttpRequest(); |
15628 | 144 |
xml.open("GET", "//hg.hedgewars.org/hedgewars/file/tip/share/hedgewars/Data/Graphics/Graves/"); |
145 |
xml.addEventListener("error", on_xml_error); |
|
146 |
xml.onload = on_xml_loaded; |
|
147 |
xml.send(); |
|
148 |
} |
|
149 |
else |
|
150 |
{ |
|
151 |
on_graves_loaded(); |
|
152 |
} |
|
153 |
} |
|
154 |
||
155 |
on_graves_loaded = function() |
|
156 |
{ |
|
157 |
// Render girders |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
158 |
let s = document.styleSheets[0].cssRules; |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
159 |
for(let i=0;i<s.length;i++) |
15628 | 160 |
{ |
161 |
if (s[i].selectorText.toLowerCase() === ".girder") |
|
162 |
girder = s[i]; |
|
163 |
} |
|
164 |
||
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
165 |
let a = document.createElement("a"); |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
166 |
let g = document.createElement("div"); |
15628 | 167 |
g.className="girder"; |
168 |
a.className="grave"; |
|
169 |
a.appendChild(document.createElement("div")); |
|
170 |
a.lastChild.appendChild(document.createTextNode("")); |
|
171 |
||
172 |
// Render graves |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
173 |
let missingGraves = []; |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
174 |
let img; |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
175 |
let j = 0; |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
176 |
let toDelete = []; |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
177 |
for (let i=0;i<graves.length;i++) |
15628 | 178 |
{ |
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
179 |
let h = document.body.appendChild(a.cloneNode(true)); |
15628 | 180 |
if (IS_LOCAL) |
181 |
h.href = "../share/hedgewars/Data/Graphics/Graves/"+graves[i]+".png"; |
|
182 |
else |
|
183 |
h.href = "//hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Graphics/Graves/"+graves[i]+".png"; |
|
184 |
||
185 |
h.lastChild.style.backgroundImage = 'url("'+h.href+'")'; |
|
186 |
h.title = graves[i]; |
|
187 |
h.idle = Math.floor(Math.random()*16); |
|
188 |
if (j%8 === 7 || i === graves.length-1) |
|
189 |
document.body.appendChild(g.cloneNode(false)); |
|
190 |
j++; |
|
191 |
} |
|
192 |
||
193 |
// Quick and dirty animation |
|
194 |
animationInterval = setInterval(animateGraves, 128); |
|
195 |
||
196 |
// Theme selection drop-down list |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
197 |
let form = document.body.appendChild(document.createElement("form")); |
15628 | 198 |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
199 |
let opt = document.createElement("option"); |
15628 | 200 |
opt.appendChild(document.createTextNode("")); |
201 |
||
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
202 |
let label = document.createElement("label"); |
15628 | 203 |
label.htmlFor = "theme_select"; |
204 |
label.appendChild(document.createTextNode("Theme: ")); |
|
205 |
form.appendChild(label); |
|
206 |
||
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
207 |
let sel = form.appendChild(document.createElement("select")); |
15628 | 208 |
sel.id = "theme_select"; |
209 |
sel.onchange = switchTheme; |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
210 |
for(let theme in themes) |
15628 | 211 |
{ |
212 |
sel.appendChild(opt.cloneNode(true)); |
|
213 |
sel.lastChild.value = theme; |
|
214 |
sel.lastChild.lastChild.data = theme; |
|
215 |
if(theme === "Nature") |
|
216 |
sel.lastChild.selected = true; |
|
217 |
} |
|
218 |
form.appendChild(document.createElement("br")); |
|
219 |
||
220 |
// Checkbox: Switch animation |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
221 |
let chk = document.createElement("input"); |
15628 | 222 |
chk.id = "anim"; |
223 |
chk.type = "checkbox"; |
|
224 |
chk.onclick = switchAnim; |
|
225 |
chk.checked = true; |
|
226 |
form.appendChild(chk); |
|
227 |
label = document.createElement("label"); |
|
228 |
label.htmlFor = "anim"; |
|
16006
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15629
diff
changeset
|
229 |
label.appendChild(document.createTextNode(" Animate graves")); |
15628 | 230 |
form.appendChild(label); |
231 |
||
232 |
form.appendChild(document.createElement("br")); |
|
233 |
||
234 |
// Checkbox: Hide girders |
|
235 |
chk = document.createElement("input"); |
|
236 |
chk.id = "hide_girders"; |
|
237 |
chk.type = "checkbox"; |
|
238 |
chk.onclick = hideGirders; |
|
239 |
chk.checked = true; |
|
240 |
form.appendChild(chk); |
|
241 |
label = document.createElement("label"); |
|
242 |
label.htmlFor = "hide_girders"; |
|
16006
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15629
diff
changeset
|
243 |
label.appendChild(document.createTextNode(" Show girders")); |
15628 | 244 |
form.appendChild(label); |
245 |
||
246 |
document.body.appendChild(form); |
|
247 |
||
16006
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15629
diff
changeset
|
248 |
switchTheme(); |
15628 | 249 |
} |
250 |
||
251 |
function animateGraves() |
|
252 |
{ |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
253 |
let a = document.getElementsByTagName("a"); |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
254 |
for (let i=0;i<a.length;i++) |
15628 | 255 |
{ |
256 |
if (a[i].className !== "grave") |
|
257 |
continue; |
|
258 |
// Cycle thru animation frames |
|
259 |
||
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
260 |
let maskName = a[i].title; |
15628 | 261 |
// Grave |
262 |
a[i].firstChild.style.backgroundPosition=Math.floor(a[i].idle/16)*-32+"px "+(a[i].idle%16)*-32+"px"; |
|
263 |
||
264 |
// Next frame |
|
265 |
a[i].idle++; |
|
266 |
if (a[i].idle > 15) |
|
267 |
a[i].idle = 0; |
|
268 |
} |
|
269 |
} |
|
270 |
||
271 |
// Turn on or off grave animation |
|
272 |
function switchAnim() |
|
273 |
{ |
|
274 |
if (animationInterval) |
|
275 |
{ |
|
276 |
clearInterval(animationInterval); |
|
277 |
animationInterval = null; |
|
278 |
} |
|
279 |
else animationInterval = setInterval(animateGraves, 128); |
|
280 |
} |
|
281 |
||
282 |
// Turn on or off girders |
|
283 |
function hideGirders() |
|
284 |
{ |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
285 |
let g = document.getElementsByClassName("girder"); |
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
286 |
for(let i=0;i<g.length;i++) |
15628 | 287 |
if (this.checked) |
288 |
g[i].className = "girder"; |
|
289 |
else |
|
290 |
g[i].className = "girder hide"; |
|
291 |
||
292 |
} |
|
293 |
||
294 |
// Select theme according to drop-down list value |
|
295 |
function switchTheme() |
|
296 |
{ |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
297 |
let prefix; |
15628 | 298 |
if (!IS_LOCAL) |
299 |
prefix = "//hg.hedgewars.org/hedgewars/raw-file/tip"; |
|
300 |
else |
|
301 |
prefix = ".."; |
|
16007
20adaa127663
Replace 'var' with 'let' in flag/grave/hat XHTML previews
Wuzzy <Wuzzy@disroot.org>
parents:
16006
diff
changeset
|
302 |
let theme = this.value || "Nature"; |
16006
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15629
diff
changeset
|
303 |
document.body.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+theme+'/Sky.png")'; |
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15629
diff
changeset
|
304 |
if (themes[theme]) |
f81fe8250ed9
Clean up flag/grave/hats XHTML preview pages
Wuzzy <Wuzzy@disroot.org>
parents:
15629
diff
changeset
|
305 |
girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Themes/'+theme+'/Girder.png")'; |
15628 | 306 |
else |
307 |
girder.style.backgroundImage='url("'+prefix+'/share/hedgewars/Data/Graphics/Girder.png")'; |
|
308 |
} |
|
309 |
//]]> |
|
310 |
</script> |
|
311 |
</head> |
|
312 |
<body> |
|
313 |
<h1>List of Hedgewars graves</h1> |
|
314 |
<noscript> |
|
315 |
<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/> |
|
316 |
Normally, this webpage would display an animated preview of the graves in Hedgewars.</p> |
|
317 |
</noscript> |
|
318 |
</body> |
|
319 |
</html> |