mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-05-19 10:32:56 +00:00
30 lines
674 B
JavaScript
30 lines
674 B
JavaScript
import { writeDataToInput } from "/load-data.js";
|
|
|
|
const form = document.querySelector("form");
|
|
|
|
form.addEventListener("reset", async (event) => {
|
|
event.preventDefault();
|
|
|
|
const ok = confirm(
|
|
"Sicher, dass du alle Einstellungen zurücksetzen möchtest?"
|
|
);
|
|
if (ok) {
|
|
reset();
|
|
}
|
|
});
|
|
|
|
async function reset() {
|
|
try {
|
|
const res = await fetch("/reset", {
|
|
method: "POST",
|
|
});
|
|
if (!res.ok) {
|
|
throw new Error(`Response status: ${res.status}`);
|
|
}
|
|
|
|
const json = await res.json();
|
|
writeDataToInput(json);
|
|
} catch (error) {
|
|
console.error(error.message);
|
|
}
|
|
}
|