forked from ketile/ketile.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tdk_board.html
68 lines (62 loc) · 2.06 KB
/
tdk_board.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<head>
<style>
td, th {
text-align: left;
}
</style>
</head>
<h2>TDK Leaderboard</h2>
<div id="demo">
Loading data, please wait...
</div>
<script>
function readBody(xhr) {
var data;
if (!xhr.responseType || xhr.responseType === "text") {
data = xhr.responseText;
} else if (xhr.responseType === "document") {
data = xhr.responseXML;
} else {
data = xhr.response;
}
return data;
}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == XMLHttpRequest.DONE) {
var respLines= this.responseText.split('\n');
var text = "<table>";
var get_score = false;
for (i = 0; i < respLines.length; i++)
{
if (respLines[i].includes("Track:"))
{
text += "<tr><td></td><td><b>" + respLines[i].split("</B> ")[1].split("<BR>")[0] + "</b></td></tr>"
}
else if (respLines[i].includes("250 Racer Advanced"))
{
get_score = true;
}
else if (respLines[i].includes("250 Racer Custom") || respLines[i].includes("250 Racer Trainer"))
{
get_score = false;
}
else if (respLines[i].includes("[TDK]") && get_score)
{
var position = "<td>" + respLines[i-2].split("<p>")[1].split("</p>")[0] + "</td>"
var name = "<td>" + respLines[i].split("</img>")[1].split("</p>")[0] + "</td>"
var time = "<td>" + respLines[i+4].split("<p>")[1].split("</p>")[0] + "</td>"
var gap = "<td>" + respLines[i+6].split("<p>")[1].split("</p>")[0] + "</td>"
var missed = "<td>" + respLines[i+8].split("<p>")[1].split("</p>")[0] + "</td>"
text += "<tr>" + position + name + time + gap + missed + "</tr>"
}
}
text += "</table>"
document.getElementById("demo").innerHTML = text;
//console.log(text);
}
};
xhttp.open("GET", 'https://cors-anywhere.herokuapp.com/http://dronesimulation.co.uk/events/evlbs.pl', true);
xhttp.send(null);
</script>