-
Notifications
You must be signed in to change notification settings - Fork 4
/
ttnlora_env_map_table_aw.js
89 lines (71 loc) · 2.41 KB
/
ttnlora_env_map_table_aw.js
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
var holder = document.getElementById('awdatatable');
var table = document.createElement("table");
holder.appendChild(table);
var tr, td, th;
tr = document.createElement("tr");
table.appendChild(tr);
var columns = ['DevUID', 'Area', 'Level', 'Type', 'Value', 'Start', 'End'];
for(j=0; j<columns.length; j++)
{
th = document.createElement('th');
th.innerHTML = columns[j];
tr.appendChild(th);
}
var span = 3600*1000;
var nowInMs = Date.now();
var d = new Date();
var offset = d.getTimezoneOffset();
for (i = 0; i < lastalarmwarnings.length; i++)
{
// if (lastalarmwarnings[i][3] != '0' && lastalarmwarnings[i][4] != '0')
{
var start = new Date(lastalarmwarnings[i][4]); // UTC
start.setSeconds(start.getSeconds() + offset*-60); // UTC > Local
var end = new Date(lastalarmwarnings[i][5]); // UTC
end.setSeconds(end.getSeconds() + offset*-60); // UTC > Local
hasEnded = (lastalarmwarnings[i][5] != "");
tr = document.createElement("tr");
table.appendChild(tr);
// DevUID (with link)
td = document.createElement("td");
td.innerHTML = '<a href="./ttnlora_env_chart.php?id=' + lastalarmwarnings[i][0] + '">' + lastalarmwarnings[i][0] + '</a>';
tr.appendChild(td);
// Area
td = document.createElement("td");
td.innerHTML = lastalarmwarnings[i][6];
td.innerHTML = '<a href="./ttnlora_env_map.php?area=' + lastalarmwarnings[i][6] + '">' + lastalarmwarnings[i][6] + '</a>';
tr.appendChild(td);
// Level
td = document.createElement("td");
td.innerHTML = lastalarmwarnings[i][1];
tr.appendChild(td);
// Type
td = document.createElement("td");
td.innerHTML = lastalarmwarnings[i][2];
tr.appendChild(td);
// Value // todo change type
td = document.createElement("td");
td.innerHTML = lastalarmwarnings[i][3];
tr.appendChild(td);
// Start
td = document.createElement("td");
td.innerHTML = start.toLocaleDateString() + ' ' + start.toLocaleTimeString();
tr.appendChild(td);
// End
td = document.createElement("td");
if (hasEnded)
td.innerHTML = end.toLocaleDateString() + ' ' + end.toLocaleTimeString();
else
td.innerHTML = "---";
tr.appendChild(td);
// Humidity
/*
td = document.createElement("td");
if (lastalarmwarnings[i][6] > 0)
td.innerHTML = lastalarmwarnings[i][6] + ' %';
else
td.innerHTML = '---';
tr.appendChild(td);
*/
}
}