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