Commit
This commit is contained in:
parent
a1d1123894
commit
b0e23a9d61
@ -1,11 +1,9 @@
|
||||
<h1>Live resultater</h1>
|
||||
<br>
|
||||
<table id ="table">
|
||||
<tr>
|
||||
<th>Some shit</th>
|
||||
<th>Some shit</th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="ranking-table">
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var hash = 0;
|
||||
@ -34,6 +32,25 @@ async function updateTable()
|
||||
|
||||
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.bestTime + "</td>";
|
||||
table_html += "</tr>";
|
||||
});
|
||||
|
||||
table_html += "<table>";
|
||||
|
||||
document.getElementById("ranking-table").innerHTML = table_html;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
@ -7,20 +7,39 @@
|
||||
use App\Teamtable\TeamMapper;
|
||||
use App\Timetable\TimeMapper;
|
||||
|
||||
$teamMapper = new TimeMapper($app->database->conn);
|
||||
$teamMapper = new TeamMapper($app->database->conn);
|
||||
$timeMapper = new TimeMapper($app->database->conn);
|
||||
|
||||
$prev_hash = (int)filter_input(INPUT_GET, 'h');
|
||||
|
||||
$data = [];
|
||||
$times = $timeMapper->getAll();
|
||||
|
||||
$hash = crc32(serialize($timeMapper->getAll()));
|
||||
foreach ($times as $time)
|
||||
{
|
||||
$team = $teamMapper->get($time->teamId);
|
||||
|
||||
if (!$team)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$row = [
|
||||
"name" => $team->name,
|
||||
"rounds" => $team->rounds,
|
||||
"bestTime" => $team->bestTime
|
||||
];
|
||||
|
||||
array_push($data, $row);
|
||||
}
|
||||
|
||||
$hash = crc32(serialize($data));
|
||||
|
||||
if ($prev_hash !== $hash)
|
||||
{
|
||||
$app->api([
|
||||
"hash" => $hash,
|
||||
"data" => $times
|
||||
"data" => $data
|
||||
]);
|
||||
}
|
||||
// return nothing
|
||||
|
Reference in New Issue
Block a user