mirror of
https://github.com/Kizuren/statusPage.git
synced 2025-12-21 21:16:09 +01:00
Initial client script.
This commit is contained in:
parent
c0db0a4e27
commit
2b4f959525
1 changed files with 22 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
const engine = new liquidjs.Liquid();
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
let $main = document.querySelector('main');
|
||||
const templateLiquid = document.querySelector("template#site").innerHTML;
|
||||
const template = await engine.parse(templateLiquid);
|
||||
|
||||
const refreshStatus = async () => {
|
||||
try {
|
||||
const response = await fetch('/status.json');
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error fetching status.json: ${response.statusText}`);
|
||||
}
|
||||
const status = await response.json();
|
||||
|
||||
$main.innerHTML = template.render(status);
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error loading server status:", error);
|
||||
}
|
||||
};
|
||||
setInterval(refreshStatus, 60_000); // Refresh every minute
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue