2024-08-25 15:13:57 +02:00
|
|
|
const badgeurl = "https://monitoring.lila.network/api/badge/##/status?style=for-the-badge"
|
2023-08-23 16:17:31 +02:00
|
|
|
const template = document.getElementById("game-template").content
|
2023-08-23 13:11:43 +02:00
|
|
|
const serverdata = "/servers.json"
|
|
|
|
var gamecontainer = document.getElementById("gamelist")
|
|
|
|
|
2023-08-28 13:53:31 +02:00
|
|
|
window.setInterval(PopulatePage, 30000, true)
|
2023-08-23 13:11:43 +02:00
|
|
|
|
2023-08-28 13:46:40 +02:00
|
|
|
async function PopulatePage(reload) {
|
|
|
|
var request = await fetch(serverdata, {cache: "reload"})
|
2023-08-23 13:11:43 +02:00
|
|
|
var data = await request.json()
|
|
|
|
console.log(data)
|
|
|
|
|
2023-08-28 13:46:40 +02:00
|
|
|
if (reload == true) {
|
|
|
|
gamecontainer.innerHTML = ""
|
|
|
|
}
|
|
|
|
|
2023-08-23 13:11:43 +02:00
|
|
|
data.forEach(server => {
|
|
|
|
let clone = template.cloneNode(true);
|
|
|
|
|
2023-08-28 13:48:06 +02:00
|
|
|
let url = badgeurl.replace("##", server.id ) + "&" + String(Date.now())
|
2023-08-23 13:11:43 +02:00
|
|
|
clone.querySelector("#game-name").innerHTML = server.displayname
|
|
|
|
clone.querySelector("#game-badge").src = url
|
2023-08-23 16:17:31 +02:00
|
|
|
clone.querySelector("#game-url").innerHTML = server.serverurl
|
2023-08-24 09:28:05 +02:00
|
|
|
clone.querySelector("#game-password").innerHTML = server.password ? "yes" : "no"
|
|
|
|
clone.querySelector("#game-whitelist").innerHTML = server.whitelist ? "yes" : "no"
|
2023-08-23 13:11:43 +02:00
|
|
|
|
|
|
|
gamecontainer.appendChild(clone)
|
|
|
|
});
|
|
|
|
}
|