diff --git a/data/index.html.gz b/data/index.html.gz index e0fb8bf..c15156a 100644 Binary files a/data/index.html.gz and b/data/index.html.gz differ diff --git a/data/index.js.gz b/data/index.js.gz index 2fb8d53..4676f62 100644 Binary files a/data/index.js.gz and b/data/index.js.gz differ diff --git a/data/low_power.html.gz b/data/low_power.html.gz index 60ee962..43105e0 100644 Binary files a/data/low_power.html.gz and b/data/low_power.html.gz differ diff --git a/data/low_power.js.gz b/data/low_power.js.gz index 088d581..b85095e 100644 Binary files a/data/low_power.js.gz and b/data/low_power.js.gz differ diff --git a/data/ota.html.gz b/data/ota.html.gz index ababbf0..92268c1 100644 Binary files a/data/ota.html.gz and b/data/ota.html.gz differ diff --git a/data/ota.js.gz b/data/ota.js.gz index 009e082..b919048 100644 Binary files a/data/ota.js.gz and b/data/ota.js.gz differ diff --git a/data/preferences.html.gz b/data/preferences.html.gz index d6b8d28..02a44f9 100644 Binary files a/data/preferences.html.gz and b/data/preferences.html.gz differ diff --git a/data/preferences.js.gz b/data/preferences.js.gz index 1913029..f619e63 100644 Binary files a/data/preferences.js.gz and b/data/preferences.js.gz differ diff --git a/data/status.html.gz b/data/status.html.gz index d558ebb..dc8256d 100644 Binary files a/data/status.html.gz and b/data/status.html.gz differ diff --git a/data/status.js.gz b/data/status.js.gz index f498217..92718b5 100644 Binary files a/data/status.js.gz and b/data/status.js.gz differ diff --git a/data/style.css.gz b/data/style.css.gz index fb6fa2f..c185464 100644 Binary files a/data/style.css.gz and b/data/style.css.gz differ diff --git a/platformio.ini b/platformio.ini index 36df993..8b7aa87 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,7 +13,7 @@ extra_configs = platformio_extra_configs.ini [version] build_flags = -D CO2_GADGET_VERSION="\"0.14."\" - -D CO2_GADGET_REV="\"011-development-low-power"\" + -D CO2_GADGET_REV="\"012-development-low-power"\" ;**************************************************************************************** ;*** You can disable features by commenting the line with a semicolon at the beginning diff --git a/webserver/common.js b/webserver/common.js index cf184c8..a1978d0 100644 --- a/webserver/common.js +++ b/webserver/common.js @@ -404,11 +404,12 @@ function readPreferencesFromServer() { } /** - * Initialize the captive portal for preferences.html. + * Initialize the navbar based on the features supported by the device. */ function initNavBar() { if (captivePortalDebug) console.log("Document loaded. Initializing navbar..."); + if (features.SUPPORT_OTA) { const otaLink = document.getElementById("otaLink"); if (otaLink) { @@ -417,6 +418,7 @@ function initNavBar() { console.error('Element with ID "otaLink" not found.') } } + if (features.SUPPORT_LOW_POWER) { const lowPowerLink = document.getElementById("lowPowerLink"); if (lowPowerLink) { @@ -424,14 +426,45 @@ function initNavBar() { } else { console.error('Element with ID "lowPowerLink" not found.') } + + const lowPowerIcon = document.getElementById("iconLighting"); + if (lowPowerIcon) { + lowPowerIcon.classList.remove("hidden"); + } else { + console.error('Element with ID "iconLighting" not found.') + } } } +/** + * Handles the low power mode activation. + */ +function goLowPower() { + console.log("Low power mode activated"); + fetch('/goLowPower', { + method: 'GET', + headers: { + 'Content-Type': 'text/plain' + } + }) + .then(response => { + if (response.ok) { + console.log('Low power mode activated'); + } else { + throw new Error(`HTTP error! Status: ${response.status}`); + } + }) + .catch(error => console.error('Error activating low power mode:', error)); +} + document.addEventListener("DOMContentLoaded", function () { getFeaturesAsJson().then(initNavBar); - // Add device hostName to the exixting page title as document.title + (HostName) + // Add device hostName to the existing page title as document.title + (HostName) readPreferencesFromServer().then(data => { document.title += ` (${data.hostName})`; }); -}); \ No newline at end of file + + // Llamar a la función goLowPower al hacer clic en el icono de bajo consumo + document.getElementById('lightingIcon').addEventListener('click', goLowPower); +}); diff --git a/webserver/index.html b/webserver/index.html index f01dad1..417ea7a 100644 --- a/webserver/index.html +++ b/webserver/index.html @@ -17,7 +17,7 @@ -
+ diff --git a/webserver/low_power.html b/webserver/low_power.html index 8754a37..c51d7ba 100644 --- a/webserver/low_power.html +++ b/webserver/low_power.html @@ -67,6 +67,12 @@ + +