<html><head>
<meta charset='utf-8'><meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'/>
<link rel='stylesheet' href='style.css'>
<title>WiFiThermostat - WTherm-3598</title>
<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>
</head>
<body onload='init()'>
<div id='main'>
<div id='head'>WiFiThermostat - WTherm-3598
</div><hr>
<div></div>
<b>Configuration - Date &amp; 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>&nbsp;<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 target='_blank' href='https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv'>zones.csv</a></p>
<p><b>NTP Sync Interval [m]</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>

<div style='text-align:right;font-size:0.7em;color:#AAA;'><hr/><a href='https://git.flokra.at/flo/WiFiThermostat' target='_blank' style='color:#AAA;'>WiFiThermostat</a> 0.6.1 by <a href='https://www.flokra.at/' target='_blank' style='color:#AAA;'>FloKra</a></div>
</div></body></html>