relay.std.hd.com.imuslab.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <html>
  2. <head>
  3. <title>relay_std_driver</title>
  4. <script src="jquery.min.js"></script>
  5. <style>
  6. #button{
  7. background-color:#262626;
  8. }
  9. .center{
  10. position: fixed;
  11. width: 40%;
  12. top:50%;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <div id="ipv4" style="position:fixed;top:10px;left:10px;z-index:10;color:white;"><?php echo $_GET['ip'];?></div>
  18. <div id="button" style="width:100%;height:100%;position:fixed;left:0px;top:0px;" onClick="toggleSwitch();">
  19. <img id="icon" class="center" src="img/default_transparent.png"></img>
  20. </div>
  21. <div id="uuid" style="position:fixed;bottom:10px;left:10px;color:white;"></div>
  22. <script>
  23. status();
  24. uuid();
  25. var uuid = "";
  26. var currentStatus = "OFF";
  27. moveIcon();
  28. function status(){
  29. $.ajax({url: "http://<?php echo $_GET['ip'];?>/status",
  30. success: function(result){
  31. $("#status").html(result);
  32. if (result == "ON"){
  33. $("#button").css("background-color","#00cccc");
  34. currentStatus = "ON";
  35. }else{
  36. $("#button").css("background-color","#262626");
  37. currentStatus = "OFF";
  38. }
  39. }});
  40. }
  41. function moveIcon(){
  42. $("#icon").css("top",(window.innerHeight /2 - $("#icon").height() / 2) + "px");
  43. $("#icon").css("left",(window.innerWidth /2 - $("#icon").width() / 2) + "px");
  44. }
  45. function toggleSwitch(){
  46. if (currentStatus == "OFF"){
  47. on();
  48. }else{
  49. off();
  50. }
  51. }
  52. function off(){
  53. $.ajax({url: "http://<?php echo $_GET['ip'];?>/off", success: function(result){
  54. status();
  55. }});
  56. }
  57. function on(){
  58. $.ajax({url: "http://<?php echo $_GET['ip'];?>/on", success: function(result){
  59. status();
  60. }});
  61. }
  62. function uuid(){
  63. $.ajax({url: "http://<?php echo $_GET['ip'];?>/uuid", success: function(result){
  64. $("#uuid").text(result);
  65. uuid = result;
  66. }});
  67. }
  68. </script>
  69. </body>
  70. </html>