Jony/assets/js/joe.census.min.js

1 line
5.0 KiB
JavaScript
Raw Normal View History

2021-05-21 09:27:27 +00:00
document.addEventListener("DOMContentLoaded",()=>{{const e=t=>{if(!t)return"0 B";const e=1024,o=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(t)/Math.log(e));return(t/Math.pow(e,a)).toPrecision(3)+" "+o[a]},o=[],a=[],n=[],i=document.querySelector("#flow"),l=document.querySelector("#work"),s=i&&echarts.init(i),r=l&&echarts.init(l);function t(){$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"server_status"},success(i){i.status||Qmsg.warning("服务器接口异常!");{$(".joe_census__server-item .count .up").html(`总发送:${e(i.upTotal)}`),$(".joe_census__server-item .count .down").html(`总接收:${e(i.downTotal)}`);const t=new Date,l=String(t.getHours()).padStart(2,0),r=String(t.getMinutes()).padStart(2,0),c=String(t.getSeconds()).padStart(2,0),d=`${l}:${r}:${c}`;o.push(d),a.push(i.up),n.push(i.down),o.length>5&&o.shift(),a.length>5&&a.shift(),n.length>5&&n.shift(),s.setOption({title:{subtext:"单位 KB/s"},grid:{left:"3%",right:"4%",bottom:"3%",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:n}]})}{const t=i.cpu[0],e=Math.round(i.memory.memRealUsed/i.memory.memTotal*1e3)/10,o=Math.round(i.memory.memCached/i.memory.memTotal*1e3)/10,a=Math.round(i.memory.memBuffers/i.memory.memTotal*1e3)/10,n=Math.round(i.load.one/i.load.max*100)>100?100:Math.round(i.load.one/i.load.max*100);r.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:t,itemStyle:{color:"#b3c25a"}},{name:"内存占用",value:e,itemStyle:{color:"#67b580"}},{name:"系统缓冲",value:a,itemStyle:{color:"#86ba71"}},{name:"内存缓冲",value:o,itemStyle:{color:"#feb041"}},{name:"系统负载",value:n,itemStyle:{color:"#fd7e55"}}],type:"bar",showBackground:!0,label:{show:!0,color:"#ffffff",formatter:t=>`${t.data.value} %`},backgroundStyle:{color:"rgba(180, 180, 180, 0.2)"}}})}setTimeout(t,2e3)}})}i&&l&&t()}{const t=document.querySelector("#category"),e=echarts.init(t),o=[];$(".joe_census__basic-item.category ul li").each((t,e)=>{o.push({name:e.getAttribute("data-name"),value:e.getAttribute("data-value")})}),e.setOption({tooltip:{trigger:"item"},series:[{type:"pie",roseType:"area",itemStyle:{borderRadius:8},data:o}]})}{const t=document.querySelector("#lately"),e=echarts.init(t);$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"comment_lately"},success(t){e.setOption({title:{subtext:"单位 数量"},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:t.categories},yAxis:{type:"value"},series:{name:"数量",itemStyle:{normal:{color:"#91cc75",lineStyle:{width:2,color:"#91cc75"}}},data:t.series,type:"line",smooth:!0}})}})}{let t=0;function e(){"loading..."!==$(".joe_census__filing .button").html()&&$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"article_filing",page:++t},success(t){if(!t.length)return $(".joe_census__filing .item.load").remove(),Qmsg.warning("没有更多内容了");let e="";t.forEach(t=>{e+=`\n\t\t\t\t\t\t\t<div class="item">\n\t\t\t\t\t\t\t\t<div class="tail"></div>\n\t\t\t\t\t\t\t\t<div class="head"></div>\n\t\t\t\t\t\t\t\t<div class="wrapper">\n\t\t\t\t\t\t\t\t\t<div class="panel">${t.date}<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path