123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /* clang-format off */
- static const char html_conftime_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;
- updCbxVal(g('NTPEnable'));
- xhttp = new XMLHttpRequest();
- xhttp.timeout = 1000;
- xhttp.overrideMimeType('application/json');
- xhttp.open('POST', 'confDataTime');
- xhttp.send(f ? (new FormData(f)) : '');
- xhttp.onreadystatechange = function () {
- if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
- var data = JSON.parse(xhttp.responseText);
- setCbx(g('NTPEnable'), data.NTPEnable);
- g('NTPServer1').value = data.NTPServer1;
- g('NTPServer2').value = data.NTPServer2;
- g('TZStr').value = data.TZStr;
- g('NTPSyncInt').value = data.NTPSyncInt;
- xhttp = null;
- reqFin = true;
- }
- else {
- if(!reqFin && reqTime > 10) {
- xhttp = null;
- reqFin = true;
- }
- }
- }
- }
- return false;
- }
- //transmit();
- function saveConf() {
- updCbxVal(g('NTPEnable'));
- g('frmConf').submit();
- }
- function init() {
- transmit();
- }
- setInterval(function () { ++reqTime; }, 1000);
- </script>
- )====="; // html_conftime_script
- static const char html_conftime_body[] PROGMEM = R"=====(
- <b>Configuration - Date & Time</b>
- <div class='config'>
- <form id='frmConf' action='setConfTime' method='POST'>
- <br>
- <fieldset>
- <legend>NTP-Server</legend>
- <p><b>Enable NTP Time Sync</b> <input type='checkbox' name='NTPEnable' id='NTPEnable'></p>
- <p><b>NTP Server 1</b><br><input type='text' name='NTPServer1' id='NTPServer1'></p>
- <p><b>NTP Server 2</b><br><input type='text' name='NTPServer2' id='NTPServer2'></p>
- <p><b>Timezone String</b><br><input type='text' name='TZStr' id='TZStr'></p>
- <p class='n'>a valid TZ string (right column) from here: <br><a href='https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv'>zones.csv</a></p>
- <p><b>NTP Sync Interval [s]</b><br><input type='text' name='NTPSyncInt' id='NTPSyncInt'></p>
- </fieldset>
- <div></div><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_conftime_body
|