games/static/main.js
lauralani 2656a8c558
All checks were successful
ci/woodpecker/push/netlify Pipeline was successful
update style and translate to english
2023-08-24 09:28:05 +02:00

24 lines
No EOL
936 B
JavaScript

const badgeurl = "https://uptime-kuma.lauka.net/api/badge/##/status?style=for-the-badge"
const template = document.getElementById("game-template").content
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-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)
});
}