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){var B=[".wollist-widget"];if(!vBulletin.pageHasSelectors(B)){return false}A(document).ready(function(){new vBulletin.pagination({context:A(".wollist-widget"),onPageChanged:function(K,E){A("body").css("cursor","wait");var D=A(this).closest(".wollist-widget");var J=A(".widget-content",D).attr("data-perpage"),I=A(".widget-content",D).attr("data-thispageonly"),F=A(".widget-content",D).attr("data-pagekey"),G=A(".widget-content",D).attr("data-who"),L=parseInt(A(".widget-content",D).attr("data-resolve")),H={who:G,pagenumber:K,perpage:J,resolveIp:L};if(I=="1"){H.pagekey=F}A.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/wol/refreshUsers",data:H,type:"POST",dataType:"json",complete:function(N,M){console.log("wol-fetchAll complete.");A("body").css("cursor","auto")},success:function(M,P,Q){console.log("wol-fetchAll successful! result:"+JSON.stringify(M));if(M){if(!M.error){var N=((K-1)*J)+1,R=K*J,O;R=(R>M.userCounts.total)?M.userCounts.total:R;O=N+" - "+vBulletin.phrase.get("x_of_y",R,M.userCounts.total);A(".widget-content tbody",D).empty().html(M.template);A(".widget-content .user-counters",D).html(O);A(".widget-content .user-counts",D).html(vBulletin.phrase.get("x_members_y_guests_online",M.userCounts.members,M.userCounts.guests))}else{openAlertDialog({title:"Online Users",message:vBulletin.phrase.get("error_x",M.error),iconType:"warning"})}}else{openAlertDialog({title:"Online Users",message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(O,N,M){console.log("wol-fetchAll failed! error:"+M);openAlertDialog({title:"Online Users",message:vBulletin.phrase.get("error_fetching_online_users_x",O.status),iconType:"error"})}})}});function C(M,L){var D=A('div.wollist-widget[data-widget-instance-id="'+M+'"]');var K=A('.pagenav-controls :input[name="page"]',D).val(),J=A(".widget-content",D).attr("data-perpage"),I=A(".widget-content",D).attr("data-thispageonly"),E=A(".widget-content",D).attr("data-pagekey"),G=A(".widget-content",D).attr("data-who"),F=A(".widget-content",D).attr("data-resolve"),H={who:G,pagenumber:K,perpage:J,resolveIp:F};if(typeof L=="object"){H.sortfield=L.sortby;H.sortorder=L.sortorder}if(I=="1"){H.pagekey=E}A("body").css("cursor","wait");A.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/wol/refreshUsers",data:H,type:"POST",dataType:"json",complete:function(O,N){console.log("wol-refreshUsers complete.");A("body").css("cursor","auto")},success:function(N,Q,R){console.log("wol-fetchAll successful! result:"+JSON.stringify(N));if(N){if(!N.error){var O=((K-1)*J)+1,S=K*J,P;S=(S>N.userCounts.total)?N.userCounts.total:S;P=O+" - "+vBulletin.phrase.get("x_of_y",S,N.userCounts.total);A(".widget-content tbody",D).empty().html(N.template);A(".widget-content .user-counters",D).html(P);A(".widget-content .user-counts",D).html(vBulletin.phrase.get("x_members_y_guests_online",N.userCounts.members,N.userCounts.guests))}else{openAlertDialog({title:"Online Users",message:vBulletin.phrase.get("error_x",N.error),iconType:"warning"})}}else{openAlertDialog({title:"Online Users",message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(P,O,N){console.log("wol-fetchAll failed! error:"+N);openAlertDialog({title:"Online Users",message:vBulletin.phrase.get("error_fetching_online_users_x",P.status),iconType:"error"})}})}A(".wollist-widget").each(function(){var E=A(this).attr("data-widget-instance-id"),D=parseInt(A(".widget-content",A(this)).attr("data-refresh"));if(D>0){window.setInterval(function(){C(E)},(D*1000))}});A(document).off("click",".sortBy").on("click",".sortBy",function(H){var D=A(this),F=D.closest(".wollist-widget").attr("data-widget-instance-id"),E=D.data("sortorder"),G={sortby:D.data("sortby"),sortorder:(E=="desc")?"asc":"desc"};D.data("sortorder",G.sortorder);C(F,G)});A(document).off("click",".resolveIpLink").on("click",".resolveIpLink",function(E){E.preventDefault();var D=A(this);A.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/call/bbcode/resolveIp",type:"post",data:{ip:D.text()},dataType:"json",success:function(F){if(!F||F.errors){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("online_error_resolving_ip")+": "+vBulletin.phrase.get(F.errors[0]),iconType:"error"})}else{D.replaceWith(F)}},complete:function(){A("body").css("cursor","default")}})})})})(jQuery);