diff --git a/src/Python/flask/web/static/script.js b/src/Python/flask/web/static/script.js index de56ad4..57938f4 100644 --- a/src/Python/flask/web/static/script.js +++ b/src/Python/flask/web/static/script.js @@ -1,6 +1,6 @@ // Selecteer alle knoppen en voeg een event listener toe aan elke knop -document.querySelectorAll(".btn").forEach(button => { - button.addEventListener("click", function(event) { +document.querySelectorAll(".btn").forEach((button) => { + button.addEventListener("click", function (event) { event.preventDefault(); // voorkomt pagina-verversing // Haal de waarde van de knop op @@ -9,30 +9,30 @@ document.querySelectorAll(".btn").forEach(button => { fetch("/move", { method: "POST", headers: { - "Content-Type": "application/json" + "Content-Type": "application/json", }, - body: JSON.stringify({ direction: direction }) + body: JSON.stringify({ direction: direction }), }) - .then(response => response.json()) - .then(data => { - console.log("Success:", data); - }) - .catch(error => { - console.error("Error:", error); - }); + .then((response) => response.json()) + .then((data) => { + console.log("Success:", data); + }) + .catch((error) => { + console.error("Error:", error); + }); }); // Fetch data from the server async function fetchData() { - try{ - const response = await fetch("/data"); - const data = await response.json(); - return data; - } catch (error) { - console.error("Error:", error); + try { + const response = await fetch("/data"); + const data = await response.json(); + return data; + } catch (error) { + console.error("Error:", error); + } } - // Parse the data and show it on the website async function parseData() { const data = await fetchData(); @@ -48,4 +48,4 @@ document.querySelectorAll(".btn").forEach(button => { // Fetch and display sensor data every 5 seconds setInterval(parseData, 5000); -}); \ No newline at end of file +});