aboutsummaryrefslogtreecommitdiff
path: root/src/app/launcher.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-05-28 01:52:03 +0200
committer0neGal <mail@0negal.com>2022-05-28 01:52:03 +0200
commita844a146e88faa0c5f7239b5d05869868f2a2aab (patch)
treec21d60fae9b1015f0fad1fb0edc7843182b3144c /src/app/launcher.js
parent0f9d80cce91960350c42a50cbbee0a8d4e0c8713 (diff)
downloadViper-a844a146e88faa0c5f7239b5d05869868f2a2aab.tar.gz
Viper-a844a146e88faa0c5f7239b5d05869868f2a2aab.zip
initial commit for master server status
This doesn't fully implement everything as the master server is down whilst making this commit, so I can't fully implement it.
Diffstat (limited to 'src/app/launcher.js')
-rw-r--r--src/app/launcher.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/app/launcher.js b/src/app/launcher.js
index 51d3a63..f426775 100644
--- a/src/app/launcher.js
+++ b/src/app/launcher.js
@@ -1,5 +1,9 @@
const markdown = require("marked").parse;
+var servercount;
+var playercount;
+var masterserver;
+
// Changes the main page
// This is the tabs in the sidebar
function page(page) {
@@ -107,3 +111,39 @@ function showNsSection(section) {
break;
}
}
+
+async function loadServers() {
+ serverstatus.classList.add("checking");
+
+ try {
+ let servers = await (await fetch("https://northstar.tf/client/servers/")).json();
+ masterserver = true;
+ }catch (err) {
+ playercount = 0;
+ servercount = 0;
+ masterserver = false;
+ }
+
+ serverstatus.classList.remove("checking");
+
+ if (servercount == 0) {masterserver = false}
+
+ if (masterserver) {
+ serverstatus.classList.add("up");
+ // servercount and playercount don't actually get set anywhere,
+ // the reason for this is, while writing this code, the master
+ // server is down so I don't have anyway to test the code...
+ //
+ // it'll be added whenever the masterserver comes online again.
+ serverstatus.innerHTML = `${servercount} ${lang("gui.server.servers")} - ${playercount} ${lang("gui.server.players")}`;
+ } else {
+ serverstatus.classList.add("down");
+ serverstatus.innerHTML = lang("gui.server.offline");
+
+ }
+}; loadServers()
+
+// Refreshes every 5 minutes
+setInterval(() => {
+ loadServers();
+}, 300000)