Advertisement
RuiViana

javascript.js

Feb 15th, 2019
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ip ="";
  2. var root ="";
  3. $(document).ready(function(){  
  4.     ip = location.host;
  5.     setInterval(function(){ myfunction(); }, 800); 
  6.    
  7.    
  8.     $("#btnRoot").click(function(){
  9.         ip = location.host;
  10.         root = "";
  11.         root += "http://";
  12.         root += ip;
  13.         root += "/ligarLed?btnRoot=1";
  14.         $.ajax({url: root, success: function(result){
  15.            
  16.         }});
  17.     });
  18.    
  19.     $("#btnNode1").click(function(){
  20.         ip = location.host;
  21.         root = "";
  22.         root += "http://";
  23.         root += ip;
  24.         root += "/ligarLed?btnNode1=1";
  25.         $.ajax({url: root, success: function(result){
  26.                
  27.         }});
  28.     });
  29.    
  30.     $("#btnNode2").click(function(){
  31.         ip = location.host;
  32.         root = "";
  33.         root += "http://";
  34.         root += ip;
  35.         root += "/ligarLed?btnNode2=1";
  36.         $.ajax({url: root, success: function(result){
  37.            
  38.         }});
  39.     });
  40.    
  41.     $("#btnNode3").click(function(){
  42.         ip = location.host;
  43.         root = "";
  44.         root += "http://";
  45.         root += ip;
  46.         root += "/ligarLed?btnNode3=1";
  47.         $.ajax({url: root, success: function(result){
  48.            
  49.         }});
  50.     });
  51.    
  52.     $("#btnNode4").click(function(){
  53.         ip = location.host;
  54.         root = "";
  55.         root += "http://";
  56.         root += ip;
  57.         root += "/ligarLed?btnNode4=1";
  58.         $.ajax({url: root, success: function(result){
  59.            
  60.         }});
  61.     });
  62.    
  63.     $("#btnNode5").click(function(){
  64.         ip = location.host;
  65.         root = "";
  66.         root += "http://";
  67.         root += ip;
  68.         root += "/ligarLed?btnNode5=1";
  69.         $.ajax({url: root, success: function(result){
  70.            
  71.         }});
  72.     });    
  73.        
  74.     $("#btnNode6").click(function(){
  75.         ip = location.host;
  76.         root = "";
  77.         root += "http://";
  78.         root += ip;
  79.         root += "/ligarLed?btnNode6=1";
  80.         $.ajax({url: root, success: function(result){
  81.            
  82.         }});
  83.     });
  84.    
  85.    
  86. });
  87.  
  88. function myfunction(){
  89.         ip = location.host;
  90.         root = "";
  91.         root += "http://";
  92.         root += ip;
  93.         root += "/teste";
  94.         $.ajax({url: root, success: function(result){
  95.         //------------------( dados botao btnRoot )-----------------
  96.         var pacote;
  97.         pacote = result.split("*");
  98.         $("#debug").html(ip);
  99.         $("#debug").append("<br>");
  100.         $("#debug").append(pacote[0]);
  101.         $("#debug").append("<br>");
  102.         $("#debug").append(pacote[1]);
  103.         $("#debug").append("<br>");
  104.         $("#debug").append(pacote[2]);
  105.         $("#debug").append("<br>");
  106.         $("#debug").append(pacote[3]); 
  107.         $("#debug").append("<br>");
  108.         $("#debug").append(pacote[4]);
  109.         $("#debug").append("<br>");
  110.         $("#debug").append(pacote[5]); 
  111.         $("#debug").append("<br>");
  112.         $("#debug").append(pacote[6]);     
  113.        
  114.         //-----------------( dados botao btnRoot )------------------
  115.         var dados;
  116.         dados = pacote[0].split("|");
  117.         $("#tdEsp1Id") .html(dados[0]);
  118.         $("#tdEsp1Mod").html(dados[1]);
  119.         $("#tdEsp1Con").html(dados[2]);
  120.         $("#tdEsp1Led").html(dados[4]);
  121.         $("#tdEsp1Cnt").html(dados[5]);
  122.         if(dados[4]=="0"){
  123.             $("#btnRoot").prop("checked", false);
  124.         }
  125.         else{
  126.             $("#btnRoot").prop("checked", true);
  127.         }
  128.        
  129.         //-----------------( dados botao btnNode1 )-----------------
  130.         dados = pacote[1].split("|");
  131.         $("#tdEsp2Id") .html(dados[0]);
  132.         $("#tdEsp2Mod").html(dados[1]);
  133.         $("#tdEsp2Con").html(dados[2]);
  134.         $("#tdEsp2Led").html(dados[4]);
  135.         $("#tdEsp2Cnt").html(dados[5]);
  136.         if(dados[4]=="0"){
  137.             $("#btnNode1").prop("checked", false);
  138.         }
  139.         else{
  140.             $("#btnNode1").prop("checked", true);
  141.         }
  142.        
  143.         //-----------------( dados botao btnNode2 )-----------------
  144.         dados = pacote[2].split("|");
  145.         $("#tdEsp3Id") .html(dados[0]);
  146.         $("#tdEsp3Mod").html(dados[1]);
  147.         $("#tdEsp3Con").html(dados[2]);
  148.         $("#tdEsp3Led").html(dados[4]);
  149.         $("#tdEsp3Cnt").html(dados[5]);
  150.         if(dados[4]=="0"){
  151.             $("#btnNode2").prop("checked", false);
  152.         }
  153.         else{
  154.             $("#btnNode2").prop("checked", true);
  155.         }
  156.                
  157.         //-----------------( dados botao btnNode3 )-----------------
  158.         dados = pacote[3].split("|");
  159.         $("#tdEsp4Id") .html(dados[0]);
  160.         $("#tdEsp4Mod").html(dados[1]);
  161.         $("#tdEsp4Con").html(dados[2]);
  162.         $("#tdEsp4Led").html(dados[4]);
  163.         $("#tdEsp4Cnt").html(dados[5]);
  164.         if(dados[4]=="0"){
  165.             $("#btnNode3").prop("checked", false);
  166.         }
  167.         else{
  168.             $("#btnNode3").prop("checked", true);
  169.         }
  170.                
  171.         //-----------------( dados botao btnNode4 )-----------------
  172.         dados = pacote[4].split("|");
  173.         $("#tdEsp5Id") .html(dados[0]);
  174.         $("#tdEsp5Mod").html(dados[1]);
  175.         $("#tdEsp5Con").html(dados[2]);
  176.         $("#tdEsp5Led").html(dados[4]);
  177.         $("#tdEsp5Cnt").html(dados[5]);
  178.         if(dados[4]=="0"){
  179.             $("#btnNode4").prop("checked", false);
  180.         }
  181.         else{
  182.             $("#btnNode4").prop("checked", true);
  183.         }
  184.                        
  185.         //-----------------( dados botao btnNode4 )-----------------
  186.         dados = pacote[5].split("|");
  187.         $("#tdEsp6Id") .html(dados[0]);
  188.         $("#tdEsp6Mod").html(dados[1]);
  189.         $("#tdEsp6Con").html(dados[2]);
  190.         $("#tdEsp6Led").html(dados[4]);
  191.         $("#tdEsp6Cnt").html(dados[5]);
  192.         if(dados[4]=="0"){
  193.             $("#btnNode5").prop("checked", false);
  194.         }
  195.         else{
  196.             $("#btnNode5").prop("checked", true);
  197.         }
  198.                        
  199.         //-----------------( dados botao btnNode4 )-----------------
  200.         dados = pacote[6].split("|");
  201.         $("#tdEsp7Id") .html(dados[0]);
  202.         $("#tdEsp7Mod").html(dados[1]);
  203.         $("#tdEsp7Con").html(dados[2]);
  204.         $("#tdEsp7Led").html(dados[4]);
  205.         $("#tdEsp7Cnt").html(dados[5]);
  206.         if(dados[4]=="0"){
  207.             $("#btnNode6").prop("checked", false);
  208.         }
  209.         else{
  210.             $("#btnNode6").prop("checked", true);
  211.         }
  212.                                            
  213.     }});
  214. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement