redTemps 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. var xhttp, updateTime, reqTime, reqFin;
  8. function sendBtn(btn, conf) {
  9. var frmn='BtnFrm'+btn;
  10. var form = g(frmn);
  11. if(conf !== undefined) {
  12. if(confirm(conf)) return transmit(form);
  13. else return false;
  14. }
  15. else return transmit(form);
  16. }
  17. function transmit(f) {
  18. if (!xhttp) {
  19. reqTime = 0;
  20. reqFin = false;
  21. xhttp = new XMLHttpRequest();
  22. xhttp.timeout = 1000;
  23. xhttp.overrideMimeType("application/json");
  24. xhttp.open('POST', 'api');
  25. xhttp.send(f ? (new FormData(f)) : '');
  26. xhttp.onreadystatechange = function () {
  27. if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
  28. var data = JSON.parse(xhttp.responseText);
  29. if(data.tempLow !== undefined) g('tempLow').innerHTML = data.tempLow.toFixed(1) + '&deg;';
  30. if(data.tempLow2 !== undefined) g('tempLow2').innerHTML = data.tempLow2.toFixed(1) + '&deg;';
  31. xhttp = null;
  32. updateTime = 0;
  33. reqFin = true;
  34. }
  35. else {
  36. if(!reqFin && reqTime > 10) {
  37. xhttp = null;
  38. reqFin = true;
  39. }
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. function init() {
  46. transmit();
  47. }
  48. setInterval(transmit, 2500);
  49. </script>
  50. </head>
  51. <body onload='init()'>
  52. <div id='main'>
  53. <div id='head'>WiFiThermostat - WTherm-3598
  54. </div><hr>
  55. <div></div>
  56. <p><b>Reduction 1 - Temperature</b></p>
  57. <div id='tempLow' style='text-align:center;font-weight:bold;font-size:40px'></div>
  58. <div></div>
  59. <table style='width:100%'><tr>
  60. <td style='width:50%'><form id='BtnFrmL1Minus'><input type='hidden' name='BtnL1Minus' value='1'><button onclick='return sendBtn("L1Minus")'>-</button></form></td>
  61. <td style='width:50%'><form id='BtnFrmL1Plus'><input type='hidden' name='BtnL1Plus' value='1'><button onclick='return sendBtn("L1Plus")'>+</button></form></td>
  62. </tr></table>
  63. <p><b>Reduction 2 - Temperature</b></p>
  64. <div id='tempLow2' style='text-align:center;font-weight:bold;font-size:40px'></div>
  65. <div></div>
  66. <table style='width:100%'><tr>
  67. <td style='width:50%'><form id='BtnFrmL2Minus'><input type='hidden' name='BtnL2Minus' value='1'><button onclick='return sendBtn("L2Minus")'>-</button></form></td>
  68. <td style='width:50%'><form id='BtnFrmL2Plus'><input type='hidden' name='BtnL2Plus' value='1'><button onclick='return sendBtn("L2Plus")'>+</button></form></td>
  69. </tr></table>
  70. <div></div>
  71. <table style='width:100%'><tr>
  72. <td style='width:100%'><form action='.' method='get'><button class='bgrey'>Main Menu</button></form></td>
  73. </tr></table>
  74. <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>
  75. </div></body></html>