Compare commits

..

No commits in common. "91ada2809d33e1aa361b47fa3ccecec26a3d9cfe" and "dbcbaff3e159b80743d73408a28742e8c6621b0d" have entirely different histories.

8 changed files with 53 additions and 182 deletions

View File

@ -8,11 +8,9 @@ class Runner
{ {
public int $id; public int $id;
public string $name; public string $name;
public string $club;
public string $course;
public array $splits; public array $splits;
function __construct($id, $name, $club, $course) function __construct($id, $name)
{ {
//echo($id); //echo($id);
//echo($name); //echo($name);
@ -22,8 +20,6 @@ class Runner
} }
$this->id = $id; $this->id = $id;
$this->name = $name; $this->name = $name;
$this->club = $club;
$this->course = $course;
for ($i = 0; $i < $GLOBALS['number_of_controls']; $i++) { for ($i = 0; $i < $GLOBALS['number_of_controls']; $i++) {
$this->splits[$i] = false; $this->splits[$i] = false;
} }
@ -87,7 +83,7 @@ $csv_runners = str_getcsv($csv_runners, "\n");
//print_r($csv_runners); //print_r($csv_runners);
for ($i = 1; $i < count($csv_runners); $i++) { for ($i = 1; $i < count($csv_runners); $i++) {
$line = str_getcsv($csv_runners[$i]); $line = str_getcsv($csv_runners[$i]);
array_push($runners, new Runner($line[0], $line[1], $line[2], $line[3])); array_push($runners, new Runner($line[0], $line[1]));
} }
@ -111,14 +107,8 @@ for ($i = 0; $i < count($timings); $i++) {
$runner->set_split($line[0]-1, $time); $runner->set_split($line[0]-1, $time);
} }
usort($runners, "cmp");
if (!isset($query)){ echo(" <tr>
$query = explode(",",$_SERVER['QUERY_STRING']);
}
if ($query[0] == "registrering"){
$matpost = $query[1];
echo(" <tr>
<th>#</th> <th>#</th>
<th>Startnummer</th> <th>Startnummer</th>
<th>Navn</th> <th>Navn</th>
@ -126,60 +116,7 @@ if ($query[0] == "registrering"){
<th>2. matpost</th> <th>2. matpost</th>
<th>Mål</th> <th>Mål</th>
</tr>"); </tr>");
for ($i = 0; $i < count($runners); $i++) { for ($i = 0; $i < count($runners); $i++) {
$runner = $runners[$i];
$tid_1_mat = "";
if ($runner->splits[0] != false) {
// https://www.php.net/manual/en/class.dateinterval.php
$tid_1_mat = $GLOBALS['start_time']->diff($runner->splits[0])->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');
}
$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) {
// Løperen har vært på denne matposten og vi farger raden grønn
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
$cssclass = "class=\"bg-success\"\"";
}
elseif ($runner->get_control() > $matpost-1) {
// Løperen har vært på denne matposten og vi farger raden grønn
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
$cssclass = "class=\"bg-active\"\"";
}
else {
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
$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");
}
}
elseif ($query[0] == "paameldte") {
echo(" <tr>
<th>Navn</th>
<th>Klubb/Forening</th>
<th>Variant</th>
</tr>");
for ($i = 0; $i < count($runners); $i++) {
$runner = $runners[$i];
echo ("<td>$runner->name</td><td>$runner->club</td><td>$runner->course</td></tr>\n");
}
}
else {
usort($runners, "cmp");
echo(" <tr>
<th>#</th>
<th>Startnummer</th>
<th>Navn</th>
<th>1. matpost</th>
<th>2. matpost</th>
<th>Mål</th>
</tr>");
for ($i = 0; $i < count($runners); $i++) {
$runner = $runners[$i]; $runner = $runners[$i];
$tid_1_mat = ""; $tid_1_mat = "";
if ($runner->splits[0] != false) { if ($runner->splits[0] != false) {
@ -195,5 +132,4 @@ else {
$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"); 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");
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 488 KiB

View File

@ -5,20 +5,10 @@
<title>EKT</title> <title>EKT</title>
<meta name="viewport" content="width=device-width,initial-scale=1" /> <meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" /> <meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
<link rel="stylesheet" href="matcha.css"> <link rel="stylesheet" href="https://matcha.mizu.sh/matcha.css">
<style>
@media (prefers-color-scheme: dark) {
.invert {
filter: invert(1);
}
}
</style>
</head> </head>
<body> <body>
<div class="flex align-center"> <h1>Løpende resultater kadaverløpet 2024</h1>
<figure><img src="img/kadaver.png" alt="" width="100px" class="invert"></figure>
<h1>TESTING Løpende resultater kadaverløpet 2024</h1>
</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> <table>
<tbody> <tbody>
@ -26,11 +16,7 @@
include("get_table.php") include("get_table.php")
?> ?>
</tbody> </tbody>
<footer>
</table> </table>
<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>
</footer>
</body> </body>
<script> <script>
function update() { function update() {

File diff suppressed because one or more lines are too long

View File

@ -1,36 +0,0 @@
<!DOCTYPE html>
<html lang="no">
<head>
<meta charset="UTF-8" />
<title>Påmeldte kadaverløpet</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
<link rel="stylesheet" href="matcha.css">
<style>
@media (prefers-color-scheme: dark) {
.invert {
filter: invert(1);
}
}
</style>
</head>
<body>
<div class="flex align-center">
<figure><img src="img/kadaver.png" alt="" width="100px" class="invert"></figure>
<h1>Påmeldte kadaverløpet 2024</h1>
</div>
<h2>Oppdatert 11.10.24</h2>
<table>
<tbody>
<?php
$query = ["paameldte"];
include("get_table.php");
?>
</tbody>
<footer>
</table>
<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>
</footer>
</body>
</html>

View File

@ -5,7 +5,7 @@
<title>EKT</title> <title>EKT</title>
<meta name="viewport" content="width=device-width,initial-scale=1" /> <meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" /> <meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
<link rel="stylesheet" href="matcha.css"> <link rel="stylesheet" href="https://matcha.mizu.sh/matcha.css">
<style> <style>
.passed { .passed {
background-color: #8ff0a4; background-color: #8ff0a4;
@ -15,32 +15,26 @@
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-evenly; justify-content: space-evenly;
} }
.bg-success {
background: var(--bg-success) !important;
}
.bg-active {
background: var(--bg-active) !important;
}
</style> </style>
</head> </head>
<body> <body>
<fieldset> <fieldset>
<legend>Velg post</legend> <legend>Velg post</legend>
<label> <label>
<input type="radio" name="post" value="1" onclick="update()"> <input type="radio" name="post" value="1">
1. Matpost 1. Matpost
</label> </label>
<label> <label>
<input type="radio" name="post" value="2" onclick="update()"> <input type="radio" name="post" value="2">
2. Matpost 2. Matpost
</label> </label>
<label> <label>
<input type="radio" name="post" value="3" onclick="update()"> <input type="radio" name="post" value="3">
Mål Mål
</label> </label>
</fieldset> </fieldset>
<button onmousedown="update()">Oppdater</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>
@ -58,22 +52,8 @@ print_r($action)
// Hvilken matpost vi er på: // Hvilken matpost vi er på:
var control = location.search[1]; var control = location.search[1];
function get_control() {
try {
return document.querySelector('input[name="post"]:checked').value;
}
catch (error) {
return 0;
}
}
function register_runner(id) { function register_runner(id) {
control = get_control(); control = document.querySelector('input[name="post"]:checked').value;
if (control == 0) {
console.error(error);
alert("Velg en post!");
return 0;
}
let formData = new FormData(); let formData = new FormData();
formData.append(name= 'control', value=control); formData.append(name= 'control', value=control);
formData.append(name= 'id', value=id); formData.append(name= 'id', value=id);
@ -83,9 +63,31 @@ function register_runner(id) {
method: "POST", method: "POST",
body: formData, body: formData,
}); });
update()
//document.getElementById("search").focus()
}; };
function update_runner_status(id, name) {
update_row(id, name, true);
register_runner(id);
}
function read_db() {
let xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "db.csv", false);
xmlHttp.send(null);
return xmlHttp.responseText;
}
function create_row(id, name, passed) {
if (!passed) {
button = `<button onclick="update_runner_status(${id}, '${name}')">✓</button>`
return `<tr id="${id}"><td>${id}</td><td>${name}</td><td>${button}</td></tr>`
}
else {
button = `<button onclick="update_runner_status(${id}, '${name}')">Angre</button>`
return `<tr id="${id}" class="passed"><td>${id}</td><td>${name}</td><td>${button}</td></tr>`
}
}
function create_rows(csv) { function create_rows(csv) {
csv = csv.split('\n') csv = csv.split('\n')
rows = "<tr><th>#</th><th>Navn</th><th></th>"; rows = "<tr><th>#</th><th>Navn</th><th></th>";
@ -118,20 +120,9 @@ function filterTable() {
function update_row(id, name, passed) { function update_row(id, name, passed) {
row = document.getElementById(id) row = document.getElementById(id)
row.innerHTML = create_row(id, name, passed) row.innerHTML = create_row(id, name, passed)
row.classList.add("bg-success"); row.classList.add("passed");
} }
table = document.getElementById("runners")
function update() { table.innerHTML = create_rows(read_db())
const table = document.getElementById("runners");
control = get_control();
const myRequest = new Request(`get_table.php?registrering,`+control);
fetch(myRequest)
.then((response) => response.text())
.then((text) => {
table.innerHTML = text;
});
}
update()
</script> </script>
<html> <html>