2024-02-11 18:27:54 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="no">
|
2024-02-12 20:23:13 +00:00
|
|
|
<head>
|
|
|
|
<style>
|
|
|
|
.passed {
|
|
|
|
background-color: #8ff0a4;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<table>
|
|
|
|
<tbody id="runners">
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</body>
|
2024-02-11 18:27:54 +00:00
|
|
|
<script>
|
2024-02-12 20:23:13 +00:00
|
|
|
function register_runner(id, name) {
|
|
|
|
update_row(id, name, true)
|
|
|
|
let formData = new FormData();
|
|
|
|
formData.append(name= 'id', value=id);
|
|
|
|
time = new Date(Date.now()).toISOString()
|
|
|
|
formData.append('time', time);
|
2024-02-11 18:27:54 +00:00
|
|
|
fetch("upload.php", {
|
|
|
|
method: "POST",
|
2024-02-12 20:23:13 +00:00
|
|
|
body: formData,
|
2024-02-11 18:27:54 +00:00
|
|
|
});
|
|
|
|
};
|
2024-02-12 20:23:13 +00:00
|
|
|
|
|
|
|
function read_db() {
|
|
|
|
let xmlHttp = new XMLHttpRequest();
|
|
|
|
xmlHttp.open("GET", "db.csv", false);
|
|
|
|
xmlHttp.send(null);
|
|
|
|
return xmlHttp.responseText;
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_row(id, name, passed) {
|
|
|
|
if (!passed) {
|
|
|
|
button = `<button onclick="register_runner(${id}, '${name}')">✓</button>`
|
|
|
|
return `<tr id="${id}"><td>${id}</td><td>${name}</td><td>${button}</td></tr>`
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
button = `<button onclick="register_runner(${id}, '${name}')">Angre</button>`
|
|
|
|
return `<tr id="${id}" class="passed"><td>${id}</td><td>${name}</td><td>${button}</td></tr>`
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_rows(csv) {
|
|
|
|
csv = csv.split('\n')
|
|
|
|
rows = ""
|
|
|
|
for (i in csv) {
|
|
|
|
data = csv[i].split(",")
|
|
|
|
rows += create_row(data[0], data[1], false)
|
|
|
|
}
|
|
|
|
return rows
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_row(id, name, passed) {
|
|
|
|
row = document.getElementById(id)
|
|
|
|
row.innerHTML = create_row(id, name, passed)
|
|
|
|
row.classList.add("passed");
|
|
|
|
}
|
|
|
|
table = document.getElementById("runners")
|
|
|
|
table.innerHTML = create_rows(read_db())
|
2024-02-11 18:27:54 +00:00
|
|
|
</script>
|
|
|
|
<html>
|