more node things

master
louisa 2 years ago
parent 608f1b5543
commit a1f0e3169c

@ -13,16 +13,19 @@
<script> <script>
const socket = io(); const socket = io();
// Listen for custom events from the server
socket.on('node-data', function(data) { socket.on('node-data', function(data) {
console.log(data); // Log the received data to the browser's console console.log(data);
if (node === 'node4' && value === '21') {
// Change the background color to red // Split the data into separate parts
document.body.style.backgroundColor = 'red'; const [node, value] = data.split(' ');
} else {
// Restore the default background color if (node === 'node4' && value === '21') {
document.body.style.backgroundColor = 'white'; // Change the background color to red
} document.body.style.backgroundColor = 'red';
} else {
// Restore the default background color
document.body.style.backgroundColor = 'white';
}
}); });
</script> </script>
<script src='socket.io/socket.io.js'></script> <script src='socket.io/socket.io.js'></script>

Loading…
Cancel
Save