Compare commits
7 Commits
91ada2809d
...
9a0dd90bd6
Author | SHA1 | Date | |
---|---|---|---|
|
9a0dd90bd6 | ||
|
be878ac77e | ||
|
004474c2e1 | ||
|
3ec19dd4cb | ||
|
35df188cf6 | ||
|
78c6f0e2dd | ||
|
b2afadedf1 |
BIN
QTOldGoudy.woff2
Normal file
BIN
QTOldGoudy.woff2
Normal file
Binary file not shown.
BIN
fonts/QTOldGoudy-Bold.otf
Normal file
BIN
fonts/QTOldGoudy-Bold.otf
Normal file
Binary file not shown.
BIN
fonts/QTOldGoudy.otf
Normal file
BIN
fonts/QTOldGoudy.otf
Normal file
Binary file not shown.
18
index.php
18
index.php
@ -7,6 +7,12 @@
|
||||
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
|
||||
<link rel="stylesheet" href="matcha.css">
|
||||
<style>
|
||||
@media only screen and (max-width: 650px) {
|
||||
body {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.invert {
|
||||
filter: invert(1);
|
||||
@ -17,25 +23,20 @@
|
||||
<body>
|
||||
<div class="flex align-center">
|
||||
<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>
|
||||
<h2>Vi tar forbehold om feil. Dette er ikke offisielle resultater</h2>
|
||||
<table>
|
||||
<tbody>
|
||||
<?php
|
||||
include("get_table.php")
|
||||
include("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>
|
||||
<script>
|
||||
function update() {
|
||||
const table = document.querySelector("table");
|
||||
const myRequest = new Request(`get_table.php`);
|
||||
const myRequest = new Request(`table.php`);
|
||||
fetch(myRequest)
|
||||
.then((response) => response.text())
|
||||
.then((text) => {
|
||||
@ -44,4 +45,5 @@ include("get_table.php")
|
||||
}
|
||||
setInterval(update, 5*1000)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
11
matcha.css
11
matcha.css
File diff suppressed because one or more lines are too long
@ -19,16 +19,12 @@
|
||||
<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>
|
||||
<h2>Oppdatert 13.10.24</h2>
|
||||
<?php
|
||||
$query = ["paameldte"];
|
||||
include("get_table.php");
|
||||
include("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>
|
||||
|
17
passing.php
Normal file
17
passing.php
Normal 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);
|
||||
}
|
117
registrering.php
117
registrering.php
@ -7,23 +7,29 @@
|
||||
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
|
||||
<link rel="stylesheet" href="matcha.css">
|
||||
<style>
|
||||
.passed {
|
||||
background-color: #8ff0a4;
|
||||
}
|
||||
fieldset {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
.bg-success {
|
||||
background: var(--bg-success) !important;
|
||||
}
|
||||
.bg-active {
|
||||
background: var(--bg-active) !important;
|
||||
}
|
||||
body {
|
||||
padding: 0;
|
||||
}
|
||||
.settings {
|
||||
padding: 0 1.5rem;
|
||||
}
|
||||
fieldset {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
.bg-success {
|
||||
background: var(--bg-success) !important;
|
||||
}
|
||||
.bg-active {
|
||||
background: var(--bg-active) !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="settings">
|
||||
<legend>Passord</legend>
|
||||
<input type="password" name="passord" id="password">
|
||||
<fieldset>
|
||||
<legend>Velg post</legend>
|
||||
<label>
|
||||
@ -40,20 +46,11 @@
|
||||
</label>
|
||||
</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">
|
||||
<br>
|
||||
|
||||
<table>
|
||||
<tbody id="runners">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
<?php
|
||||
$action = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
|
||||
print_r($action)
|
||||
?>
|
||||
</div>
|
||||
<table id="runners"></table>
|
||||
<script>
|
||||
// Hvilken matpost vi er på:
|
||||
var control = location.search[1];
|
||||
@ -75,63 +72,61 @@ function register_runner(id) {
|
||||
return 0;
|
||||
}
|
||||
let formData = new FormData();
|
||||
formData.append(name= 'password', value=document.getElementById('password').value)
|
||||
formData.append(name= 'control', value=control);
|
||||
formData.append(name= 'id', value=id);
|
||||
time = new Date(Date.now()).toISOString().split('.')[0]+"Z"
|
||||
formData.append('time', time);
|
||||
fetch("upload.php", {
|
||||
response = fetch("passing.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
update()
|
||||
//document.getElementById("search").focus()
|
||||
};
|
||||
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)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.status == 401) {
|
||||
alert("Feil passord!")
|
||||
}
|
||||
return rows
|
||||
}
|
||||
})
|
||||
|
||||
update()
|
||||
document.getElementById("search").focus()
|
||||
};
|
||||
function filterTable() {
|
||||
var input, filter, table, tr, td, i, txtValue;
|
||||
input = document.getElementById("search");
|
||||
filter = input.value.toUpperCase();
|
||||
table = document.getElementById("runners");
|
||||
filter = input.value;
|
||||
table = document.getElementById("runners").getElementsByTagName("tbody")[0];
|
||||
if (!table) {
|
||||
setTimeout(filterTable, 100);
|
||||
}
|
||||
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++) {
|
||||
td = tr[i].getElementsByTagName("td");
|
||||
for (var j = 0; j < td.length; j++) {
|
||||
txtValue = td[j].textContent || td[j].innerText;
|
||||
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
||||
tr[i].style.display = "";
|
||||
break;
|
||||
} else {
|
||||
tr[i].style.display = "none";
|
||||
}
|
||||
txtValue = td[0].textContent;
|
||||
if (txtValue == filter) {
|
||||
tr[i].style.display = "";
|
||||
} 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() {
|
||||
const table = document.getElementById("runners");
|
||||
control = get_control();
|
||||
const myRequest = new Request(`get_table.php?registrering,`+control);
|
||||
fetch(myRequest)
|
||||
let request = new Request(`table.php?registrering,`+control);
|
||||
fetch(request)
|
||||
.then((response) => response.text())
|
||||
.then((text) => {
|
||||
table.innerHTML = text;
|
||||
});
|
||||
.then((text) => {table.innerHTML = text;})
|
||||
filterTable()
|
||||
}
|
||||
|
||||
update()
|
||||
</script>
|
||||
<html>
|
||||
</body>
|
||||
</html>
|
@ -80,6 +80,10 @@ function cmp(Runner $a, Runner $b) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function cmp_course(Runner $a, Runner $b) {
|
||||
return strcmp($a->course, $b->course);
|
||||
}
|
||||
|
||||
|
||||
$runners = [];
|
||||
$csv_runners = file_get_contents("db.csv");
|
||||
@ -118,82 +122,122 @@ if (!isset($query)){
|
||||
|
||||
if ($query[0] == "registrering"){
|
||||
$matpost = $query[1];
|
||||
echo(" <tr>
|
||||
echo(" <thead><tr>
|
||||
<th>#</th>
|
||||
<th>Startnummer</th>
|
||||
<th>Navn</th>
|
||||
<th>1. matpost</th>
|
||||
<th>2. matpost</th>
|
||||
<th>Mål</th>
|
||||
</tr>");
|
||||
<th>Tid</th>
|
||||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>");
|
||||
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');
|
||||
|
||||
// Klokkeslett for denne posten
|
||||
if ($runner->splits[$matpost-1] != false) {
|
||||
$tid_passering = $GLOBALS['start_time']->diff($runner->splits[$matpost-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');
|
||||
}
|
||||
$tid_maal = "";
|
||||
if ($runner->splits[2] != false) {
|
||||
$tid_maal = $GLOBALS['start_time']->diff($runner->splits[2])->format('%H:%I:%S');
|
||||
else {
|
||||
$tid_passering = "";
|
||||
}
|
||||
|
||||
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\"\"";
|
||||
$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\"\"";
|
||||
$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");
|
||||
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") {
|
||||
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>Klubb/Forening</th>
|
||||
<th>Variant</th>
|
||||
</tr>");
|
||||
</tr></thead>
|
||||
<tbody>");
|
||||
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");
|
||||
echo ("<tr><td>$runner->id</td><td>$runner->name</td><td>$runner->club</td><td>$runner->course</td></tr>\n");
|
||||
}
|
||||
echo("<table><tbody>");
|
||||
}
|
||||
else {
|
||||
usort($runners, "cmp");
|
||||
echo(" <tr>
|
||||
usort($runners, "cmp_course");
|
||||
$kadaver_table = "<table><thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Startnummer</th>
|
||||
<th>Navn</th>
|
||||
<th>1. matpost</th>
|
||||
<th>2. matpost</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++) {
|
||||
$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');
|
||||
|
||||
if ($runner->course == "Kadaverløpet") {
|
||||
$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');
|
||||
}
|
||||
$matposter = "<td>$tid_1_mat</td><td>$tid_2_mat</td>";
|
||||
}
|
||||
$tid_maal = "";
|
||||
if ($runner->splits[2] != false) {
|
||||
$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);
|
||||
}
|
@ -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);
|
Loading…
Reference in New Issue
Block a user