From 543b477cca098e4fd9b4ec75ec39e3b4331e69d2 Mon Sep 17 00:00:00 2001 From: louisa Date: Mon, 19 Jun 2023 16:45:26 +0200 Subject: [PATCH] background colour conditions --- public/index.html | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/public/index.html b/public/index.html index 92b04db..f09e7e8 100644 --- a/public/index.html +++ b/public/index.html @@ -19,23 +19,17 @@ // Split the data into separate parts const [node, value] = data.split(' '); - if (node === 'node3' && value === '15') { // Change the background color to red document.body.style.backgroundColor = 'red'; - } - - if (node === 'node4' && value === '21') { + } else if (node === 'node4' && value === '21') { // Change the background color to blue document.body.style.backgroundColor = 'blue'; - } - - else { + } else { // Restore the default background color - document.body.style.backgroundColor = 'white'; + document.body.style.backgroundColor = rgb(26, 26, 26); } - }); - + }); function sendMessage() { const inputField = document.getElementById('input'); const message = inputField.value;