d1283b96a1
fixed TopStats restrict search to minimum 3 characters
1 line
9.0 KiB
JavaScript
1 line
9.0 KiB
JavaScript
function hideLoader(){$(".layout-loading-icon").fadeOut()}function showLoader(){$(".layout-loading-icon").attr("style","visibility:visible");$(".layout-loading-icon").removeClass("text-danger");$(".layout-loading-icon").fadeIn()}function errorLoader(){$(".layout-loading-icon").addClass("text-danger")}function executeCommand(){const t=$("#console_server_select").val(),n=$("#console_command_value").val();if(n.length===0)return!1;if(n[0]!=="!")return $("#console_command_response").text("All commands must start with !").addClass("text-danger"),!1;showLoader();$.get("/Console/ExecuteAsync",{serverId:t,command:n}).done(function(n){hideLoader();$("#console_command_response").html(n);$("#console_command_value").val("")}).fail(function(n,t,i){errorLoader();hideLoader();$("#console_command_response").text("Could not execute command: "+i).addClass("text-danger")})}function loadMorePenalties(){showLoader();$.get("/Penalty/ListAsync",{offset:offset}).done(function(n){$("#penalty_table").append(n);hideLoader()}).fail(function(){errorLoader()});offset+=15}function penaltyToName(n){switch(n){case"Flag":return"Flagged";case"Warning":return"Warned";case"Report":return"Reported";case"Ban":return"Banned";case"Kick":return"Kicked";case"TempBan":return"Temp Banned";case"Unban":return"Unbanned"}}function shouldIncludePlural(n){return n>1?"s":""}function timeStep(n){let t=n/36e5,i=n/864e5,r=n/6048e5;return Math.round(r)>Math.round(currentStepAmount/24*7)?(currentStepAmount=Math.round(r),`${currentStepAmount} week${shouldIncludePlural(currentStepAmount)} ago`):Math.round(i)>Math.round(currentStepAmount/24)?(currentStepAmount=Math.round(i),`${currentStepAmount} day${shouldIncludePlural(currentStepAmount)} ago`):Math.round(t)>currentStepAmount?(currentStepAmount=Math.round(t),`${currentStepAmount} hour${shouldIncludePlural(currentStepAmount)} ago`):void 0}function loadMeta(n){let t="";const r=moment.utc(n.when).valueOf();mostRecentDate===0&&(mostRecentDate=r);const i=timeStep(moment.utc().valueOf()-r);i!==lastStep&&i!==undefined&&r>0&&($("#profile_events").append('<span class="p2 text-white profile-event-timestep"><span class="text-primary">—<\/span> '+i+"<\/span>"),lastStep=i);n.class.includes("Penalty")?t=n.value.punisherId!==clientInfo.clientId?`<div><span class="penalties-color-${n.value.type.toLowerCase()}">${penaltyToName(n.value.type)}</span> by <span class="text-highlight"> <a class="link-inverse" href="${n.value.punisherId}">${n.value.punisherName}</a></span > for <span style="color: white; ">${n.value.offense}</span></div>`:`<div><span class="penalties-color-${n.value.type.toLowerCase()}">${penaltyToName(n.value.type)} </span> <span class="text-highlight"><a class="link-inverse" href="${n.value.offenderId}"> ${n.value.offenderName}</a></span > for <span style="color: white; ">${n.value.offense}</span></div>`:n.key.includes("Alias")?t=`<div><span class="text-success">${n.value}</span></div>`:n.key.includes("Event")&&(t=`<div><span style="color:white;">></span><span class="text-muted"> ${n.value}</span></div>`);$("#profile_events").append(t)}function getPlayerHistoryChart(n,t,i,r){return n.forEach(function(t,i){n[i].x=new Date(n[i].x)}),new CanvasJS.Chart(`server_history_${t}`,{backgroundColor:"#191919",height:100,width:i,animationEnabled:!0,toolTip:{contentFormatter:function(n){const t=moment.utc(n.entries[0].dataPoint.x);return t.local().format("h:mm A")+" - "+n.entries[0].dataPoint.y+" players"}},axisX:{interval:1,gridThickness:0,lineThickness:0,tickThickness:0,margin:0,valueFormatString:" "},axisY:{gridThickness:0,lineThickness:0,tickThickness:0,minimum:0,margin:0,valueFormatString:" ",labelMaxWidth:0},legend:{maxWidth:0,maxHeight:0,dockInsidePlotArea:!0},data:[{showInLegend:!1,type:"splineArea",color:r,markerSize:0,dataPoints:n}]})}function refreshClientActivity(){$(".server-history-row").each(function(){let n=$(this).data("serverid");$.get({url:"/server/clientactivity/"+n,cache:!1}).done(function(t){const i=$(t).find(".col-6 span").length;$("#server_header_"+n+" .server-clientcount").text(i);$("#server_clientactivity_"+n).html(t)}).fail(function(t,i,r){$("#server_clientactivity_"+n).html("Could not load client activity - "+r)})})}var charts;$(document).ready(function(){hideLoader();$(document).click(function(){hideLoader()});$(".profile-action").click(function(){const n=$(this).data("action");$.get("/Action/"+n+"Form").done(function(n){$("#actionModal .modal-message").fadeOut("fast");$("#actionModal .modal-body-content").html(n);$("#actionModal").modal()}).fail(function(n,t,i){$("#actionModal .modal-message").text("Error &mdash "+i);$("#actionModal").modal();$("#actionModal .modal-message").fadeIn("fast")})});$(document).on("submit",".action-form",function(n){n.preventDefault();$(this).append($("#target_id input"));const t=$(this).serialize();showLoader();$.get($(this).attr("action")+"/?"+t).done(function(n){hideLoader();n.length===0?location.reload():($("#actionModal .modal-message").fadeOut("fast"),$("#actionModal .modal-body-content").html(n),$("#actionModal").modal())}).fail(function(n,t,i){errorLoader();hideLoader();$("#actionModal .modal-message").text.length>0&&$("#actionModal .modal-message").fadeOut("fast");n.status===401?$("#actionModal .modal-message").text("Invalid login credentials"):$("#actionModal .modal-message").text("Error — "+i);$("#actionModal .modal-message").fadeIn("fast")})})});$(document).ready(function(){$("#console_command_button").click(function(){executeCommand()});$(document).keydown(function(n){const t=n.keyCode?n.keyCode:n.which;t===13&&executeCommand()})});let offset=15;if($("#penalty_table").length==1){$("html").bind("mousewheel DOMMouseScroll",function(n){var t=n.originalEvent.wheelDelta||-n.originalEvent.detail;t<0&&!hasScrollBar&&loadMorePenalties()});var _throttleTimer=null,_throttleDelay=100,$window=$(window),$document=$(document),hasScrollBar=!1;$document.ready(function(){$window.off("scroll",n).on("scroll",n)});function n(){hasScrollBar=!0;clearTimeout(_throttleTimer);_throttleTimer=setTimeout(function(){$window.scrollTop()+$window.height()>$document.height()-100&&loadMorePenalties()},_throttleDelay)}}let count=1;$(document).ready(function(){if(typeof clientInfo=="undefined")return!1;$("#profile_aliases_btn").click(function(){const n=$("#profile_aliases").text().trim();n&&n.length!==0&&($("#profile_aliases").slideToggle(150),$(this).toggleClass("oi-caret-top"))});$.each(clientInfo.Meta,function(n,t){if(t.key.includes("Event")){if(loadMeta(t),count%40==0)return count++,!1;count++}});$(window).scroll(function(){if($(window).scrollTop()===$(document).height()-$(window).height()||$(document).height()===$(window).height()){while(count%40!=0&&count<clientInfo.Meta.length)loadMeta(clientInfo.Meta[count-1]),count++;count++}});$.each(clientInfo.Meta,function(n,t){if(!t.key.includes("Event")){let n=`<div class="profile-meta-entry"><span class="profile-meta-value text-primary">${t.value}</span><span class="profile-meta-title text-muted"> ${t.key}</span></div>`;$("#profile_meta").append(n)}});$(".ip-locate-link").click(function(n){n.preventDefault();const t=$(this).data("ip");$.getJSON("https://extreme-ip-lookup.com/json/"+t).done(function(n){$("#mainModal .modal-title").text(t);$("#mainModal .modal-body").text("");n.ipName.length>0&&$("#mainModal .modal-body").append("Hostname — "+n.ipName+"<br/>");n.isp.length>0&&$("#mainModal .modal-body").append("ISP — "+n.isp+"<br/>");n.org.length>0&&$("#mainModal .modal-body").append("Organization — "+n.org+"<br/>");n.businessName.length>0&&$("#mainModal .modal-body").append("Business — "+n.businessName+"<br/>");n.businessWebsite.length>0&&$("#mainModal .modal-body").append("Website — "+n.businessWebsite+"<br/>");(n.city.length>0||n.region.length>0||n.country.length>0)&&$("#mainModal .modal-body").append("Location — ");n.city.length>0&&$("#mainModal .modal-body").append(n.city);n.region.length>0&&$("#mainModal .modal-body").append(", "+n.region);n.country.length>0&&$("#mainModal .modal-body").append(", "+n.country);$("#mainModal").modal()}).fail(function(n,t,i){$("#mainModal .modal-title").text("Error");$("#mainModal .modal-body").html('<span class="text-danger">—'+i+"<\/span>");$("#mainModal").modal()})})});let mostRecentDate=0,currentStepAmount=0,lastStep="";charts={};$(".server-history-row").each(function(){let i=$(this).data("clienthistory"),n=$(this).data("serverid"),r=$(this).data("online")==="True"?"rgba(0, 122, 204, 0.432)":"#ff6060",u=$(".server-header").first().width(),t=getPlayerHistoryChart(i,n,u,r);t.render();charts[n]=t});$(window).resize(function(){$(".server-history-row").each(function(){let n=$(this).data("serverid");charts[n].options.width=$(".server-header").first().width();charts[n].render()})});setInterval(refreshClientActivity,2e3);$(document).ready(function(){$(".form-inline").submit(function(n){$("#client_search").val().length<3&&(n.preventDefault(),$("#client_search").addClass("input-text-danger").delay(25).queue(function(){$(this).addClass("input-border-transition").dequeue()}).delay(1e3).queue(function(){$(this).removeClass("input-text-danger").dequeue()}).delay(500).queue(function(){$(this).removeClass("input-border-transition").dequeue()}))})}); |