diff options
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/browser.js | 34 | ||||
-rw-r--r-- | src/app/main.js | 11 |
2 files changed, 43 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; + } +} diff --git a/src/app/main.js b/src/app/main.js index b61b20a..fa7cea8 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -68,6 +68,15 @@ function log(msg) { // updating/installing Northstar. function setButtons(state) { playNsBtn.disabled = !state; + + let disablearray = (array) => { + for (let i = 0; i < array.length; i++) { + array[i].disabled = !state; + } + } + + disablearray(document.querySelectorAll("#nsMods .buttons.modbtns button")) + disablearray(document.querySelectorAll("#browser #browserEntries .text button")) } // Frontend part of updating Northstar @@ -150,11 +159,13 @@ function selected(all) { // Tells the main process to install a mod function installmod() { + setButtons(false); ipcRenderer.send("installmod") } // Tells the main process to install a mod from a URL function installFromURL(url) { + setButtons(false); ipcRenderer.send("installfromurl", url) } |