123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- static const char html_confdev_script[] PROGMEM = R"=====(
- <script>
- function g(i) { return document.getElementById(i) };
- function sp(i){g(i).type=(g(i).type==='text'?'password':'text');}
- var xhttp, reqTime, reqFin;
- function setCbx(el, da) {
- if(da == '1') {
- el.checked = true;
- el.style.visibility = 'visible';
- }
- else {
- el.checked = false;
- el.style.visibility = 'visible';
- }
- }
- function updCbxVal(el) {
- if (el.checked) el.value = '1';
- else {
- el.checked = true;
- el.value = '0';
- el.style.visibility = 'hidden';
- }
- }
-
- function transmit(f) {
- if (!xhttp) {
- reqTime = 0;
- reqFin = false;
- xhttp = new XMLHttpRequest();
- xhttp.timeout = 1000;
- xhttp.overrideMimeType('application/json');
- xhttp.open('POST', 'confddev');
- xhttp.send(f ? (new FormData(f)) : '');
- xhttp.onreadystatechange = function () {
- if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
- var data = JSON.parse(xhttp.responseText);
- g('devName').value = data.devName;
- g('hostName').value = data.hostName;
- g('wifiappw').value = data.wifiappw;
- xhttp = null;
- reqFin = true;
- }
- else {
- if(!reqFin && reqTime > 10) {
- xhttp = null;
- reqFin = true;
- }
- }
- }
- }
- return false;
- }
- //transmit();
- function saveConf() {
- g('frmConf').submit();
- }
- function init() {
- transmit();
- setCbx(g('wifiappwSet'), 0);
- }
- setInterval(function () { ++reqTime; }, 1000);
- </script>
- )====="; // html_confdev_script
- static const char html_confdev_body[] PROGMEM = R"=====(
- <b>Configuration - Device</b>
- <div class='config'>
- <form id='frmConf' action='setConfDev' method='POST'>
- <br>
- <fieldset>
- <legend>Device</legend>
- <p><b>Device Name *</b><br><input type='text' name='devName' id='devName'></p>
- <p><b>Hostname *</b><br><input type='text' name='hostName' id='hostName'></p>
- <p><b>WiFi AP Password *</b><input type='checkbox' id='wifiappwSet' name='wifiappwSet' onclick='sp("wifiappw")'><br><input type='password' name='wifiappw' id='wifiappw'></p>
- </fieldset>
- <br>
- </form>
- <div></div>
- <table style='width:100%'>
- <td style='width:50%'><button onclick='location="conf";' class='bgrey'>Cancel</button></td>
- <td style='width:50%'><button onclick='return saveConf()' class='bred'>Save</button></td>
- </tr></table>
- </div>
- )====="; // html_confdev_body
|