(function () {
|
//获取URL中的参数id
|
var deviceId = getParam("id");
|
|
console.log("------获取URL中的参数-----deviceId=" + deviceId);
|
|
if (!deviceId) {
|
window.parent.notify("没有获取到设备ID,无法查看监控信息");
|
return false;
|
}
|
//根据设备ID从缓存中获取设备基本信息
|
var device = window.parent.getDevice(deviceId);
|
|
//根据设备ID从接口中获取实时监控
|
queryData(deviceId,device);
|
//定时器,每5秒查询一次;查询设备信息并渲染
|
setInterval(function () {
|
queryData(deviceId,device);
|
},5000);
|
|
}).call(this);
|
|
|
function queryData(deviceId,device) {
|
var data = {id: deviceId};
|
$.post("./cgi-bin/detail/query-data", JSON.stringify(data), function (data, status) {
|
if ("success" == status) {
|
console.log('---------获取到的设备实时数据-----' + data);
|
renderInfo(data,device);
|
} else {
|
console.log("数据查询出错,请重新操作!");
|
window.parent.notify("数据查询出错,请重新操作!");
|
}
|
}, "json");
|
};
|
|
|
/**
|
* 获取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;
|
}
|