aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/mods.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-01-30 23:22:41 +0100
committer0neGal <mail@0negal.com>2023-01-30 23:22:41 +0100
commit84cc46018664cee9d89d71ea75ba687a9171ab28 (patch)
tree43e71f3b8a1535aa1e6440dd0f7df001efb09749 /src/app/js/mods.js
parent67778e1ecab4747cf886e8ffcb6a11f96ccc279c (diff)
downloadViper-84cc46018664cee9d89d71ea75ba687a9171ab28.tar.gz
Viper-84cc46018664cee9d89d71ea75ba687a9171ab28.zip
added: toggles for toggling mods in modlist
The new modlist now uses the same toggles found in the settings popup, only here they're used to disable/enable mods. On top of this I also fixed the "Toggle All" button not working. Forgot to change some stuff, breaking it... oops...
Diffstat (limited to 'src/app/js/mods.js')
-rw-r--r--src/app/js/mods.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/app/js/mods.js b/src/app/js/mods.js
index 39e904e..6c2fc22 100644
--- a/src/app/js/mods.js
+++ b/src/app/js/mods.js
@@ -11,7 +11,14 @@ mods.load = (mods_obj) => {
normalized_names.push(normalized_name);
- if (document.getElementById(normalized_name)) {
+ let el = document.getElementById(normalized_name);
+ if (el) {
+ if (mod.Disabled) {
+ el.querySelector(".switch").classList.remove("on");
+ } else {
+ el.querySelector(".switch").classList.add("on");
+ }
+
return;
}
@@ -27,12 +34,21 @@ mods.load = (mods_obj) => {
<div class="text">
<div class="title">${mod.Name}</div>
<div class="description">${mod.Description}</div>
+ <button class="switch on"></button>
<button class="red" onclick="mods.remove('${mod.Name}')">Remove</button>
<button class="visual">${mod.Version}</button>
<button class="visual">by ${mod.Author || "Unknown"}</button>
</div>
`;
+ if (mod.Disabled) {
+ div.querySelector(".switch").classList.remove("on");
+ }
+
+ div.querySelector(".switch").addEventListener("click", () => {
+ mods.toggle(mod.Name);
+ })
+
if (! image_url) {
div.querySelector(".image").remove();
}