2022-07-24 01:09:22 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="de">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Blitzer</title>
|
|
|
|
<style type="text/css">
|
|
|
|
body, html {
|
|
|
|
padding: 0;
|
|
|
|
margin: 10px 20px;
|
|
|
|
font-family: sans-serif;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn {
|
|
|
|
width: 100%;
|
|
|
|
height: 70px;
|
|
|
|
background-color: red;
|
|
|
|
color: white;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Blitzercontrol</h1>
|
2022-07-25 08:04:51 +00:00
|
|
|
<button onclick="getData()">Refresh</button>
|
2022-07-24 01:09:22 +00:00
|
|
|
<h2>Highscore</h2>
|
|
|
|
<span id="highscore">23km/h</span>
|
|
|
|
<h2>Letzte Messungen</h2>
|
|
|
|
<ul id="lastSpeeds">
|
|
|
|
<li></li>
|
|
|
|
<li></li>
|
|
|
|
<li></li>
|
|
|
|
<li></li>
|
|
|
|
<li></li>
|
|
|
|
<li></li>
|
|
|
|
<li></li>
|
|
|
|
<li></li>
|
|
|
|
<li></li>
|
|
|
|
<li></li>
|
|
|
|
</ul>
|
|
|
|
<h2>Manuelle Steuerung</h2>
|
|
|
|
<button class="btn" onclick="flash()">Flash</button>
|
|
|
|
<h2>Speed setting</h2>
|
|
|
|
<input id="threshold" type="text" /> km/h<br />
|
|
|
|
<button onclick="setSpeed()">Set Speed</button>
|
|
|
|
<script type="text/javascript">
|
|
|
|
const highscoreElem = document.getElementById("highscore");
|
|
|
|
const lastSpeeds = document.getElementById("lastSpeeds");
|
|
|
|
const thresholdFieldElem = document.getElementById("threshold");
|
|
|
|
function flash() {
|
|
|
|
fetch('/flash').then(() => {});
|
|
|
|
}
|
|
|
|
function setSpeed() {
|
|
|
|
console.log('/set?speed=' + thresholdFieldElem.value);
|
|
|
|
fetch('/set?speed=' + thresholdFieldElem.value);
|
|
|
|
}
|
|
|
|
function getData() {
|
2022-07-25 08:04:51 +00:00
|
|
|
const controller = new AbortController();
|
|
|
|
const id = setTimeout(() => controller.abort(), 1500);
|
|
|
|
fetch('/data.json', {
|
|
|
|
signal: controller.signal
|
|
|
|
})
|
2022-07-24 01:09:22 +00:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
2022-07-25 08:04:51 +00:00
|
|
|
clearTimeout(id);
|
2022-07-24 01:09:22 +00:00
|
|
|
highscoreElem.innerText = data.highscore + ' km/h';
|
|
|
|
let c = lastSpeeds.children;
|
|
|
|
for(let i=0; i<data.lastSpeeds.length; i++) {
|
|
|
|
c[i].innerText = data.lastSpeeds[i] + ' km/h';
|
|
|
|
}
|
2022-07-25 08:04:51 +00:00
|
|
|
thresholdFieldElem.value = data.threshold
|
2022-07-24 01:09:22 +00:00
|
|
|
});
|
|
|
|
}
|
2022-07-25 08:04:51 +00:00
|
|
|
window.setInterval(getData, 5000)
|
2022-07-24 01:09:22 +00:00
|
|
|
getData();
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|