This repository has been archived on 2023-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
web/app/view/pages/race/live-results.php

59 lines
1.1 KiB
PHP
Raw Normal View History

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
<div id="ranking-table">
</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;
function main()
{
setInterval(function() {
updateTable()
}, 1000);
updateTable();
}
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>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.bestTime + "</td>";
table_html += "</tr>";
});
table_html += "<table>";
document.getElementById("ranking-table").innerHTML = table_html;
2022-03-30 08:51:46 +00:00
}
2022-03-30 12:50:21 +00:00
document.addEventListener('DOMContentLoaded', function() {
main();
});
2022-03-21 11:28:18 +00:00
</script>