From 1117af20e923ddfcf49555d7f39898e319305901 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Dec 2024 14:51:54 -0500 Subject: [PATCH] Move psState to the Window for global access --- src/assets/hestia.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/assets/hestia.js b/src/assets/hestia.js index 54bf0fc..8766ed5 100644 --- a/src/assets/hestia.js +++ b/src/assets/hestia.js @@ -37,8 +37,8 @@ const config = { }; // Create a new state and communicator -const psState = new State(config); -const comms = new Communicator(psState); +window.psState = new State(config); +const comms = new Communicator(window.psState); // Grab elements from the DOM const setFeedRateButton = document.getElementById("set-feed-rate"); @@ -81,8 +81,8 @@ export function refreshState(doc, state) { } export function togglePower(element) { - psState[element].power(comms); - refreshState(window.document, psState); + window.psState[element].power(comms); + refreshState(window.document, window.psState); } export function startup() { @@ -95,13 +95,13 @@ export function shutdown() { // Run stuff once the page loads window.onload = function() { - comms.init(psState, config); - refreshState(window.document, psState); + comms.init(window.psState, config); + refreshState(window.document, window.psState); }; setFeedRateButton.addEventListener("click", function() { const feedRate = document.getElementById("feed-rate").value; - psState.auger.feedRate = feedRate; - comms.send(config.mqtt.topics.auger, JSON.stringify(psState.auger)); - refreshState(window.document, psState); + window.psState.auger.feedRate = feedRate; + comms.send(config.mqtt.topics.auger, JSON.stringify(window.psState.auger)); + refreshState(window.document, window.psState); }); \ No newline at end of file