const timeoutShort=1500,timeoutMedium=2500,timeoutLong=4e3,bufferTrimSize=131072,spinnerHTML='<div class="txSpinner">Loading...</div>',xss=e=>{let s=document.createElement("div");return s.innerText=e,s.innerHTML};function refreshData(){$.ajax({url:"/status",type:"GET",dataType:"json",timeout:1500,success:function(e){e.logout?window.location="/auth?logout":($("#hostusage-cpu-bar").attr("aria-valuenow",e.host.cpu.pct).css("width",e.host.cpu.pct+"%"),$("#hostusage-cpu-text").html(e.host.cpu.text),$("#hostusage-memory-bar").attr("aria-valuenow",e.host.memory.pct).css("width",e.host.memory.pct+"%"),$("#hostusage-memory-text").html(e.host.memory.text),$("#status-card").html(e.status),$("#favicon").attr("href","img/"+e.meta.favicon+".png"),document.title=e.meta.title,processPlayers(e.players))},error:function(e,s,t){let a=null;a="parsererror"==s?"Response parse error.\nTry refreshing your window.":`Request error: ${s}\n${t}`,$("#hostusage-cpu-bar").attr("aria-valuenow",0).css("width",0),$("#hostusage-cpu-text").html("error"),$("#hostusage-memory-bar").attr("aria-valuenow",0).css("width",0),$("#hostusage-memory-text").html("error"),$("#status-card").html(a.replace("\n","\n<br>")),$("#favicon").attr("href","img/favicon_offline.png"),document.title="ERROR - txAdmin",processPlayers(a)}})}function changeOwnPasswordModal(){$("#modChangePassword").modal("show")}$("#modChangePassword-save").click((function(){let e={newPassword:$("#modChangePassword-newPassword").val().trim(),confirmPassword:$("#modChangePassword-confirmPassword").val().trim()},s=[];if(e.newPassword.length&&e.confirmPassword.length||s.push("The new password fields are required."),e.newPassword!==e.confirmPassword&&s.push("Your new password doesn't match the one typed in the confirmation input."),"undefined"==typeof isTempPassword&&(e.oldPassword=$("#modChangePassword-oldPassword").val().trim(),e.oldPassword.length||s.push("The old password field is required."),e.oldPassword===e.confirmPassword&&s.push("The new password must be different than the old one.")),(e.newPassword.length<6||e.newPassword.length>24)&&s.push("The new password has to be between 6 and 24 characters."),s.length)var t=$.notify({message:"<b>Errors:</b><br> - "+s.join(" <br>\n - ")},{type:"warning"});else{t=$.notify({message:'<p class="text-center">Saving...</p>'},{});$.ajax({type:"POST",url:"/changePassword",timeout:2500,data:e,dataType:"json",success:function(e){t.update("progress",0),t.update("type",e.type),t.update("message",e.message),"success"==e.type&&($("#modChangePassword").modal("hide"),setTimeout((()=>{$("#modChangePassword-save").hide(),$("#modChangePassword-body").html('<h4 class="mx-auto" style="max-width: 350px">password already changed, please refresh this page</h4>')}),500))},error:function(e,s,a){t.update("progress",0),t.update("type","danger"),t.update("message",a),$("#modChangePassword").modal("hide")}})}})),$(document).ready((function(){$.notifyDefaults({z_index:2e3,mouse_over:"pause",placement:{align:"center"},offset:{y:64}}),setInterval(refreshData,1e3),"undefined"!=typeof isTempPassword&&($("#modChangePassword-oldPassword").attr("disabled",!0),$("#modChangePassword-oldPassword").attr("required",!1),$("#modChangePassword").modal("show"))})),$(".profile-pic").on("error",(function(){"img/default_avatar.png"!=$(this).attr("src")&&$(this).attr("src","img/default_avatar.png")}));