This commit is contained in:
William 2022-04-26 21:20:32 +00:00
parent 1b83f16213
commit 6544901bdd
6 changed files with 14 additions and 14 deletions

View File

@ -1,6 +1,6 @@
<div id="alertBox" class="alert danger hidden" role="alert"></div> <div id="alertBox" class="alert danger hidden" role="alert"></div>
<h1>Resultatservice</h1> <h1>Resultater</h1>
<br> <br>
<noscript> <noscript>
@ -14,6 +14,6 @@ Laster inn...
<script src="../static/js/ResultService.js"></script> <script src="../static/js/ResultService.js"></script>
<script> <script>
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
new ResultService(alertBox, rankingTable, '../api/v1/race/sync.php?h='); new ResultService(alertBox, rankingTable, '../api/race/results.php?h=');
}); });
</script> </script>

View File

@ -38,7 +38,7 @@
<h4>Felles</h4> <h4>Felles</h4>
<ul> <ul>
<li><a href="<?=$this->config['root_url']?>index.php">Forside</a></li> <li><a href="<?=$this->config['root_url']?>index.php">Forside</a></li>
<li><a href="<?=$this->config['root_url']?>race/resultservice.php">Resultater</a></li> <li><a href="<?=$this->config['root_url']?>race/results.php">Resultater</a></li>
</ul> </ul>
<?php if ($this->user->logged_in): ?> <?php if ($this->user->logged_in): ?>

View File

@ -1,12 +1,10 @@
<?php $app = require '../../../../app/inc.php'; <?php $app = require '../../../app/inc.php';
/** /**
* We originally wanted to use SSE for this, but the hosting provider * We originally wanted to use SSE for this, but the hosting provider
* did not support that so we resorted to simple polling instead * did not support that so we resorted to simple polling instead
* *
* This page compiles a set of times and sends it if the provided hash of * This page compiles a set of times and sends it if the provided hash of
* the data is not equal. * the data is not equal.
*
* TODO: This code fucking sucks, all of it does
*/ */
use App\Teamtable\TeamMapper; use App\Teamtable\TeamMapper;

5
public/race/results.php Normal file
View File

@ -0,0 +1,5 @@
<?php $app = require '../../app/inc.php';
$app->view('template/header', ["title" => "Resultater"]);
$app->view('pages/race/results');
$app->view('template/footer');

View File

@ -1,5 +0,0 @@
<?php $app = require '../../app/inc.php';
$app->view('template/header', ["title" => "Resultatservice"]);
$app->view('pages/race/resultservice');
$app->view('template/footer');

View File

@ -39,6 +39,7 @@ class ResultService
this.hash = json.hash; this.hash = json.hash;
let data = json.data; let data = json.data;
data.times = data.times.reverse();
let tableHTML = ""; let tableHTML = "";
tableHTML += "<table>"; tableHTML += "<table>";
@ -49,8 +50,9 @@ class ResultService
tableHTML += "</tr>"; tableHTML += "</tr>";
let iterator = 0; let iterator = 0;
data.times.reverse().forEach(element => { data.times.forEach(element => {
iterator++; iterator++;
tableHTML += "<tr>"; tableHTML += "<tr>";
tableHTML += "<td>" + iterator + "</td>"; tableHTML += "<td>" + iterator + "</td>";
tableHTML += "<td>" + data.map.team.name[element.id] + "</td>"; tableHTML += "<td>" + data.map.team.name[element.id] + "</td>";