confweb 5.1 KB

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