modify refresh behavior
All checks were successful
ci/woodpecker/push/netlify Pipeline was successful

This commit is contained in:
Adora Laura Kalb 2023-08-28 13:46:40 +02:00
parent 8226f440ef
commit bbd794d44e
Signed by: adoralaura
GPG key ID: 7A4552166FC8C056
2 changed files with 10 additions and 5 deletions

View file

@ -9,14 +9,14 @@
<link rel='stylesheet' type='text/css' media='screen' href='/static/style.css'>
<link rel="preload" href="/static/open-sans-v35-latin-regular.woff2" as="font" type="font/woff2" crossorigin>
<script src='/static/main.js' defer></script>
<meta http-equiv="refresh" content="30" />
<!-- <meta http-equiv="refresh" content="30" /> -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
</head>
<body onload="javascript:populatePage()">
<body onload="javascript:PopulatePage(false)">
<h1>LiLa Games 💜</h1>
<div id="gamelist" class="flex">

View file

@ -3,16 +3,21 @@ const template = document.getElementById("game-template").content
const serverdata = "/servers.json"
var gamecontainer = document.getElementById("gamelist")
window.setInterval(PopulatePage, 10000, true)
async function populatePage() {
var request = await fetch(serverdata)
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)
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