Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. check: function(mac){
  2.         var cmd = {  // The command
  3.             "action": "sdcard",
  4.             "subaction": "info",
  5.             "macaddr": mac
  6.         };
  7.         deviceAjax.send(cmd).then(function(data) { // Ajax call
  8.             var row = $(document.getElementById(mac)).html(); // Updating the row
  9.             var x = parseInt(row) - 1;
  10.             sd.msg.push(data);
  11.  
  12.             if(data.result == "OK"){ // If already formatted
  13.                 $('#forbtn'+row).val("Format again");
  14.                 $("#forbtn"+row).addClass("red");
  15.                 $('#forbtn'+row).show();
  16.  
  17.                 if (sd.go_to == "sdloop"){sd.x++; sd.loop();}
  18.                 else if (sd.go_to == "popup"){popup.unload("YES");}
  19.             }
  20.             else if (data.result == "ERROR"){
  21.                 if (deviceinfo.array[x]["sdcard"] == 1){// Is Extended
  22.                     $('#forbtn'+row).val("Format");
  23.                     $("#forbtn"+row).addClass("green");
  24.                     $('#forbtn'+row).show();
  25.                 }
  26.                 else{// Is Live Or None
  27.                     $("#forbtn"+row).hide();
  28.                 }
  29.  
  30.                 if (sd.go_to == "sdloop"){sd.x++; sd.loop();}
  31.                 else if (sd.go_to == "popup"){popup.unload("YES");}
  32.             }
  33.             else if (data.result == "BUSY"){
  34.                 setTimeout(function(){ sd.check(mac); }, 1000);
  35.             }
  36.         })
  37.         .catch(function(error) {
  38.             console.log("SD Error:",error);
  39.             setTimeout(function(){ sd.check(mac); }, 1000);
  40.         });
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement