lagde matpost nedtelling
This commit is contained in:
parent
568c00ddd6
commit
f2ede38dca
@ -33,6 +33,12 @@
|
|||||||
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
||||||
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
||||||
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
||||||
|
<li class="selected">⏳️ Nedtelling matpost
|
||||||
|
<menu>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=0">1. mat</a></li>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=1">2. mat</a></li>
|
||||||
|
</menu>
|
||||||
|
</li>
|
||||||
</menu>
|
</menu>
|
||||||
</nav>
|
</nav>
|
||||||
<button class="danger" onclick="log_out()">Logg ut</button>
|
<button class="danger" onclick="log_out()">Logg ut</button>
|
||||||
|
|||||||
50
api/countdown.php
Normal file
50
api/countdown.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
$documentRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||||
|
include("$documentRoot/import_runners.php");
|
||||||
|
|
||||||
|
function format($seconds) {
|
||||||
|
// Ensure it's an integer and non-negative
|
||||||
|
$seconds = max(0, (int)$seconds);
|
||||||
|
|
||||||
|
$minutes = floor($seconds / 60);
|
||||||
|
$remainingSeconds = $seconds % 60;
|
||||||
|
|
||||||
|
// Format with leading zeros (e.g., 02:05)
|
||||||
|
return sprintf('%02d:%02d', $minutes, $remainingSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
$method = $_SERVER['REQUEST_METHOD'];
|
||||||
|
|
||||||
|
$time_limit = 240;
|
||||||
|
|
||||||
|
if ($method == "GET") {
|
||||||
|
parse_str($_SERVER['QUERY_STRING'], $query);
|
||||||
|
$control = $query['matpost'];
|
||||||
|
|
||||||
|
$runners = read_runners_from_csv();
|
||||||
|
usort($runners, "cmp");
|
||||||
|
$runners = array_reverse($runners);
|
||||||
|
$hourMin = date('H:i:s');
|
||||||
|
$waiting = "$hourMin
|
||||||
|
<h1>Tid igjen på matpost:<h1><div class='flex wrap center'>";
|
||||||
|
$finished = "<h1>Kan løpe videre:<h1><div class='flex wrap center'>";
|
||||||
|
for ($i = 0; $i < count($runners); $i++) {
|
||||||
|
$runner = $runners[$i];
|
||||||
|
if ($runner->get_control() == $control){
|
||||||
|
$time_since_punch = time() - ($runner->splits[$control])->getTimestamp();
|
||||||
|
|
||||||
|
//Løperen har ikke venta 4 minutt:
|
||||||
|
if ($time_since_punch < $time_limit) {
|
||||||
|
$time = format($time_limit - $time_since_punch);
|
||||||
|
$waiting .= "<div class=\"flash attention\">$runner->id $runner->name <span class=\"time\">-$time</span></div>";
|
||||||
|
} elseif ($time_since_punch >= $time_limit && $time_since_punch <900){ //Løperen har venta ferdig
|
||||||
|
$time = format(time()-$runner->splits[$control]->getTimestamp() - $time_limit) ;
|
||||||
|
$finished .= "<div class=\"flash success\">$runner->id $runner->name <span class=\"time\">+$time</span></div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo($waiting . "</div>". $finished . "</div>");
|
||||||
|
}
|
||||||
@ -19,6 +19,12 @@
|
|||||||
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
||||||
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
||||||
<li class="selected"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
<li class="selected"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
||||||
|
<li class="selected">⏳️ Nedtelling matpost
|
||||||
|
<menu>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=0">1. mat</a></li>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=1">2. mat</a></li>
|
||||||
|
</menu>
|
||||||
|
</li>
|
||||||
</menu>
|
</menu>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,12 @@
|
|||||||
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
||||||
<li class="selected"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
<li class="selected"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
||||||
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
||||||
|
<li class="selected">⏳️ Nedtelling matpost
|
||||||
|
<menu>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=0">1. mat</a></li>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=1">2. mat</a></li>
|
||||||
|
</menu>
|
||||||
|
</li>
|
||||||
</menu>
|
</menu>
|
||||||
</nav>
|
</nav>
|
||||||
<h2>Legg til løper</h2>
|
<h2>Legg til løper</h2>
|
||||||
|
|||||||
67
matpost_nedtelling.php
Normal file
67
matpost_nedtelling.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="no">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>EKT admin</title>
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
|
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
|
||||||
|
<link rel="icon" type="image/png" href="/img/favicon-96x96.png" sizes="96x96" />
|
||||||
|
<link rel="shortcut icon" href="/img/favicon.ico" />
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png" />
|
||||||
|
<meta name="apple-mobile-web-app-title" content="Kadaver'n" />
|
||||||
|
<link rel="manifest" href="/img/site.webmanifest" />
|
||||||
|
<link rel="stylesheet" href="css/matcha.css">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
.ui {
|
||||||
|
padding: 0 1.5rem;
|
||||||
|
padding-top: 0px;
|
||||||
|
padding-right: 1.5rem;
|
||||||
|
padding-bottom: 0px;
|
||||||
|
padding-left: 1.5rem;
|
||||||
|
|
||||||
|
margin: 0 auto;
|
||||||
|
margin-top: 0px;
|
||||||
|
margin-right: auto;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
margin-left: auto;
|
||||||
|
max-width: var(--ct-width);
|
||||||
|
}
|
||||||
|
.time {
|
||||||
|
font-size: 1.5em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.flash {
|
||||||
|
margin: 0.2em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body hx-ext="morph">
|
||||||
|
<nav class="ui">
|
||||||
|
<menu>
|
||||||
|
<li class="disabled"><a href="/admin.php">📊 Dashbord</a></li>
|
||||||
|
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
||||||
|
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
||||||
|
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
||||||
|
<li class="selected">⏳️ Nedtelling matpost
|
||||||
|
<menu>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=0">1. mat</a></li>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=1">2. mat</a></li>
|
||||||
|
</menu>
|
||||||
|
</li>
|
||||||
|
</menu>
|
||||||
|
</nav>
|
||||||
|
<?php
|
||||||
|
parse_str($_SERVER['QUERY_STRING'], $query);
|
||||||
|
$control = $query['matpost'];
|
||||||
|
echo("<div hx-get='/api/countdown.php?matpost=$control' hx-trigger='load, every 1s' hx-swap='morph:innerHTML'></div>");
|
||||||
|
?>
|
||||||
|
<script src="/lib/htmx.min.js"></script>
|
||||||
|
<script src="https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js" integrity="sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -53,6 +53,12 @@
|
|||||||
<li class="selected"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
<li class="selected"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
||||||
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
||||||
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
||||||
|
<li class="selected">⏳️ Nedtelling matpost
|
||||||
|
<menu>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=0">1. mat</a></li>
|
||||||
|
<li><a href="http://localhost:8000/matpost_nedtelling.php?matpost=1">2. mat</a></li>
|
||||||
|
</menu>
|
||||||
|
</li>
|
||||||
</menu>
|
</menu>
|
||||||
</nav>
|
</nav>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user