conftime 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <html><head>
  2. <meta charset='utf-8'><meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'/>
  3. <link rel='stylesheet' href='style.css'>
  4. <title>WiFiThermostat - WTherm-3598</title>
  5. <script>
  6. function g(i) { return document.getElementById(i) };
  7. function sp(i){g(i).type=(g(i).type==='text'?'password':'text');}
  8. var xhttp, reqTime, reqFin;
  9. function setCbx(el, da) {
  10. if(da == '1') {
  11. el.checked = true;
  12. el.style.visibility = 'visible';
  13. }
  14. else {
  15. el.checked = false;
  16. el.style.visibility = 'visible';
  17. }
  18. }
  19. function updCbxVal(el) {
  20. if (el.checked) el.value = '1';
  21. else {
  22. el.checked = true;
  23. el.value = '0';
  24. el.style.visibility = 'hidden';
  25. }
  26. }
  27. function transmit(f) {
  28. if (!xhttp) {
  29. reqTime = 0;
  30. reqFin = false;
  31. updCbxVal(g('NTPEnable'));
  32. xhttp = new XMLHttpRequest();
  33. xhttp.timeout = 1000;
  34. xhttp.overrideMimeType('application/json');
  35. xhttp.open('POST', 'confDataTime');
  36. xhttp.send(f ? (new FormData(f)) : '');
  37. xhttp.onreadystatechange = function () {
  38. if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
  39. var data = JSON.parse(xhttp.responseText);
  40. setCbx(g('NTPEnable'), data.NTPEnable);
  41. g('NTPServer1').value = data.NTPServer1;
  42. g('NTPServer2').value = data.NTPServer2;
  43. g('TZStr').value = data.TZStr;
  44. g('NTPSyncInt').value = data.NTPSyncInt;
  45. xhttp = null;
  46. reqFin = true;
  47. }
  48. else {
  49. if(!reqFin && reqTime > 10) {
  50. xhttp = null;
  51. reqFin = true;
  52. }
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. //transmit();
  59. function saveConf() {
  60. updCbxVal(g('NTPEnable'));
  61. g('frmConf').submit();
  62. }
  63. function init() {
  64. transmit();
  65. }
  66. setInterval(function () { ++reqTime; }, 1000);
  67. </script>
  68. </head>
  69. <body onload='init()'>
  70. <div id='main'>
  71. <div id='head'>WiFiThermostat - WTherm-3598
  72. </div><hr>
  73. <div></div>
  74. <b>Configuration - Date &amp; Time</b>
  75. <div class='config'>
  76. <form id='frmConf' action='setConfTime' method='POST'>
  77. <br>
  78. <fieldset>
  79. <legend>NTP-Server</legend>
  80. <p><b>Enable NTP Time Sync</b>&nbsp;<input type='checkbox' name='NTPEnable' id='NTPEnable'></p>
  81. <p><b>NTP Server 1</b><br><input type='text' name='NTPServer1' id='NTPServer1'></p>
  82. <p><b>NTP Server 2</b><br><input type='text' name='NTPServer2' id='NTPServer2'></p>
  83. <p><b>Timezone String</b><br><input type='text' name='TZStr' id='TZStr'></p>
  84. <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>
  85. <p><b>NTP Sync Interval [m]</b><br><input type='text' name='NTPSyncInt' id='NTPSyncInt'></p>
  86. </fieldset>
  87. <div></div><br>
  88. </form>
  89. <div></div>
  90. <table style='width:100%'>
  91. <td style='width:50%'><button onclick='location="conf";' class='bgrey'>Cancel</button></td>
  92. <td style='width:50%'><button onclick='return saveConf()' class='bred'>Save</button></td>
  93. </tr></table>
  94. </div>
  95. <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>
  96. </div></body></html>