-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (36 loc) · 963 Bytes
/
index.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
const wa = import('./kunovski');
const { refreshTimeout } = require('./snippets')
const re = document.getElementById('refresh');
wa.then(wa => {
// Hack! Fixme. So that update in snippets can schedule a timeout
window.start = (options) => {
const partial = options && options.partial;
const scheduled = options && options.schedules;
if (!scheduled) {
clearTimeout(refreshTimeout);
}
wa.start(partial);
};
// Initialize the corpus (takes up to a second).
wa.init();
const defer = timeout => {
setTimeout(() => {
start();
}, timeout);
};
const visChange = () => {
if (!document.hidden) {
defer(500);
}
};
if (document.hidden) {
document.addEventListener("visibilitychange", visChange);
} else {
start();
}
re.addEventListener('click', e => {
e.preventDefault();
document.getElementById('links').classList.toggle('active', false);
start();
}, false);
});