-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
119 lines (114 loc) · 3.63 KB
/
index.html
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
115
116
117
118
119
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A layout example that shows off a responsive product landing page.">
<title>Landing Page – Layout Examples – Pure</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/build/pure-min.css"
integrity="sha384-cg6SkqEOCV1NbJoCu11+bm0NvBRc8IYLRGXkmNrqUBfTjmMYwNKPWBTIKyw9mHNJ" crossorigin="anonymous">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css">
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<div class="pure-g">
<div class="pure-u-1-24"></div>
<div class="pure-u-22-24">
<table class="pure-table pure-table-horizontal">
<thead>
<tr>
<th>Server</th>
<th>#</th>
</tr>
</thead>
<tbody>
<tr>
<td>Global Counter</td>
<td>
<div id="gobalCount"></div>
</td>
</tr>
<tr>
<td>N° sessions</td>
<td>
<div id="sessions"></div>
</td>
</tr>
</tbody>
</table>
<table class="pure-table pure-table-horizontal">
<thead>
<tr>
<th>Session</th>
<th>#</th>
</tr>
</thead>
<tbody>
<tr>
<td>Session ID</td>
<td>
<div id="sessionID"></div>
</td>
</tr>
<tr>
<td>Session Counter</td>
<td>
<div id="sessionCount"></div>
</td>
</tr>
</tbody>
</table>
<table class="pure-table pure-table-horizontal">
<thead>
<tr>
<th>TimeStamp</th>
<th>#</th>
</tr>
</thead>
<tbody>
<tr>
<td>Server Time</td>
<td>
<div id="timestamp_server"></div>
</td>
</tr>
<tr>
<td>Client Time</td>
<td>
<div id="timestamp_client"></div>
</td>
</tr>
<tr>
<td>Diff. Server/Client</td>
<td>
<div id="diffTimestamp"></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="pure-u-1-14"></div>
</div>
<script type="text/javascript">
const source = new EventSource('/events');
source.addEventListener('message', message => {
try {
const msg = JSON.parse(event.data);
console.log('Got', event);
console.log('Got', msg);
const tc = new Date().getTime();
document.querySelector('#gobalCount').innerHTML = msg.gobalCount;
document.querySelector('#sessions').innerHTML = msg.sessions;
document.querySelector('#sessionCount').innerHTML = msg.sessionCount;
document.querySelector('#sessionID').innerHTML = msg.sessionID;
document.querySelector('#timestamp_server').innerHTML = new Date(msg.t).toISOString();
document.querySelector('#timestamp_client').innerHTML = new Date(tc).toISOString();
document.querySelector('#diffTimestamp').innerHTML = new Date(msg.t - tc).getTime();
document.querySelector('#eventTimestamp').innerHTML = new Date(event.timeStamp).getTime();
} catch (error) {
console.error(error);
};
});
</script>
</body>
</html>