Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
5.8 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>{appname} - Configuration</title>
  5. <meta charset="utf-8" />
  6. <link rel="stylesheet" href="index.css" />
  7. <script src="jquery-1.12.3.min.js"></script>
  8. <script>
  9. $(function() {
  10. var updateInterval = 1000;
  11. $("#config").submit(function(event) {
  12. $(":submit").prop("value", "Wait...").attr("disabled", true);
  13. $.ajax({
  14. 'method': 'POST',
  15. 'url': '/save',
  16. 'dataType': 'json',
  17. 'data': $(this).serializeArray()
  18. }).done(function(data) {
  19. $(":submit").prop("value", "Connect").removeAttr("disabled");
  20. }).fail(function() {
  21. $(":submit").prop("value", "Connect").removeAttr("disabled");
  22. });
  23. event.preventDefault();
  24. });
  25. function update() {
  26. $.ajax({
  27. 'method': 'GET',
  28. 'url': '/status',
  29. 'dataType': 'json'
  30. }).done(function(data) {
  31. $("span.device").html(data.device);
  32. $("span.network").html(data.network.toUpperCase());
  33. $("span.ip").html(data.ip);
  34. $("span.mqtt").html(data.mqtt ? "CONNECTED" : "NOT CONNECTED");
  35. $("span.relay").html(data.relay ? "ON" : "OFF");
  36. updateInterval = parseInt(data.interval);
  37. setTimeout(update, updateInterval);
  38. }).fail(function() {
  39. setTimeout(update, updateInterval);
  40. });
  41. }
  42. update();
  43. });
  44. </script>
  45. </head>
  46. <body>
  47. <form id="config" action="/" method="post">
  48. <header>
  49. <h2>{appname} - Configuration</h2>
  50. <div>This form lets you define the WIFI network this device should try to join.</div>
  51. </header>
  52. <div>
  53. <p>Device: <span class="device"></span></p>
  54. <p>Network: <span class="network"></span></p>
  55. <p>IP: <span class="ip"></span></p>
  56. <p>MQTT: <span class="mqtt"></span></p>
  57. <p>Relay: <span class="relay"></span></p>
  58. </div>
  59. <div>
  60. <label class="desc" for="ssid0">Network SSID 0</label>
  61. <div>
  62. <input id="ssid0" name="ssid0" type="text" class="field text fn" value="{ssid0}" size="8" tabindex="1">
  63. </div>
  64. </div>
  65. <div>
  66. <label class="desc" for="pass0">Network Password 0</label>
  67. <div>
  68. <input id="pass0" name="pass0" type="text" spellcheck="false" value="{pass0}" maxlength="255" tabindex="2">
  69. </div>
  70. </div>
  71. <div>
  72. <label class="desc" for="ssid1">Network SSID 1</label>
  73. <div>
  74. <input id="ssid1" name="ssid1" type="text" class="field text fn" value="{ssid1}" size="8" tabindex="3">
  75. </div>
  76. </div>
  77. <div>
  78. <label class="desc" for="pass1">Network Password 1</label>
  79. <div>
  80. <input id="pass1" name="pass1" type="text" spellcheck="false" value="{pass1}" maxlength="255" tabindex="4">
  81. </div>
  82. </div>
  83. <div>
  84. <label class="desc" for="ssid2">Network SSID 2</label>
  85. <div>
  86. <input id="ssid2" name="ssid2" type="text" class="field text fn" value="{ssid2}" size="8" tabindex="5">
  87. </div>
  88. </div>
  89. <div>
  90. <label class="desc" for="pass2">Network Password 2</label>
  91. <div>
  92. <input id="pass2" name="pass2" type="text" spellcheck="false" value="{pass2}" maxlength="255" tabindex="6">
  93. </div>
  94. </div>
  95. <div>
  96. <label class="desc" for="mqtt_server">MQTT Server</label>
  97. <div>
  98. <input id="mqtt_server" name="mqtt_server" type="text" class="field text fn" value="{mqtt_server}" size="8" tabindex="7">
  99. </div>
  100. </div>
  101. <div>
  102. <label class="desc" for="mqtt_port">MQTT Port</label>
  103. <div>
  104. <input id="mqtt_port" name="mqtt_port" type="text" spellcheck="false" value="{mqtt_port}" maxlength="255" tabindex="8">
  105. </div>
  106. </div>
  107. <div>
  108. <label class="desc" for="mqtt_topic">MQTT Topic</label>
  109. <div>
  110. <input id="mqtt_topic" name="mqtt_topic" type="text" class="field text fn" value="{mqtt_topic}" size="8" tabindex="9">
  111. </div>
  112. </div>
  113. <div>
  114. <label class="desc" for="mqtt_port">RF Channel</label>
  115. <div>
  116. <input id="rf_channel" name="rf_channel" type="text" spellcheck="false" value="{rf_channel}" maxlength="255" tabindex="8">
  117. </div>
  118. </div>
  119. <div>
  120. <label class="desc" for="mqtt_topic">RF Device</label>
  121. <div>
  122. <input id="rf_device" name="rf_device" type="text" class="field text fn" value="{rf_device}" size="8" tabindex="9">
  123. </div>
  124. </div>
  125. <div>
  126. <div>
  127. <input id="submit" name="submit" type="submit" value="Connect">
  128. </div>
  129. </div>
  130. </form>
  131. </body>
  132. </html>