|
2 | 2 | <html>
|
3 | 3 | <head>
|
4 | 4 | <link rel=stylesheet type="text/css" href="/house.css" title="House">
|
| 5 | +<script src="/events.js"></script> |
5 | 6 | <script>
|
6 |
| -function ntpShowStatus (response) { |
7 |
| - document.getElementById('portal').href = 'http://'+response.proxy+'/index.html'; |
8 |
| -} |
9 |
| - |
10 |
| -function ntpStatus () { |
11 |
| - var command = new XMLHttpRequest(); |
12 |
| - command.open("GET", "/ntp/status"); |
13 |
| - command.onreadystatechange = function () { |
14 |
| - if (command.readyState === 4 && command.status === 200) { |
15 |
| - ntpShowStatus (JSON.parse(command.responseText)); |
16 |
| - } |
17 |
| - } |
18 |
| - command.send(null); |
19 |
| -} |
20 | 7 | window.onload = function() {
|
21 |
| - |
22 |
| - function newColumn (text) { |
23 |
| - var column = document.createElement("td"); |
24 |
| - column.innerHTML = text; |
25 |
| - return column; |
26 |
| - } |
27 |
| - |
28 |
| - var lastEventId = null; |
29 |
| - |
30 |
| - function showEvents (response) { |
31 |
| - |
32 |
| - if (!lastEventId) { |
33 |
| - var title = response.host + ' - NTP Events'; |
34 |
| - document.getElementsByTagName ('title')[0].innerHTML = title; |
35 |
| - var elements = document.getElementsByClassName ('hostname'); |
36 |
| - for (var i = 0; i < elements.length; i++) { |
37 |
| - elements[i].innerHTML = response.host; |
38 |
| - } |
39 |
| - } |
40 |
| - |
41 |
| - lastEventId = response.ntp.latest; |
42 |
| - |
43 |
| - var table = document.getElementsByClassName ('eventlist')[0]; |
44 |
| - for (var i = table.childNodes.length - 1; i > 1; i--) { |
45 |
| - table.removeChild(table.childNodes[i]); |
46 |
| - } |
47 |
| - for (var i = response.ntp.events.length-1; i >= 0; --i) { |
48 |
| - var event = response.ntp.events[i]; |
49 |
| - var timestamp = new Date(event[0]); |
50 |
| - var row = document.createElement("tr"); |
51 |
| - row.appendChild(newColumn(timestamp.toLocaleString())); |
52 |
| - row.appendChild(newColumn(event[1])); |
53 |
| - row.appendChild(newColumn(event[2])); |
54 |
| - row.appendChild(newColumn(event[3])); |
55 |
| - row.appendChild(newColumn(event[4])); |
56 |
| - table.appendChild(row); |
57 |
| - } |
58 |
| - } |
59 |
| - |
60 |
| - function updateEvents() { |
61 |
| - |
62 |
| - var command = new XMLHttpRequest(); |
63 |
| - command.open("GET", "/ntp/log/events"); |
64 |
| - command.onreadystatechange = function () { |
65 |
| - if (command.readyState === 4 && command.status === 200) { |
66 |
| - showEvents (JSON.parse(command.responseText)); |
67 |
| - } |
68 |
| - } |
69 |
| - command.send(null); |
70 |
| - } |
71 |
| - |
72 |
| - function checkEvents () { |
73 |
| - |
74 |
| - var command = new XMLHttpRequest(); |
75 |
| - command.open("GET", "/ntp/log/latest"); |
76 |
| - command.onreadystatechange = function () { |
77 |
| - if (command.readyState === 4 && command.status === 200) { |
78 |
| - var response = JSON.parse(command.responseText); |
79 |
| - if ((lastEventId == null) || |
80 |
| - (response.ntp.latest != lastEventId)) updateEvents (); |
81 |
| - } |
82 |
| - } |
83 |
| - command.send(null); |
84 |
| - } |
85 |
| - |
86 |
| - updateEvents(); |
87 |
| - setInterval (function() {checkEvents()}, 1000); |
88 |
| - ntpStatus(); |
| 8 | + eventStart('/ntp'); |
89 | 9 | }
|
90 | 10 | </script>
|
91 | 11 | <head>
|
|
0 commit comments