Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
2,262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.77 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
  4. <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  5. <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
  6. <script>
  7. var stepr1;
  8. var stepr2;
  9. var stepr3;
  10. var stepr4;
  11. var intervalr1;
  12. var intervalr2;
  13. var intervalr3;
  14. var intervalr4;
  15. var thatr1;
  16. var thatr2;
  17. var thatr3;
  18. var thatr4;
  19.  
  20. $(document).ready(function() {
  21.  
  22.     $("#relay-1").click(function() {
  23.         thatr1 = this;
  24.         stepr1 = 4;
  25.         $(thatr1).button("option", "disabled", true);
  26.         $(thatr1).val("....5");
  27.         $(thatr1).button("refresh");
  28.         intervalr1 = setInterval(funcr1, 1000);
  29.  
  30.         $.post("/gpio31");
  31.     });
  32.  
  33.     $("#relay-2").click(function() {
  34.         thatr2 = this;
  35.         stepr2 = 4;
  36.         $(thatr2).button("option", "disabled", true);
  37.         $(thatr2).val("....5");
  38.         $(thatr2).button("refresh");
  39.         intervalr2 = setInterval(funcr2, 1000);
  40.  
  41.         $.post("/gpio33");
  42.     });
  43.  
  44.     $("#relay-3").click(function() {
  45.         thatr3 = this;
  46.         stepr3 = 4;
  47.         $(thatr3).button("option", "disabled", true);
  48.         $(thatr3).val("....5");
  49.         $(thatr3).button("refresh");
  50.         intervalr3 = setInterval(funcr3, 1000);
  51.  
  52.         $.post("/gpio35");
  53.     });
  54.  
  55.     $("#relay-4").click(function() {
  56.         thatr4 = this;
  57.         stepr4 = 4;
  58.         $(thatr4).button("option", "disabled", true);
  59.         $(thatr4).val("....5");
  60.         $(thatr4).button("refresh");
  61.         intervalr4 = setInterval(funcr4, 1000);
  62.  
  63.         $.post("/gpio37");
  64.     });
  65.  
  66.     function funcr1() {
  67.         switch(stepr1) {
  68.             case 0:
  69.                 $(thatr1).val("5 sec");
  70.                 $(thatr1).button("option", "disabled", false);
  71.                 $(thatr1).button("refresh");
  72.                 clearInterval(intervalr1);
  73.                 break;
  74.             default:
  75.                 $(thatr1).val("...." + stepr1);
  76.                 $(thatr1).button("refresh");
  77.                 stepr1--;
  78.         }
  79.     }
  80.  
  81.     function funcr2() {
  82.         switch(stepr2) {
  83.             case 0:
  84.                 $(thatr2).val("5 sec");
  85.                 $(thatr2).button("option", "disabled", false);
  86.                 $(thatr2).button("refresh");
  87.                 clearInterval(intervalr2);
  88.                 break;
  89.             default:
  90.                 $(thatr2).val("...." + stepr2);
  91.                 $(thatr2).button("refresh");
  92.                 stepr2--;
  93.         }
  94.     }
  95.  
  96.     function funcr3() {
  97.         switch(stepr3) {
  98.             case 0:
  99.                 $(thatr3).val("5 sec");
  100.                 $(thatr3).button("option", "disabled", false);
  101.                 $(thatr3).button("refresh");
  102.                 clearInterval(intervalr3);
  103.                 break;
  104.             default:
  105.                 $(thatr3).val("...." + stepr3);
  106.                 $(thatr3).button("refresh");
  107.                 stepr3--;
  108.         }
  109.     }
  110.  
  111.     function funcr4() {
  112.         switch(stepr4) {
  113.             case 0:
  114.                 $(thatr4).val("5 sec");
  115.                 $(thatr4).button("option", "disabled", false);
  116.                 $(thatr4).button("refresh");
  117.                 clearInterval(intervalr4);
  118.                 break;
  119.             default:
  120.                 $(thatr4).val("...." + stepr4);
  121.                 $(thatr4).button("refresh");
  122.                 stepr4--;
  123.         }
  124.     }  
  125. });
  126. </script>
  127. </head>
  128. <body>
  129. <input id="relay-1" type="button" value="5 sec" data-inline="true" /><br />
  130. <input id="relay-2" type="button" value="5 sec" data-inline="true" /><br />
  131. <input id="relay-3" type="button" value="5 sec" data-inline="true" /><br />
  132. <input id="relay-4" type="button" value="5 sec" data-inline="true" /><br />
  133. </body>
  134. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement