From bbd794d44e21591b647f31461c8ddaf15860f399 Mon Sep 17 00:00:00 2001 From: lauralani Date: Mon, 28 Aug 2023 13:46:40 +0200 Subject: [PATCH] modify refresh behavior --- index.html | 4 ++-- static/main.js | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index c2637d2..4bdc041 100644 --- a/index.html +++ b/index.html @@ -9,14 +9,14 @@ - + - +

LiLa Games 💜

diff --git a/static/main.js b/static/main.js index c120c87..b198c33 100644 --- a/static/main.js +++ b/static/main.js @@ -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