mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
refactor data display to use table rows for sensor data
This commit is contained in:
@@ -37,16 +37,19 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
// Parse the data and show it on the website
|
||||
async function parseData() {
|
||||
const data = await fetchData();
|
||||
const sensorDataContainer = document.getElementById("sensor-data");
|
||||
const sensorDataContainer = document.getElementById("sensor-data").querySelector("tbody");
|
||||
sensorDataContainer.innerHTML = ""; // Clear previous data
|
||||
// For each object in JSON array, create a new paragraph element and append it to the sensorDataContainer
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
const dataElement = document.createElement("p");
|
||||
dataElement.textContent = `${key}: ${value}`;
|
||||
sensorDataContainer.appendChild(dataElement);
|
||||
}
|
||||
// For each object in JSON array, create a new row and append it to the sensorDataContainer
|
||||
data.forEach(sensor => {
|
||||
const row = document.createElement("tr");
|
||||
Object.entries(sensor).forEach(([key, value]) => {
|
||||
const cell = document.createElement("td");
|
||||
cell.textContent = `${key}: ${value}`;
|
||||
row.appendChild(cell);
|
||||
});
|
||||
sensorDataContainer.appendChild(row);
|
||||
});
|
||||
}
|
||||
|
||||
// Update the image
|
||||
function updateImage() {
|
||||
var img = document.getElementById("robot-image");
|
||||
|
Reference in New Issue
Block a user