$(function(){$("[data-shafa-download='secure']").each(function(){$(this)})}),$(function(){var n=$("#remoteInstall"),c=$("[data-shafa-remote='devices']"),d=[],t=0;function o(a,t,e,s){$.getJSON("http://"+a+"/interface?mod=install_app&data="+t+"&callback=?",function(a){1==a.success&&(4!=c.data("status")&&($("[data-shafa-remote]",c).removeClass("active"),$("[data-shafa-remote='success']",c).addClass("active")),$("[data-shafa-remote='success']",c).html("
已推送"+e+"到"+s+"安装
").data("status","4"),ga("send","event","installMarket","install"),$.getScript("http://stats.shafa.com/i/app?id="+t),$.getScript("http://stats.shafa.com/i/app_web_download?id="+t))})}function l(a,t,e,s){t?o(a,t,e,s):$(".app-id").each(function(){o(a,$(this).val(),"全部应用",s)})}function s(a,o){if(86400").addClass("btn btn-primary remote-install").data("host",a).html(s).click(function(){l($(this).data("host"),t,e,s)});2!=c.data("status")&&(c.data("status",2),$("[data-shafa-remote]",c).removeClass("active"),$("[data-shafa-remote='list']",c).addClass("active")),$("[data-shafa-remote='list']",c).append(o),d.push(a)}(i,e,s,t)})})}}function a(){var a=setInterval(function(a){if(0===c.data("status")){var t="http://app.shafa.com/api/WebController/device_list?&hw="+encodeURIComponent(a)+"&callback=?";$.getJSON(t,function(a){if(0===a.code){var t=(a=$.parseJSON(a.msg)).devices.length;if(1==t)s(a.devices[0],t);else for(var e in a.devices)s(a.devices[e],t)}})}},5e3);$("#remoteInstall").on("show.bs.modal",function(a){$(this).data("app-id",$(a.relatedTarget).data("app-id")).data("app-title",$(a.relatedTarget).data("app-title"))}).on("hidden.bs.modal",function(){clearInterval(a),c.data("status",0),$("[data-shafa-remote]",c).removeClass("active"),$("[data-shafa-remote='searching']",c).addClass("active")}),setTimeout(function(){clearInterval(a),0===t&&(c.data("status",1),$("[data-shafa-remote]",c).removeClass("active"),$("[data-shafa-remote='notFound']",c).addClass("active"))},8e3)}$("[data-shafa-remote='button']").click(function(){a($(this).data("hw"))}).tooltip(),$("[data-shafa-remote='refresh']").click(function(){c.data("status",0),$("[data-shafa-remote]",c).removeClass("active"),$("[data-shafa-remote='searching']",c).addClass("active"),a()})}),$(function(){$(document).scroll(function(){var a=$(document).scrollTop(),t=$("[data-shafa-scroll='scrollShow']");t.data("shafa-distance")<=a?t.addClass("show"):t.removeClass("show")}),$("[data-shafa-scroll='backTop']").click(function(a){a.preventDefault(),$("html,body").animate({scrollTop:0})})});