aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/index.html8
-rw-r--r--src/app/main.js2
-rw-r--r--src/app/settings.js56
3 files changed, 61 insertions, 5 deletions
diff --git a/src/app/index.html b/src/app/index.html
index 7a919b1..0bd6694 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -37,7 +37,7 @@
</div>
<div class="options">
<h2>Northstar</h2>
- <div class="option">
+ <div class="option" name="nsargs">
<div class="text">
Launch options
<div class="desc">
@@ -49,7 +49,7 @@
</div>
</div>
<h2>Updates</h2>
- <div class="option">
+ <div class="option" name="autoupdate">
<div class="text">
Viper Auto-Updates
<div class="desc">
@@ -60,7 +60,7 @@
<button class="switch on"></button>
</div>
</div>
- <div class="option">
+ <div class="option" name="nsupdate">
<div class="text">
Northstar Auto-Updates
<div class="desc">
@@ -71,7 +71,7 @@
<button class="switch on"></button>
</div>
</div>
- <div class="option">
+ <div class="option" name="excludes" type="array">
<div class="text">
Retain files on update
<div class="desc">
diff --git a/src/app/main.js b/src/app/main.js
index db3514b..a781ef1 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -8,7 +8,9 @@ let shouldInstallNorthstar = false;
// Base settings
var settings = {
+ nsargs: "",
gamepath: "",
+ nsupdate: true,
autoupdate: true,
zip: "/northstar.zip",
lang: navigator.language,
diff --git a/src/app/settings.js b/src/app/settings.js
index c9e43ae..e558d61 100644
--- a/src/app/settings.js
+++ b/src/app/settings.js
@@ -1,6 +1,7 @@
var Settings = {
toggle: (state) => {
if (state) {
+ Settings.load();
options.scrollTo(0, 0);
overlay.classList.add("shown")
options.classList.add("shown")
@@ -14,6 +15,7 @@ var Settings = {
}
}
+ Settings.load();
options.scrollTo(0, 0);
overlay.classList.toggle("shown")
options.classList.toggle("shown")
@@ -39,8 +41,60 @@ var Settings = {
}
Settings.reloadSwitches();
+ },
+ get: () => {
+ let opts = {};
+ let options = document.querySelectorAll(".option");
+
+ for (let i = 0; i < options.length; i++) {
+ let optName = options[i].getAttribute("name");
+ if (options[i].querySelector(".actions input")) {
+ let input = options[i].querySelector(".actions input").value;
+ if (options[i].getAttribute("type")) {
+ opts[optName] = input.split(" ");
+ } else {
+ opts[optName] = input;
+ }
+ } else if (options[i].querySelector(".actions .switch")) {
+ if (options[i].querySelector(".actions .switch.on")) {
+ opts[optName] = true;
+ } else {
+ opts[optName] = false;
+ }
+ }
+ }
+
+ return opts;
+ },
+ load: () => {
+ let options = document.querySelectorAll(".option");
+
+ for (let i = 0; i < options.length; i++) {
+ let optName = options[i].getAttribute("name");
+ if (settings[optName] != undefined) {
+ switch(typeof settings[optName]) {
+ case "string":
+ options[i].querySelector(".actions input").value = settings[optName];
+ break
+ case "object":
+ options[i].querySelector(".actions input").value = settings[optName].join(" ");
+ break
+ case "boolean":
+ let switchDiv = options[i].querySelector(".actions .switch");
+ if (settings[optName]) {
+ switchDiv.classList.add("on");
+ switchDiv.classList.remove("off");
+ } else {
+ switchDiv.classList.add("off");
+ switchDiv.classList.remove("on");
+ }
+ break
+
+ }
+ }
+ }
}
}
Settings.reloadSwitches();
-
+Settings.load();