From 8ff349aa70bde033e0629d653388581e9b4b6dcb Mon Sep 17 00:00:00 2001 From: Tony Jurg <114746162+tonyjurg@users.noreply.github.com> Date: Thu, 8 Aug 2024 09:51:46 +0200 Subject: [PATCH] Update codeDocumentation.md --- docs/codeDocumentation.md | 56 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/docs/codeDocumentation.md b/docs/codeDocumentation.md index cf3c2ac..69992d5 100644 --- a/docs/codeDocumentation.md +++ b/docs/codeDocumentation.md @@ -7,35 +7,31 @@ The provided codebase consists of two primary files: `index.js` (running on the Together, these files create a web-based interface for using Tasmota-powered devices as a timer. The following description outlines the functionality and interactions between these files. -# index.html +# File: index.html The `index.html` file is a web page designed to control the timerfunction on a Tasmota devices via a simple user interface. It contains several HTML elements, JavaScript functions, and CSS references to facilitate control and status monitoring of the Tasmota timer. This part is rendered and executed at the client side, to create a GUI and define actions for its control elements. The static file index.html together with the ascociated stylesheet (`index.css`) are served by a call to index.js. -
-Details on HTML Structure +##Details on HTML Structure -
Head Section:
+*Head Section:* -Body Section: +*Body Section:* -
-
-Details on JavaScript functionality -
Embedded within the HTML file, the JavaScript handles the interaction logic: +Embedded within the HTML file, the JavaScript handles the interaction using the following logic: -
Initialization and WebSocket Setup: +*Initialization and WebSocket Setup:* -Device Control Functions: +*Device Control Functions:* -Utility Functions: +*Utility Functions:* -Event Listeners: +*Event Listeners:* -
-# index.js +# File: index.js -The index.js file implements the server-side logic using Node.js, handling HTTP requests to interact with Tasmota devices. It reads configuration settings, manages user authentication, and serves static files and API endpoints. This part is executed at the server side. +The index.js file implements the server-side logic using Node.js, handling HTTP requests to interact with Tasmota devices. It reads configuration settings, manages user authentication, and serves static files and API endpoints. This part is executed at the server side. The following functionality is provided: -
-Server Setup and Configuration +## Server Setup and Configuration + +Dependencies and Initialization:* -
Dependencies and Initialization: -Configuration File Loading:

+*Configuration File Loading:* + Reads and parses config.json and settings.json to load user credentials and device accounts.
-
-
-HTTP Server -
-Server Creation:

+ +## HTTP Server + +*Server Creation:* + Creates an HTTP server to listen for incoming requests.
-Request Handling:

+*Request Handling:* + Handles different routes based on the request URL: -Command Execution: +*Command Execution:* + Defines functions to handle device commands: -Utility Functions: +*Utility Functions:* + -
## Logging and Debugging