function cpuLoad(){$.ajax({url:"api/cpuload.api.php",method:"post",timeout:500}).done(function(a){vals=JSON.parse(a),$("#cpuValues").html("1min"+vals[0]+"%5min"+vals[1]+"%15min"+vals[2]+"%")})}function initpads(){var a=function(){$.ajax({url:"api/initPads.api.php",method:"post"}).done(function(a){console.log(a),$("#pads").modal("close"),Materialize.toast("Done",4e3,"")})};modal({id:"pads",title:"Init pads",message:"Do you really want re-init pads ?",buttons:{close:{label:"No",callback:"close"},dele:{label:"Yes",callback:a}}})}function unpair(){var a=function(){$.ajax({url:"api/unpair.api.php",method:"post"}).done(function(a){console.log(a),modal({id:"done",title:"Done",message:a,buttons:{close:{label:"Ok",callback:"close"}}})}),$("#unpair").modal("close")};modal({id:"unpair",title:"Unpair",message:"Do you really want unpair server?",buttons:{close:{label:"No",callback:"close"},dele:{label:"Yes",callback:a}}})}function pair(){var a=function(){Materialize.toast("Command sent, take a look in your pc...",4e3,""),$.ajax({url:"api/pair.api.php",method:"post"}).done(function(a){console.log(a),modal({id:"done",title:"Done",message:a,buttons:{close:{label:"Ok",callback:"close"}}})}),$("#pair").modal("close")};modal({id:"pair",title:"Pair",message:"Do you really want pair whit a server?",buttons:{close:{label:"No",callback:"close"},dele:{label:"Yes",callback:a}}})}function reboot(){var a=function(){$.ajax({url:"api/reboot.api.php",method:"post"}).done(function(a){console.log(a),Materialize.toast("Rebooting...",4e3,"")}),$("#reboot").modal("close")};modal({id:"reboot",title:"Reboot",message:"Do you really want reboot device ?",buttons:{close:{label:"No",callback:"close"},dele:{label:"Reboot",callback:a}}})}function stopStream(){var a=function(){$.ajax({url:"api/stopStream.api.php",method:"post"}).done(function(a){console.log(a),Materialize.toast("Done",4e3,"")}),$("#modal").modal("close")};modal({id:"modal",title:"Stop",message:"Do you really want to stop the stream?",buttons:{close:{label:"No",callback:"close"},dele:{label:"Stop",callback:a}}})}function poweroff(){var a=function(){$.ajax({url:"api/shutdown.api.php",method:"post"}).done(function(a){console.log(a),Materialize.toast("Bye bye",4e3,"")}),$("#modal").modal("close")};modal({id:"modal",title:"Shutdown",message:"Do you really want shutdown the system?",buttons:{close:{label:"No",callback:"close"},dele:{label:"Shutdown",callback:a}}})}function launch(a){var b=function(){$.ajax({url:"api/startgame.api.php",method:"post",data:{game:a}}).done(function(a){console.log(a),Materialize.toast("Done",4e3,"")}),$("#modal").modal("close")};modal({id:"modal",title:"Start stream",message:"Do you really want start "+a+" ?",buttons:{close:{label:"No",callback:"close"},dele:{label:"Start!",callback:b}}})}function getGames(){$("#games").html('

Detecting available applications...
'),$.ajax({url:"api/getGames.api.php"}).done(function(a){if(a.length>4){var b=JSON.parse(a);$("#games").html(''),Materialize.toast(b.length.toString()+" applications found",4e3,""),$.each(b,function(a,b){$("#collection").append('
  • play_arrow#'+b.id+"

    "+b.name+"

  • ")})}else $("#games").html('

    error_outline
    No games detected

    Maybe server is off or need to pair devices?


    Refresh
    ')})}modal=function(a){a=$.extend({},{id:"modal_"+Math.round(100*Math.random()).toString(),ready:function(){},dismissible:!0,title:"Title",message:"Message",buttons:{close:{label:"Ok",callback:"close"}}},a),$(".modal").remove();var b='",$("body").append(b);for(key in a.buttons)a.buttons.hasOwnProperty(key)&&"function"==typeof a.buttons[key].callback&&$("#modal_action_"+key.toString()).bind("click",a.buttons[key].callback);return $("#"+a.id).modal({ready:a.ready,dismissible:a.dismissible}).modal("open"),$("#"+a.id)};