/* xdrv_02_webserver.ino - webserver for Sonoff-Tasmota Copyright (C) 2018 Theo Arends This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifdef USE_WEBSERVER /*********************************************************************************************\ * Web server and WiFi Manager * * Enables configuration and reconfiguration of WiFi credentials using a Captive Portal * Based on source by AlexT (https://github.com/tzapu) \*********************************************************************************************/ #ifdef USE_RF_FLASH uint8_t *efm8bb1_update = NULL; #endif // USE_RF_FLASH enum UploadTypes { UPL_TASMOTA, UPL_SETTINGS, UPL_EFM8BB1 }; const char HTTP_HEAD[] PROGMEM = "" "" "" "" "{h} - {v}" "" "" "" "" "
" #ifdef BE_MINIMAL "

" D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "

" #endif #ifdef LANGUAGE_MODULE_NAME "

" D_MODULE " {ha

{h}

"; #else "

{ha " D_MODULE "

{h}

"; #endif const char HTTP_SCRIPT_CONSOL[] PROGMEM = "var sn=0;" // Scroll position "var id=0;" // Get most of weblog initially "function l(p){" // Console log and command service "var c,o,t;" "clearTimeout(lt);" "o='';" "t=eb('t1');" "if(p==1){" "c=eb('c1');" "o='&c1='+encodeURIComponent(c.value);" "c.value='';" "t.scrollTop=sn;" "}" "if(t.scrollTop>=sn){" // User scrolled back so no updates "if(x!=null){x.abort();}" // Abort if no response within 2 seconds (happens on restart 1) "x=new XMLHttpRequest();" "x.onreadystatechange=function(){" "if(x.readyState==4&&x.status==200){" "var z,d;" "d=x.responseXML;" "id=d.getElementsByTagName('i')[0].childNodes[0].nodeValue;" "if(d.getElementsByTagName('j')[0].childNodes[0].nodeValue==0){t.value='';}" "z=d.getElementsByTagName('l')[0].childNodes;" "if(z.length>0){t.value+=decodeURIComponent(z[0].nodeValue);}" "t.scrollTop=99999;" "sn=t.scrollTop;" "}" "};" "x.open('GET','ax?c2='+id+o,true);" "x.send();" "}" "lt=setTimeout(l,2345);" "return false;" "}" ""; const char HTTP_SCRIPT_MODULE1[] PROGMEM = "var os;" "function sk(s,g){" "var o=os.replace(\"value='\"+s+\"'\",\"selected value='\"+s+\"'\");" "eb('g'+g).innerHTML=o;" "}" "function sl(){" "var o0=\""; const char HTTP_SCRIPT_MODULE2[] PROGMEM = "}1'%d'>%02d %s}2"; // "}1" and "}2" means do not use "}x" in Module name and Sensor name const char HTTP_SCRIPT_MODULE3[] PROGMEM = "\";" "os=o0.replace(/}1/g,\"