mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-04 04:14:58 +00:00
attempt to fix javascript
This commit is contained in:
@@ -14,7 +14,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
body: JSON.stringify({ direction: direction })
|
body: JSON.stringify({ direction: direction })
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {script
|
.then(data => {
|
||||||
console.log("Success:", data);
|
console.log("Success:", data);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -25,13 +25,14 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
|
|
||||||
// Fetch data from the server
|
// Fetch data from the server
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
try{
|
try {
|
||||||
const response = await fetch("/data");
|
const response = await fetch("/data");
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parse the data and show it on the website
|
// Parse the data and show it on the website
|
||||||
async function parseData() {
|
async function parseData() {
|
||||||
@@ -52,9 +53,9 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
img.src = "/image?" + new Date().getTime(); // Add timestamp to avoid caching
|
img.src = "/image?" + new Date().getTime(); // Add timestamp to avoid caching
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch and display sensor data every 5 seconds
|
// Fetch and display sensor data every 1 second
|
||||||
setInterval(parseData, 1000);
|
setInterval(parseData, 1000);
|
||||||
|
|
||||||
// Update the image every 5 seconds
|
// Update the image every 200 milliseconds
|
||||||
setInterval(updateImage, 200);
|
setInterval(updateImage, 200);
|
||||||
}});
|
});
|
Reference in New Issue
Block a user