blob: 1e62849f3c45f12728e341cb94952dda3801aaf3 (
plain)
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
|
<script type="text/javascript">
/**
* Dev toolset
*/
console.log('Welcome to cState! https://github.com/mistermantas/cstate');
document.querySelector('html').className = 'js';
/**
* Make theme color pretty
*/
if (document.body.className === 'status-down') {
document.querySelector('meta[name=theme-color]').setAttribute('content', themeDownColor);
} else if (document.body.className === 'status-disrupted') {
document.querySelector('meta[name=theme-color]').setAttribute('content', themeDisruptedColor);
} else {
document.querySelector('meta[name=theme-color]').setAttribute('content', themeNoticeColor);
}
/**
* Check for internet
*/
var lastUpdated = document.querySelector('.summary__date');
var lastUpdate = new Date();
function timeSince(date) {
var seconds = Math.floor((new Date() - date) / 1000);
var interval = Math.floor(seconds / 31536000);
if (interval > 1) {
return interval + ' years';
}
interval = Math.floor(seconds / 2592000);
if (interval > 1) {
return interval + ' months';
}
interval = Math.floor(seconds / 86400);
if (interval > 1) {
return interval + 'd';
}
interval = Math.floor(seconds / 3600);
if (interval > 1) {
return interval + 'h';
}
interval = Math.floor(seconds / 60);
if (interval > 1) {
return interval + 'min';
}
return Math.floor(seconds) + 's';
}
var aDay = 24*60*60*1000;
// Show second by second updates
window.setInterval(function() {
lastUpdated.innerHTML = 'Last checked ' + timeSince(lastUpdate) + ' ago';
}, 1000);
</script>
|