From bd845a86cf45a95f14f9f84b8a58d760ea80f5e8 Mon Sep 17 00:00:00 2001
From: Miklosimate <62291267+Miklosimate@users.noreply.github.com>
Date: Mon, 13 May 2024 23:10:35 +0200
Subject: [PATCH] Cleanup, comments

---
 index.html | 33 +--------------------------------
 index.js   | 13 +++++++------
 list.html  |  1 +
 3 files changed, 9 insertions(+), 38 deletions(-)

diff --git a/index.html b/index.html
index 9b921b0..8a776c6 100644
--- a/index.html
+++ b/index.html
@@ -1,3 +1,4 @@
+<!-- //This file was written by chatGPT (3.5) with many iterations and manual corrections. -->
 <!DOCTYPE html>
 <html lang="en">
 <head>
@@ -142,38 +143,6 @@
             console.error('Error fetching devices:', error);
         }
     }
-
-    async function handleStillHereMessageAndRefresh(deviceID) {
-        try {
-            const response = await fetch(`/stillHere/${deviceID}`, {
-                method: 'POST',
-            });
-
-            const data = await response.json();
-
-            // Refresh the device list after receiving "stillHere" message
-            await populateDeviceList();
-        } catch (error) {
-            console.error('Error handling stillHere message:', error);
-        }
-    }
-
-
-    async function handleReadyMessageAndRefresh(deviceID) {
-        try {
-            const response = await fetch(`/ready/${deviceID}`, {
-                method: 'POST',
-            });
-
-            const data = await response.json();
-
-            // Refresh the device list after receiving "ready" message
-            await populateDeviceList();
-        } catch (error) {
-            console.error('Error handling ready message:', error);
-        }
-    }
-
     // Populate device list on page load
     populateDeviceList();
 </script>
diff --git a/index.js b/index.js
index 1e90d8c..3939aec 100644
--- a/index.js
+++ b/index.js
@@ -28,7 +28,7 @@ app.get('/list', (req, res) => {
     res.sendFile(path.join(__dirname, 'list.html'));
 });
 
-// Add route to get server info
+//This function was written by chatGPT (3.5), the rest of the code and the "Write me the route for server info" input was given.
 app.get('/server-info', (req, res) => {
     const serverInfo = {
         ip: ip.address(),
@@ -36,8 +36,7 @@ app.get('/server-info', (req, res) => {
     };
     res.json(serverInfo);
 });
-
-// POST route for handling "init" messages
+//This function was written by chatGPT (3.5) with many iterations and manual corrections.
 app.post('/init', (req, res) => {
     console.log(`Received "init" message\n`);
     //If the measurement parameters has not been set yet
@@ -67,6 +66,7 @@ app.post('/init', (req, res) => {
 
 
 // POST route for checking "am-i-ok" messages
+//This function was written by chatGPT (3.5) with many iterations and manual corrections.
 app.post('/am-i-ok/:deviceID', (req, res) => {
     const deviceID = req.params.deviceID;
     let responseToSend
@@ -85,7 +85,7 @@ app.post('/am-i-ok/:deviceID', (req, res) => {
     }
     console.log('Sent JSON:', responseToSend);
 });
-
+//This function was written by chatGPT (3.5) with many iterations and manual corrections.
 app.post('/json/:deviceID/:f_n', (req, res) => {
     const deviceID = req.params.deviceID;
     const f_n = req.params.f_n;
@@ -139,7 +139,7 @@ app.post('/ready/:deviceID', (req, res) => {
         connectedDevices[deviceID].state = 'Ready';
     }
 });
-
+//This function was written by chatGPT (3.5) with many iterations and manual corrections.
 app.post('/stillHere/:deviceID', (req, res) => {
     const deviceID = req.params.deviceID;
     // Check if the device is registered
@@ -169,7 +169,7 @@ function generateDeviceID() {
     // Generate a unique device ID (you can use a more robust method if needed)
     return Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
 }
-
+//This function was written by chatGPT (3.5)
 app.get('/get-devices', (req, res) => {
     const devicesList = Object.keys(connectedDevices).map(deviceID => {
         return {
@@ -181,6 +181,7 @@ app.get('/get-devices', (req, res) => {
 
     res.json(devicesList);
 });
+//This function was written by chatGPT (3.5) manual corrections was needed.
 app.post('/set-server-config', (req, res) => {
     // Handle the POST request to set server configuration
     const { NumberOfMeasurements, Intervals, Delay } = req.body;
diff --git a/list.html b/list.html
index 11faa6e..609975d 100644
--- a/list.html
+++ b/list.html
@@ -1,3 +1,4 @@
+<!-- //This file was written by chatGPT (3.5) with many iterations and manual corrections. -->
 <!DOCTYPE html>
 <html lang="en">
 <head>
-- 
GitLab