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); });