2022-03-21 11:28:18 +00:00
|
|
|
<h1>Live resultater</h1>
|
2022-03-23 13:03:33 +00:00
|
|
|
<br>
|
2022-04-04 09:09:58 +00:00
|
|
|
|
2022-04-04 16:08:39 +00:00
|
|
|
<noscript>
|
|
|
|
Denne siden krever JavaScript
|
|
|
|
</noscript>
|
2022-04-04 09:09:58 +00:00
|
|
|
|
2022-04-04 16:08:39 +00:00
|
|
|
<div id="ranking-table">
|
|
|
|
Laster inn...
|
2022-04-04 09:09:58 +00:00
|
|
|
</div>
|
2022-03-21 11:28:18 +00:00
|
|
|
|
2022-03-23 09:08:36 +00:00
|
|
|
<script>
|
2022-03-30 12:50:21 +00:00
|
|
|
var hash = 0;
|
|
|
|
|
2022-04-05 13:53:41 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
loop();
|
|
|
|
});
|
|
|
|
|
|
|
|
async function loop()
|
2022-03-30 12:50:21 +00:00
|
|
|
{
|
2022-04-05 13:53:41 +00:00
|
|
|
try {
|
|
|
|
await updateTable();
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
2022-03-30 12:50:21 +00:00
|
|
|
|
2022-04-05 13:53:41 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
loop();
|
|
|
|
}, 1000);
|
2022-03-30 12:50:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function updateTable()
|
2022-03-23 13:03:33 +00:00
|
|
|
{
|
2022-03-30 12:50:21 +00:00
|
|
|
let response = await fetch("sync.php?h=" + hash);
|
2022-03-30 08:51:46 +00:00
|
|
|
|
|
|
|
if (response.status === 204)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-30 12:50:21 +00:00
|
|
|
let json = await response.json();
|
2022-03-30 08:51:46 +00:00
|
|
|
|
|
|
|
hash = json.hash;
|
|
|
|
|
2022-03-30 12:50:21 +00:00
|
|
|
let data = json.data;
|
|
|
|
|
2022-04-04 09:09:58 +00:00
|
|
|
let table_html = "";
|
|
|
|
table_html += "<table>";
|
|
|
|
table_html += "<tr>";
|
|
|
|
table_html += "<th>Navn</th>";
|
|
|
|
table_html += "<th>Bestetid</th>";
|
|
|
|
table_html += "</tr>";
|
|
|
|
|
|
|
|
data.forEach(element => {
|
|
|
|
table_html += "<tr>";
|
|
|
|
table_html += "<td>" + element.name + "</td>";
|
2022-04-05 13:53:41 +00:00
|
|
|
table_html += "<td>" + element.date.date + "</td>";
|
2022-04-04 09:09:58 +00:00
|
|
|
table_html += "</tr>";
|
|
|
|
});
|
|
|
|
|
|
|
|
table_html += "<table>";
|
|
|
|
|
2022-04-04 16:08:39 +00:00
|
|
|
console.log(data);
|
|
|
|
|
2022-04-04 09:09:58 +00:00
|
|
|
document.getElementById("ranking-table").innerHTML = table_html;
|
2022-03-30 08:51:46 +00:00
|
|
|
}
|
2022-03-21 11:28:18 +00:00
|
|
|
</script>
|