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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <html>
  2. <head>
  3. <title>relay_std_driver</title>
  4. <link rel="stylesheet" href="basic/tocas.css">
  5. <script src="basic/jquery.min.js"></script>
  6. <style>
  7. #button{
  8. background-color:#262626;
  9. }
  10. .center{
  11. display: block;
  12. margin-left: auto;
  13. margin-right: auto;
  14. width: 40%;
  15. top:30%;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <div id="ipv4" style="position:fixed;top:3px;left:3px;z-index:10;color:white;"><?php echo $_GET['ip'];?></div>
  21. <div id="button" style="width:100%;height:100%;position:fixed;left:0px;top:0px;" onClick="toggleSwitch();">
  22. <img id="icon" class="center" src=""></img>
  23. </div>
  24. <div id="uuid" style="position:fixed;bottom:3px;left:3px;color:white;"></div>
  25. <script>
  26. status();
  27. uuid();
  28. var uuid = "";
  29. var currentStatus = "OFF";
  30. function status(){
  31. $.ajax({url: "http://<?php echo $_GET['ip'];?>/status",
  32. success: function(result){
  33. $("#status").html(result);
  34. if (result == "ON"){
  35. $("#button").css("background-color","#00cccc");
  36. currentStatus = "ON";
  37. }else{
  38. $("#button").css("background-color","#262626");
  39. currentStatus = "OFF";
  40. }
  41. }});
  42. }
  43. function toggleSwitch(){
  44. if (currentStatus == "OFF"){
  45. on();
  46. }else{
  47. off();
  48. }
  49. }
  50. function off(){
  51. $.ajax({url: "http://<?php echo $_GET['ip'];?>/off", success: function(result){
  52. status();
  53. }});
  54. }
  55. function on(){
  56. $.ajax({url: "http://<?php echo $_GET['ip'];?>/on", success: function(result){
  57. status();
  58. }});
  59. }
  60. function uuid(){
  61. $.ajax({url: "http://<?php echo $_GET['ip'];?>/uuid", success: function(result){
  62. $("#uuid").text(result);
  63. uuid = result;
  64. getNickName();
  65. }});
  66. }
  67. function getNickName(){
  68. $.ajax({url: "../nicknameman.php?uuid=" + $("#uuid").text().trim(), success: function(result){
  69. if (result.includes("ERROR") == false){
  70. $("#uuid").text(result);
  71. getIcon();
  72. }else{
  73. }
  74. }});
  75. }
  76. function getIcon(){
  77. $.ajax({url: "../nicknameman.php?nickname=" + $("#uuid").text().trim(), success: function(result){
  78. if (result.includes("true") == true){
  79. $("#icon").attr('src','../img/icons/'+ $("#uuid").text().trim() +'.png');
  80. }
  81. }});
  82. }
  83. </script>
  84. </body>
  85. </html>