-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
62 lines (52 loc) · 1.93 KB
/
app.js
File metadata and controls
62 lines (52 loc) · 1.93 KB
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
'use strict';
import { state } from './js/state.js';
import { svcId, debounce } from './js/utils.js';
import { renderServices } from './js/render.js';
import { loadServices, refreshAll, clearServiceTimers, startServiceTimers } from './js/services.js';
import { buildSidebarSections, initFilters, initViewToggle, initSortToggle, initZoomControl, initSidebarToggle, startClock, stopClock, startCountdown, stopCountdown } from './js/ui.js';
import { startPingPolling, stopPingPolling } from './js/ping.js';
import { checkForUpdate, initChangelog } from './js/updates.js';
async function init() {
startClock();
initSidebarToggle();
initFilters();
initViewToggle();
initSortToggle();
initZoomControl();
initChangelog();
checkForUpdate(); // fire-and-forget — updates UI when response arrives
state.services = await loadServices();
buildSidebarSections(state.services, state.settings);
document.getElementById('loading-overlay')?.classList.add('hidden');
state.services.forEach(s => { state.statusMap[svcId(s)] = 'loading'; });
renderServices();
await refreshAll();
startCountdown();
startServiceTimers();
startPingPolling(state.settings?.ping_endpoints ?? []);
document.getElementById('refresh-btn')?.addEventListener('click', async () => {
clearServiceTimers();
await refreshAll();
startServiceTimers();
});
document.getElementById('search')?.addEventListener('input', debounce(e => {
state.searchQuery = e.target.value.trim().toLowerCase();
renderServices();
}, 220));
}
document.addEventListener('DOMContentLoaded', init);
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
document.body.classList.add('page-hidden');
stopClock();
stopCountdown();
clearServiceTimers();
stopPingPolling();
} else {
document.body.classList.remove('page-hidden');
startClock();
startCountdown();
startServiceTimers();
startPingPolling(state.settings?.ping_endpoints ?? []);
}
});