Added spiffs data files

This commit is contained in:
Alex Alvarado
2022-05-17 12:10:41 +02:00
parent f6a075e641
commit 629c9319b1
3 changed files with 85 additions and 0 deletions

17
data/config.html Normal file
View File

@ -0,0 +1,17 @@
<!--INCLUDE MASTER-->
<div class="row">
<h2>Configuració</h2>
</div>
<div class="row">
<div class="row">
<h2>Punt d'accés</h2>
</div>
<div class="row">
<div class="col">SSID</div>
<div class="col"><input type="text" value=" &APSSID& "></div>
</div>
<div class="row">
<div class="col">Contrassenya</div>
<div class="col"><input type="text" value=" &APPASS& "></div>
</div>
</div>

63
data/index.html Normal file
View File

@ -0,0 +1,63 @@
<!--INCLUDE MASTER-->
<div class="row">
<label id="chrono-label"><a id="chrono">00:00.000</a> ± 0.002s</label>
</div>
<div class="row">
<div class="col">
<button id="btn-start" class="btn btn-success" type="button" onmousedown="startManual()">Inicia</button>
</div>
<div class="col">
<button id="btn-stop" class="btn btn-danger" type="button" onmousedown="stopManual()">Atura</button>
</div>
<div class="col">
<button id="btn-reset" class="btn btn-secondary" type="button" onmousedown="restartManual()">Reinicia</button>
</div>
</div>
<script>
/* Solicitar JSON desde una URL con JavaScript nativo */
var getJSON = function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function () {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
function API_CALL(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();
}
var chrono = document.getElementById("chrono");
function startManual() {
API_CALL("/api/start")
}
function stopManual() {
API_CALL("/api/stop")
}
function restartManual() {
API_CALL("/api/reset");
}
function updateTimerHandler() {
getJSON('/api/getElapsedTime',
function (err, data) {
if (err !== null) {
console.log("Error getting elapsed time");
} else {
var ms = data["elapsed"];
chrono.textContent = String(Math.round(ms / 1000)).padStart(2, '0') + '.' + String(ms % 1000).padEnd(3, '0');
}
});
}
var updateTimer = setInterval(updateTimerHandler, 100);
</script>

View File

@ -16,5 +16,10 @@ html {
font-size: 2em;
margin-left: auto;
margin-right: auto;
}
#chrono-label {
margin-left: auto;
margin-right: auto;
text-align: center;
}