LoRa_APRS_iGate/data/script.js

35 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-08-29 05:21:20 +02:00
// Retrieve JSON data from the JSON file in SPIFFS
fetch('igate_conf.json')
.then(response => response.json())
.then(data => {
// Process the JSON data
2023-09-03 15:05:07 +02:00
//displayJSONData(data);
const jsonDataDiv = document.getElementById('json-container');
jsonDataDiv.innerHTML = ''; // Clear the previous content
if (Array.isArray(data)) {
// If data is an array, iterate through it
data.forEach(item => {
const itemDiv = document.createElement('div');
itemDiv.textContent = JSON.stringify(item, null, 2);
jsonDataDiv.appendChild(itemDiv);
});
} else {
// If data is not an array, display it directly
const itemDiv = document.createElement('div');
itemDiv.textContent = JSON.stringify(data, null, 2);
jsonDataDiv.appendChild(itemDiv);
}
2023-08-29 05:21:20 +02:00
})
.catch(error => {
2023-09-03 15:05:07 +02:00
console.error('There was a problem fetching the JSON data:', error);
2023-08-29 05:21:20 +02:00
});
// Display JSON data in the HTML
function displayJSONData(data) {
2023-09-03 15:05:07 +02:00
//const jsonContainer = document.getElementById('json-container');
//jsonContainer.innerHTML = JSON.stringify(data, null, 2);
2023-08-29 05:21:20 +02:00
}