This repository has been archived on 2025-05-16. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
pi-race-timer/app/static/js/admin.js
2025-04-29 23:36:37 +02:00

30 lines
814 B
JavaScript

function systemCommand(cmd) {
fetch(`/admin/${cmd}`, { method: "POST" })
.then(res => res.text())
.then(alert);
}
function fetchLogs() {
fetch("/admin/logs")
.then(res => res.text())
.then(data => {
document.getElementById("logs").innerText = data;
});
}
document.getElementById("adminForm").addEventListener("submit", function(e) {
e.preventDefault();
const data = new FormData(e.target);
const json = {};
for (let [k, v] of data.entries()) {
json[k] = v;
}
json["ziel_aktiviert"] = data.get("ziel_aktiviert") === "on";
fetch("/admin/save", {
method: "POST",
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(json)
}).then(res => res.text())
.then(alert);
});