games/static/main.js

24 lines
936 B
JavaScript
Raw Normal View History

2023-08-23 13:11:43 +02:00
const badgeurl = "https://uptime-kuma.lauka.net/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")
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
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)
});
}