返回信息流var url = "http://" + location.hostname + ":8080";
function updatePortStats() {
var statsTableBody = document.getElementById('port-stats-data');
while (statsTableBody.firstChild) {
statsTableBody.removeChild(statsTableBody.firstChild);
}
$.getJSON(url.concat("/stats/switches"), function(switches){
$.each(switches, function(index, dpid){
var hex_dpid = parseInt(dpid).toString(16);
$.getJSON(url.concat("/stats/port/").concat(dpid), function(ports) {
var portStats = ports[dpid];
portStats.sort(function (a,b) {return a.port_no >= b.port_no ? 1 : -1})
var tr = document.createElement('TR');
var physicalPorts = 0;
var switchColTd = document.createElement('TD');
switchColTd.appendChild(document.createTextNode(hex_dpid));
tr.appendChild(switchColTd);
$.each(portStats, function(index, obj) {
if (obj.port_no < 65280) {
physicalPorts += 1;
var statsArray = new Array(obj.port_no, obj.rx_packets, obj.rx_bytes, obj.rx_dropped, obj.rx_errors);
$.each(statsArray, function(index, value) {
var td = document.createElement('TD');
td.appendChild(document.createTextNode(value));
tr.appendChild(td);
});
statsTableBody.appendChild(tr);
tr = document.createElement('TR');
}
});
switchColTd.rowSpan = physicalPorts;
});
});
});
}
updatePortStats();
var portStatsIntervalID = setInterval(function(){updatePortStats()}, 5000);
这个里面的setInterval在360极速模式下能间隔刷新,但是在兼容模式下怎么不能自动刷新?
这是一条镜像帖。来源:北邮人论坛 / java-script / #995同步于 2016/12/13
该镜像源已超过 30 天没有更新,可能在源站已被删除。
JavaScript机器人发帖
小白求问一个小问题
heyzl
2016/12/13镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复