document.addEventListener("DOMContentLoaded",()=>{{const t=e=>{const t=1024,o=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(e)/Math.log(t));return(e/Math.pow(t,a)).toPrecision(3)+" "+o[a]},o=[],a=[],r=[],l=document.querySelector("#flow"),i=document.querySelector("#work"),s=l&&echarts.init(l),n=i&&echarts.init(i);function e(){$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"server_status"},success(l){{$(".joe_census__server-item .count .up").html(`总发送:${t(l.upTotal)}`),$(".joe_census__server-item .count .down").html(`总接收:${t(l.downTotal)}`);const e=new Date,i=String(e.getHours()).padStart(2,0),n=String(e.getMinutes()).padStart(2,0),c=String(e.getSeconds()).padStart(2,0),m=`${i}:${n}:${c}`;o.push(m),a.push(l.up),r.push(l.down),o.length>5&&o.shift(),a.length>5&&a.shift(),r.length>5&&r.shift(),s.setOption({title:{subtext:"单位 KB/s"},grid:{left:"3%",right:"4%",bottom:"0",containLabel:!0},tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},xAxis:{axisTick:{show:!1},type:"category",boundaryGap:!1,data:o},yAxis:{type:"value"},series:[{type:"line",name:"上行",smooth:!0,showSymbol:!1,itemStyle:{normal:{color:"#f39494",areaStyle:{color:"#f39494"},lineStyle:{width:2,color:"#f39494"}}},stack:"总量",data:a},{type:"line",name:"下行",smooth:!0,showSymbol:!1,itemStyle:{normal:{color:"#9dd3e8",areaStyle:{color:"#9dd3e8"},lineStyle:{width:2,color:"#9dd3e8"}}},stack:"总量",data:r}]})}{const e=l.cpu[0],t=Math.round(l.memory.memRealUsed/l.memory.memTotal*1e3)/10,o=Math.round(l.memory.memCached/l.memory.memTotal*1e3)/10,a=Math.round(l.memory.memBuffers/l.memory.memTotal*1e3)/10,r=Math.round(l.load.one/l.load.max*100)>100?100:Math.round(l.load.one/l.load.max*100);n.setOption({title:{subtext:"单位 百分比"},tooltip:{trigger:"axis",axisPointer:{type:"shadow"}},grid:{left:"3%",right:"3%",bottom:"3%",containLabel:!0},xAxis:{type:"category",axisTick:{show:!1},data:["CPU占用","内存占用","系统缓冲","内存缓冲","系统负载"]},yAxis:{type:"value"},series:{data:[{name:"CPU占用",value:e,itemStyle:{color:"#b3c25a"}},{name:"内存占用",value:t,itemStyle:{color:"#67b580"}},{name:"系统缓冲",value:a,itemStyle:{color:"#86ba71"}},{name:"内存缓冲",value:o,itemStyle:{color:"#feb041"}},{name:"系统负载",value:r,itemStyle:{color:"#fd7e55"}}],type:"bar",showBackground:!0,label:{show:!0,color:"#ffffff",formatter:e=>`${e.data.value} %`},backgroundStyle:{color:"rgba(180, 180, 180, 0.2)"}}})}setTimeout(e,2e3)}})}l&&i&&e()}{const e=document.querySelector("#category"),t=echarts.init(e),o=[];$(".joe_census__basic-item.category ul li").each((e,t)=>{o.push({name:t.getAttribute("data-name"),value:t.getAttribute("data-value")})}),t.setOption({tooltip:{trigger:"item"},series:[{type:"pie",roseType:"area",itemStyle:{borderRadius:8},data:o}]})}{const e=document.querySelector("#lately"),t=echarts.init(e);$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"comment_lately"},success(e){t.setOption({tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},grid:{left:"3%",right:"3%",bottom:"3%",containLabel:!0},xAxis:{type:"category",axisTick:{show:!1},data:e.categories},yAxis:{type:"value"},series:{name:"数量",itemStyle:{normal:{color:"#91cc75",lineStyle:{width:2,color:"#91cc75"}}},data:e.series,type:"line",smooth:!0}})}})}});