Smart_Home is a home automation project suited for ESP boards family (including NodeMCU). It supports PWA; supports tons of sensors; has modern and elegant UI; is easily customizable; is multilangual.
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.

255 lines
7.0 KiB

1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <pre>
  2. <?php
  3. var_dump($_POST);
  4. var_dump(file_exists("./app/updater/" . "3C71BF22FDCF" . ".bin"));
  5. ?>
  6. </pre>
  7. <form class="" action="" method="post">
  8. <label for="operator">Typ podmínky</label>
  9. <select class="" name="operator">
  10. <option value="or">OR</option>
  11. <option value="and">AND</option>
  12. </select>
  13. <div class="variableArea">
  14. <button name="addButton" id="addButton">+</button>
  15. </div>
  16. <br>
  17. <label for="resetOperator">Typ podmínky</label>
  18. <select class="" name="resetOperator">
  19. <option value="or">OR</option>
  20. <option value="and">AND</option>
  21. </select>
  22. <div class="resetvariableArea">
  23. <button name="restartaAddButton" id="restartAddButton">+</button>
  24. </div>
  25. <br>
  26. <button type="submit" name="button">Odeslat</button>
  27. </form>
  28. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  29. <script type="text/javascript">
  30. function foo(element){
  31. var id = element.attr("name").match(/\d+/)[0]
  32. $("[name='variable["+id+"][value]']").remove();
  33. $("[name='variable["+id+"][equaler]']").remove();
  34. if (element.val() == "atDeviceValue") {
  35. var arrVarOperator = [
  36. {val : '>', text: '>'},
  37. {val : '<', text: '<'},
  38. ];
  39. var varOperator = $('<select name="variable['+id+'][equaler]">');
  40. $(arrVarOperator).each(function() {
  41. varOperator.append($('<option>').attr('value',this.val).text(this.text));
  42. });
  43. element.parent().append(varOperator);
  44. var input = $("<input/>");
  45. input.attr("type","text");
  46. input.attr("name","variable["+id+"][value]");
  47. element.parent().append(input);
  48. } else if (element.val() == "time") {
  49. var arrVarOperator = [
  50. {val : '>', text: '>'},
  51. {val : '<', text: '<'},
  52. ];
  53. var varOperator = $('<select name="variable['+id+'][equaler]">');
  54. $(arrVarOperator).each(function() {
  55. varOperator.append($('<option>').attr('value',this.val).text(this.text));
  56. });
  57. element.parent().append(varOperator);
  58. var input = $("<input/>");
  59. input.attr("type","time");
  60. input.attr("name","variable["+id+"][value]");
  61. element.parent().append(input);
  62. }else {
  63. var arrVarOperator = [
  64. {val : '=', text: '=='},
  65. {val : '!=', text: '!='},
  66. ];
  67. var varOperator = $('<select name="variable['+id+'][equaler]">');
  68. $(arrVarOperator).each(function() {
  69. varOperator.append($('<option>').attr('value',this.val).text(this.text));
  70. });
  71. element.parent().append(varOperator);
  72. var arrVarValue = [
  73. {val : 'true', text: 'True'},
  74. {val : 'false', text: 'False'},
  75. ];
  76. var varValue = $('<select name="variable['+id+'][value]">');
  77. $(arrVarValue).each(function() {
  78. varValue.append($('<option>').attr('value',this.val).text(this.text));
  79. });
  80. element.parent().append(varValue);
  81. }
  82. }
  83. $("#addButton,#restartAddButton").click( function (event) {
  84. event.preventDefault();
  85. var numItems = $('.var').length
  86. var arrVarSelect = [
  87. {val : 'sunSet', text: 'Západ Slunce'},
  88. {val : 'sunRise', text: 'Východ Slunce'},
  89. {val : 'inHome', text: 'Příchod'},
  90. {val : 'outHome', text: 'Odchod'},
  91. {val : 'time', text: 'Čas'},
  92. {val : 'atDeviceValue', text: 'Při hodnotě zařízení'},
  93. {val : 'sunRise', text: 'Východ Slunce'},
  94. {val : 'noOneHome', text: 'Nikdo Doma'},
  95. {val : 'someOneHome', text: 'Nekdo Doma'},
  96. ];
  97. var varSelect = $('<select name="variable['+numItems+'][what]">');
  98. $(arrVarSelect).each(function() {
  99. varSelect.append($('<option>').attr('value',this.val).text(this.text));
  100. });
  101. varSelect.attr("onchange", "foo($(this))");
  102. /*onchange = function(e) {
  103. console.log(this.value);
  104. if (this.value == 'atDeviceValue') {
  105. alert("ok");
  106. }
  107. };*/
  108. var arrVarOperator = [
  109. {val : '>', text: '>'},
  110. {val : '<', text: '<'},
  111. {val : '=', text: '=='},
  112. {val : '!=', text: '!='},
  113. ];
  114. var varOperator = $('<select name="variable['+numItems+'][equaler]">');
  115. $(arrVarOperator).each(function() {
  116. varOperator.append($('<option>').attr('value',this.val).text(this.text));
  117. });
  118. var arrVarValue = [
  119. {val : 'true', text: 'True'},
  120. {val : 'false', text: 'False'},
  121. ];
  122. var varValue = $('<select name="variable['+numItems+'][value]">');
  123. $(arrVarValue).each(function() {
  124. varValue.append($('<option>').attr('value',this.val).text(this.text));
  125. });
  126. var newDiv = $("<div class=var>").append(varSelect);
  127. newDiv = newDiv.append(varOperator);
  128. newDiv = newDiv.append(varValue);
  129. $(this).parent().append(newDiv);
  130. });
  131. /*var arrVarSelect = [
  132. {val : 'sunSet', text: 'Západ Slunce'},
  133. {val : 'sunRise', text: 'Východ Slunce'},
  134. {val : 'inHome', text: 'Příchod'},
  135. {val : 'outHome', text: 'Odchod'},
  136. {val : 'time', text: 'Čas'},
  137. {val : 'atDeviceValue', text: 'Při hodnotě zařízení'},
  138. {val : 'sunRise', text: 'Východ Slunce'},
  139. {val : 'noOneHome', text: 'Nikdo Doma'},
  140. {val : 'someOneHome', text: 'Nekdo Doma'},
  141. ];
  142. var varSelect = $('<select name="variable['+numItems+'][]">');
  143. $(arrVarSelect).each(function() {
  144. varSelect.append($('<option>').attr('value',this.val).text(this.text));
  145. });
  146. var arrVarOperator = [
  147. {val : '>', text: '>'},
  148. {val : '<', text: '<'},
  149. {val : '=', text: '=='},
  150. {val : '!=', text: '!='},
  151. ];
  152. var varOperator = $('<select name="variable['+numItems+'][]">');
  153. $(arrVarOperator).each(function() {
  154. varOperator.append($('<option>').attr('value',this.val).text(this.text));
  155. });
  156. var arrVarValue = [
  157. {val : 'true', text: 'True'},
  158. {val : 'false', text: 'False'},
  159. ];
  160. var varValue = $('<select name="variable['+numItems+'][]">');
  161. $(arrVarValue).each(function() {
  162. varValue.append($('<option>').attr('value',this.val).text(this.text));
  163. });
  164. //TODO změna výstupní proměné na základě vstupu date,num etc
  165. var newDiv = $("<div class=var>").append(varSelect);/*.change(
  166. function (subEvent) {
  167. alert(subEvent);
  168. }
  169. );*/
  170. /*newDiv = newDiv.append(varOperator);
  171. newDiv = newDiv.append(varValue);
  172. $(".restartaAddButton")append(newDiv);*/
  173. /*
  174. var arrVarSelect = [
  175. {val : 'sunSet', text: 'Západ Slunce'},
  176. {val : 'sunRise', text: 'Východ Slunce'},
  177. {val : 'inHome', text: 'Příchod'},
  178. {val : 'outHome', text: 'Odchod'},
  179. {val : 'time', text: 'Čas'},
  180. {val : 'atDeviceValue', text: 'Při hodnotě zařízení'},
  181. {val : 'sunRise', text: 'Východ Slunce'},
  182. {val : 'noOneHome', text: 'Nikdo Doma'},
  183. {val : 'someOneHome', text: 'Nekdo Doma'},
  184. ];
  185. var varSelect = $('<select name="variable['+numItems+'][]">');
  186. $(arrVarSelect).each(function() {
  187. varSelect.append($('<option>').attr('value',this.val).text(this.text));
  188. });
  189. var arrVarOperator = [
  190. {val : '>', text: '>'},
  191. {val : '<', text: '<'},
  192. {val : '=', text: '=='},
  193. {val : '!=', text: '!='},
  194. ];
  195. var varOperator = $('<select name="variable['+numItems+'][]">');
  196. $(arrVarOperator).each(function() {
  197. varOperator.append($('<option>').attr('value',this.val).text(this.text));
  198. });
  199. var arrVarValue = [
  200. {val : 'true', text: 'True'},
  201. {val : 'false', text: 'False'},
  202. ];
  203. var varValue = $('<select name="variable['+numItems+'][]">');
  204. $(arrVarValue).each(function() {
  205. varValue.append($('<option>').attr('value',this.val).text(this.text));
  206. });
  207. //TODO změna výstupní proměné na základě vstupu date,num etc
  208. var newDiv = $("<div class=var>").append(varSelect);/*.change(
  209. function (subEvent) {
  210. alert(subEvent);
  211. }
  212. );*/
  213. /* newDiv = newDiv.append(varOperator);
  214. newDiv = newDiv.append(varValue);
  215. $(".variableArea").parent().append(newDiv);*/
  216. </script>