65 lines
1.2 KiB
PHP
65 lines
1.2 KiB
PHP
<h1>Live resultater</h1>
|
|
<br>
|
|
|
|
<noscript>
|
|
Denne siden krever JavaScript
|
|
</noscript>
|
|
|
|
<div id="ranking-table">
|
|
Laster inn...
|
|
</div>
|
|
|
|
<script>
|
|
var hash = 0;
|
|
|
|
function main()
|
|
{
|
|
setInterval(function() {
|
|
updateTable()
|
|
}, 1000);
|
|
|
|
updateTable();
|
|
}
|
|
|
|
async function updateTable()
|
|
{
|
|
let response = await fetch("sync.php?h=" + hash);
|
|
|
|
if (response.status === 204)
|
|
{
|
|
return;
|
|
}
|
|
|
|
let json = await response.json();
|
|
|
|
hash = json.hash;
|
|
|
|
let data = json.data;
|
|
|
|
let table_html = "";
|
|
table_html += "<table>";
|
|
table_html += "<tr>";
|
|
table_html += "<th>Navn</th>";
|
|
table_html += "<th>Runder</th>";
|
|
table_html += "<th>Bestetid</th>";
|
|
table_html += "</tr>";
|
|
|
|
data.forEach(element => {
|
|
table_html += "<tr>";
|
|
table_html += "<td>" + element.name + "</td>";
|
|
table_html += "<td>" + element.rounds + "</td>";
|
|
table_html += "<td>" + element.date + "</td>";
|
|
table_html += "</tr>";
|
|
});
|
|
|
|
table_html += "<table>";
|
|
|
|
console.log(data);
|
|
|
|
document.getElementById("ranking-table").innerHTML = table_html;
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
main();
|
|
});
|
|
</script> |