Refactor main.js: Add descriptions, declare variables, and update loop condition
This commit is contained in:
12
web/main.js
12
web/main.js
@@ -1,9 +1,13 @@
|
||||
// Description: Main JavaScript file for the web application.
|
||||
// arrays and stuff
|
||||
const sensorData = {};
|
||||
let intervalDelay = 5000;
|
||||
// Create WebSocket connection.
|
||||
const socket = new WebSocket("ws://145.92.8.114/ws");
|
||||
let liveGraphs = [];
|
||||
|
||||
// variables
|
||||
let intervalDelay = 5000;
|
||||
let amountOfNodes = 4;
|
||||
|
||||
const socket = new WebSocket("ws://145.92.8.114/ws");
|
||||
function openConnection() {
|
||||
// Open connection
|
||||
socket.addEventListener("open", (event) => {
|
||||
@@ -192,7 +196,7 @@ function updateNodeData(node, temperature, humidity, eCO2, TVOC) {
|
||||
}
|
||||
|
||||
// Call the function to create the HTML structure
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
for (let i = 1; i <= amountOfNodes; i++) {
|
||||
createNodeData(i);
|
||||
liveGraphs.push(new liveGraph(i));
|
||||
}
|
||||
|
Reference in New Issue
Block a user