diff --git a/Arduino/CanGrow/include/CanGrow.h b/Arduino/CanGrow/include/CanGrow.h index a9f1cc2..fca6e19 100644 --- a/Arduino/CanGrow/include/CanGrow.h +++ b/Arduino/CanGrow/include/CanGrow.h @@ -76,8 +76,6 @@ struct GPIO_Index { const byte Max_Outputs = 16; -const char[] Output_Types= { "GPIO" , "I2C", "URL" } -byte Output_Types_len = 3; /* * diff --git a/Arduino/CanGrow/include/CanGrow_Webserver.h b/Arduino/CanGrow/include/CanGrow_Webserver.h index 59cc5f8..41d8af4 100644 --- a/Arduino/CanGrow/include/CanGrow_Webserver.h +++ b/Arduino/CanGrow/include/CanGrow_Webserver.h @@ -31,6 +31,7 @@ * include static files files */ #include "Webserver/File_cangrow_CSS.h" +#include "Webserver/File_cangrow_JS.h" #include "Webserver/File_favicon_ico.h" /* @@ -86,6 +87,7 @@ void Webserver_Init() { /* url handler definition */ webserver.on("/", HTTP_GET, WebPage_root); webserver.on("/cangrow.css", HTTP_GET, WebFile_cangrow_CSS); + webserver.on("/cangrow.js", HTTP_GET, WebFile_cangrow_JS); webserver.on("/favicon.ico", HTTP_GET, WebFile_favicon_ico); webserver.on("/wifi/", HTTP_GET, WebPage_wifi); diff --git a/Arduino/CanGrow/include/Webserver/File_cangrow_JS.h b/Arduino/CanGrow/include/Webserver/File_cangrow_JS.h new file mode 100644 index 0000000..aecb09b --- /dev/null +++ b/Arduino/CanGrow/include/Webserver/File_cangrow_JS.h @@ -0,0 +1,61 @@ +/* + * + * include/Webserver/File_cangrow_JS.h - /cangrow.js header file + * + * + * MIT License + * + * Copyright (c) 2024 DeltaLima + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + + +const char* File_cangrow_JS PROGMEM = R"(function toggleDisplay(id) { + let el = document.getElementById(id); + let el_cs = getComputedStyle(el); + + if (el_cs.getPropertyValue('display') === 'none') { + el.style.display = 'inline'; + } else { + el.style.display = 'none'; + } + } + + function hideAllClass(classname) { + + const el = document.getElementsByClassName(classname); + + for(let i = 0; i < el.length ; i++) { + el[i].style.display = ''; + } + } + + function showSelect(selectId, prefix, hideClass = '') { + if(hideClass != '') { + hideAllClass(hideClass); + } + let selVal = document.getElementById(selectId).value; + toggleDisplay(prefix + selVal); + })"; + +void WebFile_cangrow_JS(AsyncWebServerRequest *request) { + request->send_P(200, "text/css", File_cangrow_JS); +} diff --git a/Arduino/CanGrow/include/Webserver/Header.h b/Arduino/CanGrow/include/Webserver/Header.h index 8cbfdd9..ed16db1 100644 --- a/Arduino/CanGrow/include/Webserver/Header.h +++ b/Arduino/CanGrow/include/Webserver/Header.h @@ -34,6 +34,7 @@ const char* Header_HTML PROGMEM = R"(