window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache=$.merge(window.vBulletin.phrase.precache,["online_error_resolving_ip","error"]);(function(A){A(document).ready(function(){function B(F){var J=A('div.wollist-widget[widget-instance-id="'+F+'"]');var D=A('.pagenav-controls :input[name="page"]',J).val(),E=A(".widget-content",J).attr("data-perpage"),H=A(".widget-content",J).attr("data-thispageonly"),C=A(".widget-content",J).attr("data-pagekey"),I=A(".widget-content",J).attr("data-who"),G={who:I,pagenumber:D,perpage:E};if(H=="1"){G.pagekey=C}A("body").css("cursor","wait");A.ajax({url:pageData.baseurl+"/index.php/ajax/api/wol/fetchAll",data:G,type:"POST",dataType:"json",complete:function(L,K){console.log("wol-fetchAll complete.");A("body").css("cursor","auto")},success:function(K,O,P){console.log("wol-fetchAll successful! result:"+JSON.stringify(K));if(K){if(!K.error){var M="",N=[],L="";for(x in K){if(K[x].wol){if(K[x].wol.params.length>0){K[x].wol.params.unshift(K[x].wol.action);N=K[x].wol.params}else{N=K[x].wol.action}}else{N="n_a"}if(K[x].host){L='<a href="#" class="resolveIpLink">'+K[x].host+"</a>"}else{L=vBulletin.phrase.get("n_a")}M+="<tr><td>"+K[x].username+"</td><td>"+vBulletin.phrase.get(N)+"</td><td>"+K[x].lastactivity+"</td><td>"+L+"</td></tr>"}A(".widget-content tbody",J).empty().html(M)}else{openAlertDialog({title:"Online Users",message:vBulletin.phrase.get("error_x",K.error),iconType:"warning"})}}else{openAlertDialog({title:"Online Users",message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(M,L,K){console.log("wol-fetchAll failed! error:"+K);openAlertDialog({title:"Online Users",message:vBulletin.phrase.get("error_fetching_online_users_x",M.status),iconType:"error"})}})}A(".wollist-widget").each(function(){var D=A(this).attr("widget-instance-id"),C=parseInt(A(".widget-content",A(this)).attr("data-refresh"));if(C>0){window.setInterval(function(){B(D)},(C*1000))}});A(".resolveIpLink").live("click",function(D){D.preventDefault();var C=A(this);A.ajax({url:pageData.baseurl+"/index.php/ajax/call/bbcode/resolveIp",type:"post",data:{ip:C.text()},dataType:"json",success:function(E){if(!E||E.errors){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("online_error_resolving_ip")+": "+vBulletin.phrase.get(E.errors[0]),iconType:"error"})}else{C.replaceWith(E)}},complete:function(){A("body").css("cursor","default")}})})})})(jQuery);