fixes dynamic node function
This commit is contained in:
10
web/main.js
10
web/main.js
@@ -29,6 +29,7 @@ function openConnection() {
|
||||
const jsonData = JSON.parse(event.data);
|
||||
// Use the parsed JSON data as needed
|
||||
handleIncomingData(jsonData);
|
||||
console.log(jsonData);
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error parsing JSON:", error);
|
||||
@@ -47,8 +48,8 @@ function openConnection() {
|
||||
openConnection();
|
||||
|
||||
function handleIncomingData(data) {
|
||||
if (!data.message) {
|
||||
nodeEventHandler(data.node);
|
||||
|
||||
nodeNumber = nodeDict[data.node];
|
||||
temperature = data.Temp;
|
||||
humidity = data.Humi;
|
||||
@@ -57,6 +58,7 @@ function handleIncomingData(data) {
|
||||
|
||||
updateNodeData(nodeNumber, temperature, humidity, CO2, TVOC);
|
||||
}
|
||||
}
|
||||
|
||||
function nodeEventHandler(node) {
|
||||
if (!nodeArray.includes(node)) {
|
||||
@@ -71,9 +73,9 @@ function makeLiveGraph(node) {
|
||||
createNodeData(node);
|
||||
liveGraphs.push(new liveGraph(node));
|
||||
|
||||
liveGraphs.forEach((graph) => {
|
||||
graph.makeGraph();
|
||||
});
|
||||
console.log("Node " + node + " added to the liveGraphs array");
|
||||
|
||||
liveGraphs[node - 1].makeGraph();
|
||||
}
|
||||
|
||||
//function for making the html elements for the following html code
|
||||
|
Reference in New Issue
Block a user