lgq
2025-05-26 0e3ba084acf8e7b880a19ef6107d77a8cab1f83a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//定义全局变量,存放同类型设备信息
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;
}