Compare commits
No commits in common. "9a0dd90bd622a9ce0665c180688969afc9c2c319" and "91ada2809d33e1aa361b47fa3ccecec26a3d9cfe" have entirely different histories.
9a0dd90bd6
...
91ada2809d
BIN
QTOldGoudy.woff2
BIN
QTOldGoudy.woff2
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -80,10 +80,6 @@ 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");
|
||||
@ -122,122 +118,82 @@ if (!isset($query)){
|
||||
|
||||
if ($query[0] == "registrering"){
|
||||
$matpost = $query[1];
|
||||
echo(" <thead><tr>
|
||||
<th>#</th>
|
||||
<th>Navn</th>
|
||||
<th>Tid</th>
|
||||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>");
|
||||
for ($i = 0; $i < count($runners); $i++) {
|
||||
$runner = $runners[$i];
|
||||
|
||||
// Klokkeslett for denne posten
|
||||
if ($runner->splits[$matpost-1] != false) {
|
||||
$tid_passering = $GLOBALS['start_time']->diff($runner->splits[$matpost-1])->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\"";
|
||||
}
|
||||
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>$runner->id</td><td>$runner->name</td><td>$tid_passering</td><td>$button</td></tr>\n");
|
||||
}
|
||||
echo("</tbody>");
|
||||
}
|
||||
elseif ($query[0] == "paameldte") {
|
||||
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></thead>
|
||||
<tbody>");
|
||||
for ($i = 0; $i < count($runners); $i++) {
|
||||
$runner = $runners[$i];
|
||||
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");
|
||||
usort($runners, "cmp_course");
|
||||
$kadaver_table = "<table><thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Navn</th>
|
||||
<th>1. matpost</th>
|
||||
<th>2. matpost</th>
|
||||
<th>Mål</th>
|
||||
</tr></thead>
|
||||
<tbody>";
|
||||
$minikadaver_table = "<table><thead>
|
||||
<tr>
|
||||
echo(" <tr>
|
||||
<th>#</th>
|
||||
<th>Startnummer</th>
|
||||
<th>Navn</th>
|
||||
<th>1. matpost</th>
|
||||
<th>2. matpost</th>
|
||||
<th>Mål</th>
|
||||
</tr></thead>
|
||||
<tbody>";
|
||||
</tr>");
|
||||
for ($i = 0; $i < count($runners); $i++) {
|
||||
$runner = $runners[$i];
|
||||
|
||||
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_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->course == "Kadaverløpet") {
|
||||
$kadaver_table .= "<tr><td>". $i+1 .".</td><td>$runner->name</td>$matposter<td>$tid_maal</td></tr>\n";
|
||||
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->course == "Minikadaver'n") {
|
||||
$minikadaver_table .= "<tr><td>". $i+1 .".</td><td>$runner->name</td><td>$tid_maal</td></tr>\n";
|
||||
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];
|
||||
$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');
|
||||
}
|
||||
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");
|
||||
}
|
||||
$kadaver_table .= "</tbody></table>";
|
||||
$minikadaver_table .= "</tbody></table>";
|
||||
echo($kadaver_table);
|
||||
echo("<h2>Minikadaver'n</h2>");
|
||||
echo($minikadaver_table);
|
||||
}
|
18
index.php
18
index.php
@ -7,12 +7,6 @@
|
||||
<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);
|
||||
@ -23,20 +17,25 @@
|
||||
<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("table.php")
|
||||
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>
|
||||
<script>
|
||||
function update() {
|
||||
const table = document.querySelector("table");
|
||||
const myRequest = new Request(`table.php`);
|
||||
const myRequest = new Request(`get_table.php`);
|
||||
fetch(myRequest)
|
||||
.then((response) => response.text())
|
||||
.then((text) => {
|
||||
@ -45,5 +44,4 @@ include("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,12 +19,16 @@
|
||||
<figure><img src="img/kadaver.png" alt="" width="100px" class="invert"></figure>
|
||||
<h1>Påmeldte kadaverløpet 2024</h1>
|
||||
</div>
|
||||
<h2>Oppdatert 13.10.24</h2>
|
||||
<h2>Oppdatert 11.10.24</h2>
|
||||
<table>
|
||||
<tbody>
|
||||
<?php
|
||||
$query = ["paameldte"];
|
||||
include("table.php");
|
||||
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>
|
||||
|
17
passing.php
17
passing.php
@ -1,17 +0,0 @@
|
||||
<?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);
|
||||
}
|
115
registrering.php
115
registrering.php
@ -7,29 +7,23 @@
|
||||
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
|
||||
<link rel="stylesheet" href="matcha.css">
|
||||
<style>
|
||||
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;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="settings">
|
||||
<legend>Passord</legend>
|
||||
<input type="password" name="passord" id="password">
|
||||
<fieldset>
|
||||
<legend>Velg post</legend>
|
||||
<label>
|
||||
@ -46,11 +40,20 @@
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<button onmousedown="update()">Oppdater tabell</button>
|
||||
<button onmousedown="update()">Oppdater</button>
|
||||
<input id="search" type="number" class="form-control" onkeyup="filterTable()" placeholder="Søk">
|
||||
<br>
|
||||
</div>
|
||||
<table id="runners"></table>
|
||||
|
||||
<table>
|
||||
<tbody id="runners">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
<?php
|
||||
$action = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
|
||||
print_r($action)
|
||||
?>
|
||||
<script>
|
||||
// Hvilken matpost vi er på:
|
||||
var control = location.search[1];
|
||||
@ -72,61 +75,63 @@ 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);
|
||||
response = fetch("passing.php", {
|
||||
fetch("upload.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(response => {
|
||||
if (response.status == 401) {
|
||||
alert("Feil passord!")
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
update()
|
||||
document.getElementById("search").focus()
|
||||
//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)
|
||||
}
|
||||
return rows
|
||||
}
|
||||
function filterTable() {
|
||||
var input, filter, table, tr, td, i, txtValue;
|
||||
input = document.getElementById("search");
|
||||
filter = input.value;
|
||||
table = document.getElementById("runners").getElementsByTagName("tbody")[0];
|
||||
if (!table) {
|
||||
setTimeout(filterTable, 100);
|
||||
}
|
||||
filter = input.value.toUpperCase();
|
||||
table = document.getElementById("runners");
|
||||
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");
|
||||
txtValue = td[0].textContent;
|
||||
if (txtValue == filter) {
|
||||
tr[i].style.display = "";
|
||||
} else {
|
||||
tr[i].style.display = "none";
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
let request = new Request(`table.php?registrering,`+control);
|
||||
fetch(request)
|
||||
const myRequest = new Request(`get_table.php?registrering,`+control);
|
||||
fetch(myRequest)
|
||||
.then((response) => response.text())
|
||||
.then((text) => {table.innerHTML = text;})
|
||||
filterTable()
|
||||
.then((text) => {
|
||||
table.innerHTML = text;
|
||||
});
|
||||
}
|
||||
|
||||
update()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<html>
|
8
upload.php
Normal file
8
upload.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?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