-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (25 loc) · 1.22 KB
/
index.js
File metadata and controls
32 lines (25 loc) · 1.22 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
const funkyStationUrl = "https://status.funkystation.org/lrp/status"
const funkyStationMrpUrl = "https://status.funkystation.org/mrp/status"
const funkyStationSandboxUrl = "https://status.funkystation.org/sandbox/status"
async function updateServerStatus(id, source) {
const serverCard = document.getElementById(id);
const serverStatus = serverCard.parentElement;
try {
const response = await fetch(source);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const json = await response.json();
// serverCard.querySelector('.server-name').innerText = json.name;
serverStatus.querySelector('.server-players').innerText = json.players;
serverStatus.querySelector('.server-maxplayers').innerText = json.soft_max_players;
serverStatus.querySelector('.server-preset').innerText = json.preset;
serverStatus.querySelector('.server-map').innerText = json.map ?? "Lobby";
} catch (error) {
serverStatus.innerHTML = "Unable to contact server.";
console.error(error.message);
}
}
await updateServerStatus('server-cirno', funkyStationUrl);
await updateServerStatus('server-scarlet', funkyStationMrpUrl);
await updateServerStatus('server-marisa', funkyStationSandboxUrl);