Compare commits

..

7 Commits

Author SHA1 Message Date
Trygve
9a0dd90bd6 Skilte Kadavern og mini 2024-11-01 11:54:45 +01:00
Trygve
be878ac77e fjerna død kode 2024-11-01 11:54:27 +01:00
Trygve
004474c2e1 css hack 2024-11-01 11:53:49 +01:00
Trygve
3ec19dd4cb Endra navn på api 2024-10-27 18:34:42 +01:00
Trygve
35df188cf6 asdf 2024-10-27 18:15:45 +01:00
Trygve
78c6f0e2dd La til totalt antall påmeldte 2024-10-13 23:08:38 +02:00
Trygve
b2afadedf1 La til kul font 2024-10-13 23:07:56 +02:00
10 changed files with 174 additions and 119 deletions

BIN
QTOldGoudy.woff2 Normal file

Binary file not shown.

BIN
fonts/QTOldGoudy-Bold.otf Normal file

Binary file not shown.

BIN
fonts/QTOldGoudy.otf Normal file

Binary file not shown.

View File

@ -7,6 +7,12 @@
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" /> <meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
<link rel="stylesheet" href="matcha.css"> <link rel="stylesheet" href="matcha.css">
<style> <style>
@media only screen and (max-width: 650px) {
body {
padding-left: 0;
padding-right: 0;
}
}
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
.invert { .invert {
filter: invert(1); filter: invert(1);
@ -17,25 +23,20 @@
<body> <body>
<div class="flex align-center"> <div class="flex align-center">
<figure><img src="img/kadaver.png" alt="" width="100px" class="invert"></figure> <figure><img src="img/kadaver.png" alt="" width="100px" class="invert"></figure>
<h1>TESTING Løpende resultater kadaverløpet 2024</h1> <h1>TESTING Løpende resultater Kadaverløpet 2024</h1>
</div> </div>
<h2>Vi tar forbehold om feil. Dette er ikke offisielle resultater</h2> <h2>Vi tar forbehold om feil. Dette er ikke offisielle resultater</h2>
<table>
<tbody>
<?php <?php
include("get_table.php") include("table.php")
?> ?>
</tbody>
<footer> <footer>
</table>
<h3>Laget av Trygve. <a href="https://git.willy.club/Trygve/elektronisk-kadaver-tidtakingssystem">Kildekode</a></h3> <h3>Laget av Trygve. <a href="https://git.willy.club/Trygve/elektronisk-kadaver-tidtakingssystem">Kildekode</a></h3>
<figure><img src="img/NMBUI.webp" alt="" width="200px"></figure> <figure><img src="img/NMBUI.webp" alt="" width="200px"></figure>
</footer> </footer>
</body>
<script> <script>
function update() { function update() {
const table = document.querySelector("table"); const table = document.querySelector("table");
const myRequest = new Request(`get_table.php`); const myRequest = new Request(`table.php`);
fetch(myRequest) fetch(myRequest)
.then((response) => response.text()) .then((response) => response.text())
.then((text) => { .then((text) => {
@ -44,4 +45,5 @@ include("get_table.php")
} }
setInterval(update, 5*1000) setInterval(update, 5*1000)
</script> </script>
</body>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@ -19,16 +19,12 @@
<figure><img src="img/kadaver.png" alt="" width="100px" class="invert"></figure> <figure><img src="img/kadaver.png" alt="" width="100px" class="invert"></figure>
<h1>Påmeldte kadaverløpet 2024</h1> <h1>Påmeldte kadaverløpet 2024</h1>
</div> </div>
<h2>Oppdatert 11.10.24</h2> <h2>Oppdatert 13.10.24</h2>
<table>
<tbody>
<?php <?php
$query = ["paameldte"]; $query = ["paameldte"];
include("get_table.php"); include("table.php");
?> ?>
</tbody>
<footer> <footer>
</table>
<h3>Laget av Trygve. <a href="https://git.willy.club/Trygve/elektronisk-kadaver-tidtakingssystem">Kildekode</a></h3> <h3>Laget av Trygve. <a href="https://git.willy.club/Trygve/elektronisk-kadaver-tidtakingssystem">Kildekode</a></h3>
<figure><img src="img/NMBUI.webp" alt="" width="200px"></figure> <figure><img src="img/NMBUI.webp" alt="" width="200px"></figure>
</footer> </footer>

17
passing.php Normal file
View File

@ -0,0 +1,17 @@
<?php
$control = $_POST['control'];
$runner_id = $_POST['id'];
$time = $_POST['time'];
$password = $_POST['password'];
$hash = file_get_contents("hash.txt");
if (!password_verify($password, $hash)) {
http_response_code(response_code: 401);
}
else {
$file = 'passering.csv';
$current = file_get_contents($file);
$current .= $control . "," . $runner_id . "," . $time . "\n";
file_put_contents($file, $current);
}

View File

@ -7,23 +7,29 @@
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" /> <meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
<link rel="stylesheet" href="matcha.css"> <link rel="stylesheet" href="matcha.css">
<style> <style>
.passed { body {
background-color: #8ff0a4; padding: 0;
} }
fieldset { .settings {
display: flex; padding: 0 1.5rem;
flex-wrap: wrap; }
justify-content: space-evenly; fieldset {
} display: flex;
.bg-success { flex-wrap: wrap;
background: var(--bg-success) !important; justify-content: space-evenly;
} }
.bg-active { .bg-success {
background: var(--bg-active) !important; background: var(--bg-success) !important;
} }
.bg-active {
background: var(--bg-active) !important;
}
</style> </style>
</head> </head>
<body> <body>
<div class="settings">
<legend>Passord</legend>
<input type="password" name="passord" id="password">
<fieldset> <fieldset>
<legend>Velg post</legend> <legend>Velg post</legend>
<label> <label>
@ -40,20 +46,11 @@
</label> </label>
</fieldset> </fieldset>
<button onmousedown="update()">Oppdater</button> <button onmousedown="update()">Oppdater tabell</button>
<input id="search" type="number" class="form-control" onkeyup="filterTable()" placeholder="Søk"> <input id="search" type="number" class="form-control" onkeyup="filterTable()" placeholder="Søk">
<br> <br>
</div>
<table> <table id="runners"></table>
<tbody id="runners">
</tbody>
</table>
</body>
<?php
$action = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
print_r($action)
?>
<script> <script>
// Hvilken matpost vi er på: // Hvilken matpost vi er på:
var control = location.search[1]; var control = location.search[1];
@ -75,63 +72,61 @@ function register_runner(id) {
return 0; return 0;
} }
let formData = new FormData(); let formData = new FormData();
formData.append(name= 'password', value=document.getElementById('password').value)
formData.append(name= 'control', value=control); formData.append(name= 'control', value=control);
formData.append(name= 'id', value=id); formData.append(name= 'id', value=id);
time = new Date(Date.now()).toISOString().split('.')[0]+"Z" time = new Date(Date.now()).toISOString().split('.')[0]+"Z"
formData.append('time', time); formData.append('time', time);
fetch("upload.php", { response = fetch("passing.php", {
method: "POST", method: "POST",
body: formData, body: formData,
}); })
update() .then(response => {
//document.getElementById("search").focus() if (response.status == 401) {
}; alert("Feil passord!")
function create_rows(csv) {
csv = csv.split('\n')
rows = "<tr><th>#</th><th>Navn</th><th></th>";
for (i in csv) {
data = csv[i].split(",")
rows += create_row(data[0], data[1], false)
} }
return rows })
}
update()
document.getElementById("search").focus()
};
function filterTable() { function filterTable() {
var input, filter, table, tr, td, i, txtValue; var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("search"); input = document.getElementById("search");
filter = input.value.toUpperCase(); filter = input.value;
table = document.getElementById("runners"); table = document.getElementById("runners").getElementsByTagName("tbody")[0];
if (!table) {
setTimeout(filterTable, 100);
}
tr = table.getElementsByTagName("tr"); tr = table.getElementsByTagName("tr");
if (filter == "") {
for (i = 0; i < tr.length; i++) {
tr[i].style.display = "";
}
}
else {
for (i = 0; i < tr.length; i++) { for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td"); td = tr[i].getElementsByTagName("td");
for (var j = 0; j < td.length; j++) { txtValue = td[0].textContent;
txtValue = td[j].textContent || td[j].innerText; if (txtValue == filter) {
if (txtValue.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = "";
tr[i].style.display = ""; } else {
break; tr[i].style.display = "none";
} else {
tr[i].style.display = "none";
}
} }
} }
} }
function update_row(id, name, passed) {
row = document.getElementById(id)
row.innerHTML = create_row(id, name, passed)
row.classList.add("bg-success");
} }
function update() { function update() {
const table = document.getElementById("runners"); const table = document.getElementById("runners");
control = get_control(); control = get_control();
const myRequest = new Request(`get_table.php?registrering,`+control); let request = new Request(`table.php?registrering,`+control);
fetch(myRequest) fetch(request)
.then((response) => response.text()) .then((response) => response.text())
.then((text) => { .then((text) => {table.innerHTML = text;})
table.innerHTML = text; filterTable()
});
} }
update()
</script> </script>
<html> </body>
</html>

View File

@ -80,6 +80,10 @@ function cmp(Runner $a, Runner $b) {
} }
return 0; return 0;
} }
function cmp_course(Runner $a, Runner $b) {
return strcmp($a->course, $b->course);
}
$runners = []; $runners = [];
$csv_runners = file_get_contents("db.csv"); $csv_runners = file_get_contents("db.csv");
@ -118,82 +122,122 @@ if (!isset($query)){
if ($query[0] == "registrering"){ if ($query[0] == "registrering"){
$matpost = $query[1]; $matpost = $query[1];
echo(" <tr> echo(" <thead><tr>
<th>#</th> <th>#</th>
<th>Startnummer</th>
<th>Navn</th> <th>Navn</th>
<th>1. matpost</th> <th>Tid</th>
<th>2. matpost</th> <th></th>
<th>Mål</th> </tr></thead>
</tr>"); <tbody>");
for ($i = 0; $i < count($runners); $i++) { for ($i = 0; $i < count($runners); $i++) {
$runner = $runners[$i]; $runner = $runners[$i];
$tid_1_mat = "";
if ($runner->splits[0] != false) { // Klokkeslett for denne posten
// https://www.php.net/manual/en/class.dateinterval.php if ($runner->splits[$matpost-1] != false) {
$tid_1_mat = $GLOBALS['start_time']->diff($runner->splits[0])->format('%H:%I:%S'); $tid_passering = $GLOBALS['start_time']->diff($runner->splits[$matpost-1])->format('%H:%I:%S');
} }
$tid_2_mat = ""; else {
if ($runner->splits[1] != false) { $tid_passering = "";
$tid_2_mat = $GLOBALS['start_time']->diff($runner->splits[1])->format('%H:%I:%S');
}
$tid_maal = "";
if ($runner->splits[2] != false) {
$tid_maal = $GLOBALS['start_time']->diff($runner->splits[2])->format('%H:%I:%S');
} }
if ($runner->get_control() == $matpost-1) { if ($runner->get_control() == $matpost-1) {
// Løperen har vært på denne matposten og vi farger raden grønn // Løperen har vært på denne matposten og vi farger raden grønn
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>"; $button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
$cssclass = "class=\"bg-success\"\""; $cssclass = "class=\"bg-success\"";
} }
elseif ($runner->get_control() > $matpost-1) { elseif ($runner->get_control() > $matpost-1) {
// Løperen har vært på denne matposten og vi farger raden grønn // Løperen har vært på denne matposten og vi farger raden grønn
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>"; $button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
$cssclass = "class=\"bg-active\"\""; $cssclass = "class=\"bg-active\"";
} }
else { else {
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>"; $button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
$cssclass = ""; $cssclass = "";
} }
echo ("<tr $cssclass><td>". $i+1 .".</td><td>$runner->id</td><td>$runner->name</td><td>$tid_1_mat</td><td>$tid_2_mat</td><td>$tid_maal</td><td>$button</td></tr>\n"); echo ("<tr $cssclass><td>$runner->id</td><td>$runner->name</td><td>$tid_passering</td><td>$button</td></tr>\n");
} }
echo("</tbody>");
} }
elseif ($query[0] == "paameldte") { elseif ($query[0] == "paameldte") {
echo(" <tr> usort($runners, "cmp_course");
$kadaverløpere = 0;
$minikadaverløpere = 0;
for ($i = 0; $i < count($runners); $i++) {
if ($runners[$i]->course == "Kadaverløpet") {
$kadaverløpere++;
}
elseif ($runners[$i]->course == "Minikadaver'n") {
$minikadaverløpere++;
}
}
echo("<div class=\"flex space-evenly\">
<div class=\"flash accent\">$kadaverløpere påmeldt Kadaverløpet</div><div class=\"flash accent\">$minikadaverløpere påmeldte i Minikadaver'n</div>
</div>");
echo("<table><thead>
<tr>
<th>S.nr</th>
<th>Navn</th> <th>Navn</th>
<th>Klubb/Forening</th> <th>Klubb/Forening</th>
<th>Variant</th> <th>Variant</th>
</tr>"); </tr></thead>
<tbody>");
for ($i = 0; $i < count($runners); $i++) { for ($i = 0; $i < count($runners); $i++) {
$runner = $runners[$i]; $runner = $runners[$i];
echo ("<td>$runner->name</td><td>$runner->club</td><td>$runner->course</td></tr>\n"); echo ("<tr><td>$runner->id</td><td>$runner->name</td><td>$runner->club</td><td>$runner->course</td></tr>\n");
} }
echo("<table><tbody>");
} }
else { else {
usort($runners, "cmp"); usort($runners, "cmp");
echo(" <tr> usort($runners, "cmp_course");
$kadaver_table = "<table><thead>
<tr>
<th>#</th> <th>#</th>
<th>Startnummer</th>
<th>Navn</th> <th>Navn</th>
<th>1. matpost</th> <th>1. matpost</th>
<th>2. matpost</th> <th>2. matpost</th>
<th>Mål</th> <th>Mål</th>
</tr>"); </tr></thead>
<tbody>";
$minikadaver_table = "<table><thead>
<tr>
<th>#</th>
<th>Navn</th>
<th>Mål</th>
</tr></thead>
<tbody>";
for ($i = 0; $i < count($runners); $i++) { for ($i = 0; $i < count($runners); $i++) {
$runner = $runners[$i]; $runner = $runners[$i];
$tid_1_mat = "";
if ($runner->splits[0] != false) { if ($runner->course == "Kadaverløpet") {
// https://www.php.net/manual/en/class.dateinterval.php $tid_1_mat = "";
$tid_1_mat = $GLOBALS['start_time']->diff($runner->splits[0])->format('%H:%I:%S'); if ($runner->splits[0] != false) {
} // https://www.php.net/manual/en/class.dateinterval.php
$tid_2_mat = ""; $tid_1_mat = $GLOBALS['start_time']->diff($runner->splits[0])->format('%H:%I:%S');
if ($runner->splits[1] != false) { }
$tid_2_mat = $GLOBALS['start_time']->diff($runner->splits[1])->format('%H:%I:%S'); $tid_2_mat = "";
if ($runner->splits[1] != false) {
$tid_2_mat = $GLOBALS['start_time']->diff($runner->splits[1])->format('%H:%I:%S');
}
$matposter = "<td>$tid_1_mat</td><td>$tid_2_mat</td>";
} }
$tid_maal = ""; $tid_maal = "";
if ($runner->splits[2] != false) { if ($runner->splits[2] != false) {
$tid_maal = $GLOBALS['start_time']->diff($runner->splits[2])->format('%H:%I:%S'); $tid_maal = $GLOBALS['start_time']->diff($runner->splits[2])->format('%H:%I:%S');
} }
echo ("<tr><td>". $i+1 .".</td><td>$runner->id</td><td>$runner->name</td><td>$tid_1_mat</td><td>$tid_2_mat</td><td>$tid_maal</td></tr>\n"); if ($runner->course == "Kadaverløpet") {
$kadaver_table .= "<tr><td>". $i+1 .".</td><td>$runner->name</td>$matposter<td>$tid_maal</td></tr>\n";
}
elseif ($runner->course == "Minikadaver'n") {
$minikadaver_table .= "<tr><td>". $i+1 .".</td><td>$runner->name</td><td>$tid_maal</td></tr>\n";
}
} }
$kadaver_table .= "</tbody></table>";
$minikadaver_table .= "</tbody></table>";
echo($kadaver_table);
echo("<h2>Minikadaver'n</h2>");
echo($minikadaver_table);
} }

View File

@ -1,8 +0,0 @@
<?php
$control = $_POST['control'];
$runner_id = $_POST['id'];
$time = $_POST['time'];
$file = 'passering.csv';
$current = file_get_contents($file);
$current .= $control . "," . $runner_id . "," . $time . "\n";
file_put_contents($file, $current);