function refreshData(){const e=isWebInterface?"web":"iframe";txAdminAPI({url:`status/${e}`,type:"GET",timeout:REQ_TIMEOUT_SHORT,success:function(e){e.logout?window.location="/auth?logout":($("#status-card").html(e.status),isWebInterface&&($("#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),$("#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}`,$("#status-card").html(a.replace("\n","\n<br>")),isWebInterface&&($("#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"),$("#favicon").attr("href","img/favicon_offline.png"),document.title="ERROR - txAdmin",processPlayers(a))}})}function changeOwnPasswordModal(){$("#modChangePassword").modal("show")}document.getElementById("modChangePassword-save").onclick=e=>{const s={newPassword:$("#modChangePassword-newPassword").val().trim(),confirmPassword:$("#modChangePassword-confirmPassword").val().trim()},t=[];if(s.newPassword.length&&s.confirmPassword.length||t.push("The new password fields are required."),s.newPassword!==s.confirmPassword&&t.push("Your new password doesn't match the one typed in the confirmation input."),"undefined"==typeof isTempPassword&&(s.oldPassword=$("#modChangePassword-oldPassword").val().trim(),s.oldPassword.length||t.push("The old password field is required."),s.oldPassword===s.confirmPassword&&t.push("The new password must be different than the old one.")),(s.newPassword.length<6||s.newPassword.length>24)&&t.push("The new password has to be between 6 and 24 characters."),t.length)return $.notify({message:"<b>Errors:</b><br> - "+t.join(" <br>\n - ")},{type:"warning"});const a=$.notify({message:'<p class="text-center">Saving...</p>'},{});txAdminAPI({type:"POST",url:"/changePassword",data:s,dataType:"json",success:function(e){a.update("progress",0),a.update("type",e.type),a.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,t){a.update("progress",0),a.update("type","danger"),a.update("message",t),$("#modChangePassword").modal("hide")}})},document.addEventListener("DOMContentLoaded",(function(e){refreshData(),setInterval(refreshData,STATUS_REFRESH_INTERVAL),"undefined"!=typeof isTempPassword&&$("#modChangePassword").modal("show")}));