games/static/main.js
Adora Laura Kalb 7e0d172f6c
All checks were successful
ci/woodpecker/push/netlify Pipeline was successful
update badge url
2024-08-25 15:13:57 +02:00

29 lines
No EOL
1.1 KiB
JavaScript

const badgeurl = "https://monitoring.lila.network/api/badge/##/status?style=for-the-badge"
const template = document.getElementById("game-template").content
const serverdata = "/servers.json"
var gamecontainer = document.getElementById("gamelist")
window.setInterval(PopulatePage, 30000, true)
async function PopulatePage(reload) {
var request = await fetch(serverdata, {cache: "reload"})
var data = await request.json()
console.log(data)
if (reload == true) {
gamecontainer.innerHTML = ""
}
data.forEach(server => {
let clone = template.cloneNode(true);
let url = badgeurl.replace("##", server.id ) + "&" + String(Date.now())
clone.querySelector("#game-name").innerHTML = server.displayname
clone.querySelector("#game-badge").src = url
clone.querySelector("#game-url").innerHTML = server.serverurl
clone.querySelector("#game-password").innerHTML = server.password ? "yes" : "no"
clone.querySelector("#game-whitelist").innerHTML = server.whitelist ? "yes" : "no"
gamecontainer.appendChild(clone)
});
}