games/static/main.js
2023-08-23 13:11:43 +02:00

23 lines
No EOL
860 B
JavaScript

const badgeurl = "https://uptime-kuma.lauka.net/api/badge/##/status?style=for-the-badge"
const template = document.getElementById("game-template")
const serverdata = "/servers.json"
var gamecontainer = document.getElementById("gamelist")
async function populatePage() {
var request = await fetch(serverdata)
var data = await request.json()
console.log(data)
data.forEach(server => {
let clone = template.cloneNode(true);
let url = badgeurl.replace("##", server.id)
clone.querySelector("#game-name").innerHTML = server.displayname
clone.querySelector("#game-badge").src = url
clone.querySelector("#game-password").innerHTML = server.password ? "ja" : "nein"
clone.querySelector("#game-whitelist").innerHTML = server.whitelist ? "ja" : "nein"
gamecontainer.appendChild(clone)
});
}