aboutsummaryrefslogtreecommitdiff
path: root/src/app/browser.js
diff options
context:
space:
mode:
authorGitExample <git@example.com>2022-02-03 01:36:11 +0100
committerGitExample <git@example.com>2022-02-03 01:36:11 +0100
commita4b11903979fdb4c8b0f6dda8f7343e14c1ebe17 (patch)
tree408def0b839140c6004ba5099c3abf0cc2319bea /src/app/browser.js
parentd3228ae7fad117a8313731107f572ba4879569b6 (diff)
downloadViper-a4b11903979fdb4c8b0f6dda8f7343e14c1ebe17.tar.gz
Viper-a4b11903979fdb4c8b0f6dda8f7343e14c1ebe17.zip
detection of installed mods, disabling buttons
When a new mod has been installed through the browser UI it's button is changed from "Install" to "Re-Install" instantly. We also now disable modding related buttons when updating NS, or when installing mods. This should prevent issues.
Diffstat (limited to 'src/app/browser.js')
-rw-r--r--src/app/browser.js34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/app/browser.js b/src/app/browser.js
index 73eb6f7..f152a6a 100644
--- a/src/app/browser.js
+++ b/src/app/browser.js
@@ -55,16 +55,46 @@ function BrowserEl(properties) {
browserEntries.innerHTML = "";
}
+ let installstring = "Install";
+ if (normalize(modsdiv.innerText.split("\n")).includes(normalize(properties.title))) {
+ installstring = "Re-Install";
+ }
+
browserEntries.innerHTML += `
- <div class="el">
+ <div class="el" id="${normalize(properties.title)}">
<div class="image">
<img src="${properties.image}">
</div>
<div class="text">
<div class="title">${properties.title}</div>
<div class="description">${properties.description} - ${lang("gui.browser.madeby")} ${properties.author}</div>
- <button onclick="installFromURL('${properties.download}')">Install</button>
+ <button onclick="installFromURL('${properties.download}')">${installstring}</button>
</div>
</div>
`
}
+
+ipcRenderer.on("installedmod", (event, modname) => {
+ setButtons(true);
+ modname = normalize(modname);
+
+ if (document.getElementById(modname)) {
+ document.getElementById(modname).querySelector(".text button").innerHTML = "Re-Install";
+ }
+})
+
+function normalize(items) {
+ let main = (string) => {
+ return string.replaceAll(" ", "").replaceAll(".", "").toLowerCase()
+ }
+ if (typeof items == "string") {
+ return main(items)
+ } else {
+ let newArray = [];
+ for (let i = 0; i < items.length; i++) {
+ newArray.push(main(items[i]));
+ }
+
+ return newArray;
+ }
+}