blob: ea1791839e1b8e74910846f7833296a288853d49 (
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
|
const tabs = [...document.querySelectorAll('[role="tab"]')];
const panels = [...document.querySelectorAll('[role="tabpanel"]')];
tabs.forEach((tab) => tab.addEventListener('click', () => {
tabs.forEach((item) => item.setAttribute('aria-selected', String(item === tab)));
panels.forEach((panel) => {
const active = panel.id === tab.dataset.panel;
panel.hidden = !active;
panel.classList.toggle('active', active);
});
}));
fetch('/api/node/get_info', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: '{}'
}).then((response) => {
if (!response.ok) throw new Error('node unavailable');
return response.json();
}).then((info) => {
document.querySelector('#node-state').textContent = info.status === 'OK' ? 'Online' : info.status;
document.querySelector('#height').textContent = Number(info.height).toLocaleString();
document.querySelector('#peers').textContent = Number(info.incoming_connections_count || 0) + Number(info.outgoing_connections_count || 0);
}).catch(() => {
document.querySelector('#node-state').textContent = 'Unavailable';
});
|