-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_all_challenges.js
45 lines (41 loc) · 1.01 KB
/
admin_all_challenges.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function fetchHints()
{
var fetcher = new XMLHttpRequest();
fetcher.addEventListener( "load", parseHints );
fetcher.open( "GET", "api/all_hints.py" );
fetcher.send();
}
function parseHints()
{
if(this.status != 200)
{
throw this;
}
killAllChildren(document.getElementById("hintlist"));
var hints = JSON.parse(this.responseText);
for(var hintid in hints)
{
var hint = hints[ hintid ];
var hintdom = document.createElement("li");
if( hint.url )
{
var anchor = document.createElement("a");
anchor.href = hint.url;
anchor.appendChild( document.createTextNode( hint.description ) );
hintdom.appendChild( anchor );
} else {
hintdom.appendChild( document.createTextNode( hint.description ) );
}
hintdom.appendChild( document.createTextNode( " - " ) );
hintdom.appendChild( document.createTextNode( hint.publish ) );
document.getElementById("hintlist").appendChild(hintdom);
}
}
function killAllChildren(dom)
{
while(dom.firstChild)
{
dom.removeChild(dom.firstChild);
}
}
fetchHints();