confweb 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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-T5WZ</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('httpAuth'));
  32. updCbxVal(g('enableConsole'));
  33. xhttp = new XMLHttpRequest();
  34. xhttp.timeout = 1000;
  35. xhttp.overrideMimeType('application/json');
  36. xhttp.open('POST', 'confDataWeb');
  37. xhttp.send(f ? (new FormData(f)) : '');
  38. xhttp.onreadystatechange = function () {
  39. if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
  40. var data = JSON.parse(xhttp.responseText);
  41. g('apiToken').value = data.apiToken;
  42. g('httpUA').value = data.httpUA;
  43. g('httpPA').value = data.httpPA;
  44. setCbx(g('httpAuth'), data.httpAuth);
  45. g('httpU1').value = data.httpU1;
  46. g('httpP1').value = data.httpP1;
  47. g('httpU2').value = data.httpU2;
  48. g('httpP2').value = data.httpP2;
  49. setCbx(g('enableConsole'), data.enableConsole);
  50. xhttp = null;
  51. reqFin = true;
  52. }
  53. else {
  54. if(!reqFin && reqTime > 10) {
  55. xhttp = null;
  56. reqFin = true;
  57. }
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. //transmit();
  64. function saveConf() {
  65. updCbxVal(g('httpAuth'));
  66. updCbxVal(g('enableConsole'));
  67. if(g('httpPASet').checked && g('httpPA').value != g('httpPAC').value) {
  68. alert("Admin password verification failed!");
  69. }
  70. else g('frmConf').submit();
  71. }
  72. function init() {
  73. transmit();
  74. setCbx(g('httpPASet'), 0);
  75. setCbx(g('httpP1Set'), 0);
  76. setCbx(g('httpP2Set'), 0);
  77. }
  78. setInterval(function () { ++reqTime; }, 1000);
  79. </script>
  80. </head>
  81. <body onload='init()'>
  82. <div id='main'>
  83. <div id='head'>WiFiThermostat - WTherm-T5WZ
  84. </div><hr>
  85. <div></div>
  86. <p><b>Configuration - Web</b></p>
  87. <div class='config'>
  88. <form id='frmConf' action='setConfWeb' method='POST'>
  89. <fieldset>
  90. <legend>HTTP-API</legend>
  91. <p><b>API Token</b><br><input type='text' name='apiToken' id='apiToken'></p>
  92. </fieldset>
  93. <br>
  94. <fieldset>
  95. <legend>Admin</legend>
  96. <p><b>Set</b>&nbsp;<input type='checkbox' id='httpPASet' name='httpPASet'></p>
  97. <p><b>Username *</b><br><input type='text' name='httpUA' id='httpUA'></p>
  98. <p><b>Password *</b>&nbsp;<input type='checkbox' onclick='sp("httpPA")'>&nbsp;show<br><input type='password' name='httpPA' id='httpPA'></p>
  99. <p><b>Confirm Password *</b><br><input type='password' name='httpPAC' id='httpPAC'></p>
  100. <p class='n'>Admin Password can only be set but is not displayed for security reasons.</p>
  101. </fieldset>
  102. <br>
  103. <fieldset>
  104. <legend>Users</legend>
  105. <p><b>Enable User-Authentication *</b>&nbsp;<input type='checkbox' name='httpAuth' id='httpAuth'></p>
  106. <p class='n'>If User-Auth is off and Admin-PW is set, <br>
  107. Web-Interface can only be accessed by Admin.<br>
  108. Enable User-Auth and set User 1 with emtpy username and password to <br>
  109. make usaccessible without Auth.</p>
  110. <div></div>
  111. <p><b>Set</b>&nbsp;<input type='checkbox' id='httpP1Set' name='httpP1Set'></p>
  112. <p><b>User 1 *</b><br><input type='text' name='httpU1' id='httpU1'></p>
  113. <p><b>User 1 Password *</b>&nbsp;<input type='checkbox' onclick='sp("httpP1")'>&nbsp;show<br><input type='password' name='httpP1' id='httpP1'></p>
  114. <div></div>
  115. <p><b>Set</b>&nbsp;<input type='checkbox' id='httpP2Set' name='httpP2Set'></p>
  116. <p><b>User 2 *</b><br><input type='text' name='httpU2' id='httpU2'></p>
  117. <p><b>User 2 Password *</b>&nbsp;<input type='checkbox' onclick='sp("httpP2")'>&nbsp;show<br><input type='password' name='httpP2' id='httpP2'></p>
  118. </fieldset>
  119. <br>
  120. <fieldset>
  121. <legend>Console</legend>
  122. <p><b>Enable Web-Console (Experimental)</b>&nbsp;<input type='checkbox' name='enableConsole' id='enableConsole'></p>
  123. </fieldset>
  124. </form>
  125. <div></div>
  126. <table style='width:100%'>
  127. <td style='width:50%'><button onclick='location="conf";' class='bgrey'>Cancel</button></td>
  128. <td style='width:50%'><button onclick='return saveConf()' class='bred'>Save</button></td>
  129. </tr></table>
  130. <div></div>
  131. </div>
  132. <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> v0.6.0 by <a href='https://www.flokra.at/' target='_blank' style='color:#AAA;'>FloKra</a></div>
  133. </div></body></html>