//定义全局变量,存放同类型设备信息
|
var deviceList;
|
|
(function () {
|
//获取URL中的参数id
|
var type = getParam("type");
|
|
console.log("------获取URL中的参数-----type=" + type);
|
|
if (!type) {
|
window.parent.notify("没有获取到设备类型,无法查看监控信息");
|
return false;
|
}
|
|
//根据设备类型从缓存中获取所有设备
|
deviceList = window.parent.getDeviceByType(type);
|
|
//根据设备类型type从接口中获取同类型设备实时监控
|
queryData();
|
//定时器,每5秒查询一次;查询设备信息并渲染
|
setInterval(queryData,5000);
|
|
}).call(this);
|
|
function queryData() {
|
$.ajaxSettings.async = false;
|
var dataList = new Array();
|
//遍历同类型设备集合,根据id查询数据后保存
|
for (var i = 0; i < deviceList.length; i++) {
|
$.post("./cgi-bin/detail/query-data", JSON.stringify({id: deviceList[i].id}), function (data, status) {
|
if ("success" == status) {
|
console.log(data);
|
dataList.push(data);
|
}
|
}, "json");
|
}
|
if (dataList != null && dataList.length > 0) {
|
renderInfo(dataList);
|
} else {
|
window.parent.notify("数据查询出错,请重新操作!!");
|
}
|
}
|
|
/**
|
* 获取URL中的参数
|
* @param name
|
* @returns {string|null}
|
*/
|
function getParam(name) {
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
var r = window.location.search.substr(1).match(reg);
|
if (r != null) return unescape(r[2]);
|
return null;
|
}
|