-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
23 lines (20 loc) · 885 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
let serverIP = "pvp.projectenyo.eu"
let serverPort = "25565"
let api = "https://eu.mc-api.net/v3/server/ping/"
window.addEventListener("load", function() {
let ping = api + serverIP + ":" + serverPort
fetch(ping)
.then(response => response.json())
.then(data => {
document.getElementById("online-status").innerHTML = data.online ? "<span class=\"online\">Online</span>" : "<span class=\"offline\">Offline</span>"
document.getElementById("players-online").innerHTML = data.players.online + "/" + data.players.max
// get current map from motd.
// use API to get position of current
// map and change it accordingly.
document.getElementById("current-map").innerHTML = data.description.extra[2].text.trimEnd()
})
.catch(error => {
document.getElementById("online-status").innerHTML = "<span class=\"offline\">Offline</span>"
console.log(error)
})
})