confadd 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. xhttp = new XMLHttpRequest();
  32. xhttp.timeout = 1000;
  33. xhttp.overrideMimeType('application/json');
  34. xhttp.open('POST', 'confDataAdd');
  35. xhttp.send(f ? (new FormData(f)) : '');
  36. xhttp.onreadystatechange = function () {
  37. if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
  38. var data = JSON.parse(xhttp.responseText);
  39. g('PIRTop').value = data.PIRTop;
  40. g('PIROnPld').value = data.PIROnPld;
  41. g('PIROffPld').value = data.PIROffPld;
  42. g('outTempTop').value = data.outTempTop;
  43. g('outHumTop').value = data.outHumTop;
  44. xhttp = null;
  45. reqFin = true;
  46. }
  47. else {
  48. if(!reqFin && reqTime > 10) {
  49. xhttp = null;
  50. reqFin = true;
  51. }
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. //transmit();
  58. function saveConf() {
  59. g('frmConf').submit();
  60. }
  61. function init() {
  62. transmit();
  63. }
  64. setInterval(function () { ++reqTime; }, 1000);
  65. </script>
  66. </head>
  67. <body onload='init()'>
  68. <div id='main'>
  69. <div id='head'>WiFiThermostat - WTherm-T5WZ
  70. </div><hr>
  71. <div></div>
  72. <b>Configuration - Additional Functions</b>
  73. <div class='config'>
  74. <form id='frmConf' action='setConfAdd' method='POST'>
  75. <br>
  76. <fieldset>
  77. <legend>PIR Sensor</legend>
  78. <p><b>MQTT Publish Topic</b><br><input type='text' name='PIRTop' id='PIRTop'/></p>
  79. <p><b>MQTT ON Payload</b><br><input type='text' name='PIROnPld' id='PIROnPld'/></p>
  80. <p><b>MQTT OFF Payload</b><br><input type='text' name='PIROffPld' id='PIROffPld'/></p>
  81. </fieldset>
  82. <div></div><br>
  83. <fieldset>
  84. <legend>Outside Temp/Hum via MQTT</legend>
  85. <p class='n'>Only used if not empty, can be subscribed to and valid data is sent. </p>
  86. <p><b>O-Temp In-Topic</b><br><input type='text' name='outTempTop' id='outTempTop'/></p>
  87. <p><b>O-Hum In-Topic</b><br><input type='text' name='outHumTop' id='outHumTop'/><br>
  88. </fieldset>
  89. <br>
  90. </form>
  91. <div></div>
  92. <table style='width:100%'>
  93. <td style='width:50%'><button onclick='location="conf";' class='bgrey'>Cancel</button></td>
  94. <td style='width:50%'><button onclick='return saveConf()' class='bred'>Save</button></td>
  95. </tr></table>
  96. </div>
  97. <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>
  98. </div></body></html>