-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
114 lines (92 loc) · 3.81 KB
/
index.html
File metadata and controls
114 lines (92 loc) · 3.81 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="styles/styles.css">
<meta http-equiv="refresh" content="15"> <!--в content=указывается задержка в секундах на обновление информации-->
</head>
<div class="table" id="devicesTable" width='100%' align="center">
<div class="table-title">
<h3>Состояние устройств</h3>
</div>
</div>
<body>
<script>
function resultJson(devicesData)
{
let thValues = ["№", "Имя Хоста", "IP-адрес", "Состояние т.", "Состояние п.", "Время опроса", "Описание"];
createTable(thValues, devicesData); //создание таблицы
}
function createTable(thValues, devicesData)
{
//создание таблицы
let cols = thValues.length;
let rows = Object.keys(devicesData.index).length; //определение, сколько рядов создавать
//console.log(rows)
var Name = document.querySelector('#devicesTable');
var table = document.createElement('table');
//создание заголовков колонок таблицы
for (let i = 0; i < cols; i++)
{
var th = document.createElement('th');
var vth = document.createTextNode(thValues[i]);
th.appendChild(vth);
table.appendChild(th);
}
//создание ячеек таблицы
for (var i = 0; i < rows; i++)
{
var tr = document.createElement('tr');
var td = document.createElement('td');
td.innerHTML = i+1;
tr.appendChild(td);
td = document.createElement('td');
td.innerHTML = devicesData.index[i]['hostname'];
tr.appendChild(td);
td = document.createElement('td');
td.innerHTML = devicesData.index[i]['IPadd'];
tr.appendChild(td);
td = document.createElement('td');
td.innerHTML = devicesData.index[i]['currently state'];
if (devicesData.index[i]['currently state'] == 'Online')
{
td.className = 'online';
}
else
{
td.className = 'offline';
}
tr.appendChild(td);
td = document.createElement('td');
td.innerHTML = devicesData.index[i]['past state'];
if (devicesData.index[i]['past state'] == 'Online')
{
td.className = 'onlinepast';
}
else
{
td.className = 'offlinepast';
}
tr.appendChild(td);
td = document.createElement('td');
td.innerHTML = devicesData.index[i]['currently time'];
tr.appendChild(td);
td = document.createElement('td');
td.innerHTML = devicesData.index[i]['Description'];
tr.appendChild(td);
table.appendChild(tr);
}
Name.appendChild(table);
}
for (i=0; i <1; i++)
{
$.getJSON('devices.json', function (devicesData)
{
resultJson(devicesData);
});
}
</script>
</body>
</html>