-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.html
59 lines (53 loc) · 1.34 KB
/
time.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Time Proxy</title>
</head>
<body>
<script>
(function() {
const params = new URLSearchParams(window.location.search);
const varParamsArray = [...params.entries()].filter(([key]) => key.startsWith('var-'));
const timestamp = params.get('timestamp');
const rangeParam = params.get('range');
const dashboard = params.get('dashboard');
const domain = 'https://monitoring.livedigital.space';
if (!timestamp || !dashboard) {
window.location.replace(domain);
return;
}
let range;
switch (rangeParam) {
case '1m':
range = 60_000;
break;
case '10m':
range = 60_000 * 5;
break;
case '1h':
range = 60_000 * 30;
break;
case '6h':
range = 60_000 * 60 * 3;
break;
case '1d':
range = 60_000 * 60 * 12;
break;
default:
range = 60_000;
}
const originalTime = parseInt(timestamp, 10);
const fromTime = originalTime - range;
const toTime = originalTime + range;
const redirectUrl = new URL(`${domain}/${dashboard}`);
for (const [key, value] of varParamsArray) {
redirectUrl.searchParams.set(key, value);
}
redirectUrl.searchParams.set('from', fromTime);
redirectUrl.searchParams.set('to', toTime);
window.location.replace(redirectUrl.href);
})();
</script>
</body>
</html>