-
Notifications
You must be signed in to change notification settings - Fork 1
/
entry.js
39 lines (33 loc) · 953 Bytes
/
entry.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
function submit(event, box)
{
var name = document.getElementById("name");
var wintag = document.getElementById("iscorrect");
wintag.style.color = "yellow";
wintag.innerHTML = "LOADING...";
var xhr = new XMLHttpRequest();
xhr.open("GET", "/flags/" + name.innerHTML + "/" + box.value, false);
xhr.send();
if (xhr.responseText == "Yay\n") {
wintag.innerHTML = "WOOT!";
wintag.style.color = "green";
} else if (xhr.responseText == "Keep going\n") {
wintag.innerHTML = "KEEP GOING";
wintag.style.color = "purple";
} else {
wintag.innerHTML = "NOPE";
wintag.style.color = "red";
}
}
function keyup(event, box)
{
if (event.keyCode == 13) {
submit(event, box);
return
}
if (new RegExp("^[-_a-zA-Z0-9]{1,32}$").exec(box.value) == null) {
box.style.borderColor = "red";
return;
}
box.style = null;
document.getElementById("name").innerHTML = document.getElementById("team").value;
}