aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/launcher.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/js/launcher.js')
-rw-r--r--src/app/js/launcher.js40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/app/js/launcher.js b/src/app/js/launcher.js
index 6fe1686..913762b 100644
--- a/src/app/js/launcher.js
+++ b/src/app/js/launcher.js
@@ -1,11 +1,13 @@
const markdown = require("marked").parse;
+let launcher = {};
+
var servercount;
var playercount;
var masterserver;
// changes the main page, this is the tabs in the sidebar
-function page(page) {
+launcher.change_page = (page) => {
let btns = document.querySelectorAll(".gamesContainer button");
let pages = document.querySelectorAll(".mainContainer .contentContainer");
@@ -20,9 +22,9 @@ function page(page) {
pages[page].classList.remove("hidden");
btns[page].classList.remove("inactive");
bgHolder.setAttribute("bg", page);
-}; page(1)
+}; launcher.change_page(1)
-function formatRelease(notes) {
+launcher.format_release = (notes) => {
if (! notes) {return ""}
let content = "";
@@ -61,7 +63,7 @@ function formatRelease(notes) {
// sets content of `div` to a single release block with centered text
// inside it, the text being `lang(lang_key)`
-let set_error_content = (div, lang_key) => {
+launcher.error = (div, lang_key) => {
div.innerHTML =
"<div class='release-block'>" +
"<p><center>" +
@@ -73,39 +75,39 @@ let set_error_content = (div, lang_key) => {
// updates the Viper release notes
ipcRenderer.on("vp-notes", (event, response) => {
if (! response) {
- return set_error_content(
+ return launcher.error(
vpReleaseNotes,
"request.no_vp_release_notes"
)
}
- vpReleaseNotes.innerHTML = formatRelease(response);
+ vpReleaseNotes.innerHTML = launcher.format_release(response);
});
// updates the Northstar release notes
ipcRenderer.on("ns-notes", (event, response) => {
if (! response) {
- return set_error_content(
+ return launcher.error(
nsRelease,
"request.no_ns_release_notes"
)
}
- nsRelease.innerHTML = formatRelease(response);
+ nsRelease.innerHTML = launcher.format_release(response);
});
-async function loadVpReleases() {
+launcher.load_vp_notes = async () => {
ipcRenderer.send("get-vp-notes");
-}; loadVpReleases();
+}; launcher.load_vp_notes();
-async function loadNsReleases() {
+launcher.load_ns_notes = async () => {
ipcRenderer.send("get-ns-notes");
-}; loadNsReleases();
+}; launcher.load_ns_notes();
// TODO: We gotta make this more automatic instead of switch statements
// it's both not pretty, but adding more sections requires way too much
// effort, compared to how it should be.
-function showVpSection(section) {
+launcher.show_vp = (section) => {
if (!["main", "release", "info", "credits"].includes(section)) throw new Error("unknown vp section");
vpMainBtn.removeAttribute("active");
vpReleaseBtn.removeAttribute("active");
@@ -131,8 +133,8 @@ function showVpSection(section) {
}
}
-function showNsSection(section) {
- if (!["main", "release", "mods"].includes(section)) {
+launcher.show_ns = (section) => {
+ if (! ["main", "release", "mods"].includes(section)) {
throw new Error("unknown ns section");
}
@@ -161,7 +163,7 @@ function showNsSection(section) {
}
}
-async function loadServers() {
+launcher.check_servers = async () => {
serverstatus.classList.add("checking");
try {
@@ -205,9 +207,11 @@ async function loadServers() {
serverstatus.innerHTML = lang("gui.server.offline");
}
-}; loadServers()
+}; launcher.check_servers()
// refreshes every 5 minutes
setInterval(() => {
- loadServers();
+ launcher.check_servers();
}, 300000)
+
+module.exports = launcher;