2024-08-14 23:02:03 +00:00
|
|
|
import { Communicator,State } from './HestiaClasses.js';
|
2024-08-14 23:00:58 +00:00
|
|
|
|
2024-08-14 23:15:55 +00:00
|
|
|
window.onload = async function() {
|
2024-08-15 00:26:40 +00:00
|
|
|
await fetch('/assets/config.json')
|
2024-08-14 23:15:55 +00:00
|
|
|
.then(response => {
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error('Network response was not ok');
|
2024-08-15 00:26:40 +00:00
|
|
|
|
|
|
|
return response.json(); // Parse the JSON data from the response
|
2024-08-14 23:15:55 +00:00
|
|
|
})
|
|
|
|
.then(data => {
|
2024-08-15 00:26:40 +00:00
|
|
|
const config = data;
|
|
|
|
console.log(config);
|
|
|
|
const psState = new State(config);
|
|
|
|
refreshState(window.document, psState);
|
2024-08-14 23:15:55 +00:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error('There was a problem with the fetch operation:', error);
|
|
|
|
});
|
2024-08-14 23:00:58 +00:00
|
|
|
};
|
|
|
|
|
2024-08-14 23:15:55 +00:00
|
|
|
function refreshState(doc, state) {
|
2024-08-14 23:00:58 +00:00
|
|
|
const igniterStatus = doc.getElementById("igniterStatus");
|
|
|
|
const exhaustStatus = doc.getElementById("exhaustStatus");
|
|
|
|
const augerStatus = doc.getElementById("augerStatus");
|
|
|
|
let statusString;
|
|
|
|
|
|
|
|
statusString = '';
|
2024-08-14 23:15:55 +00:00
|
|
|
if (state.igniter.on) statusString = "On"; else statusString = "Off";
|
2024-08-14 23:00:58 +00:00
|
|
|
igniterStatus.innerHTML = statusString;
|
|
|
|
|
|
|
|
statusString = '';
|
2024-08-14 23:15:55 +00:00
|
|
|
if (state.exhaust.on) statusString = "On"; else statusString = "Off";
|
2024-08-14 23:00:58 +00:00
|
|
|
exhaustStatus.innerHTML = statusString;
|
|
|
|
|
|
|
|
statusString = '';
|
2024-08-14 23:15:55 +00:00
|
|
|
if (state.auger.on) statusString = "On"; else statusString = "Off";
|
2024-08-14 23:00:58 +00:00
|
|
|
augerStatus.innerHTML = statusString;
|
|
|
|
}
|