+
+<script>
+const ibtns = document.querySelectorAll(".btn-install-plugin");
+ ibtns.forEach((ib) => {
+ ib.addEventListener('click', (e) => {
+ console.log(ib.id);
+ if (ib.innerHTML !== "Install" && ib.innerHTML !== "Uninstall") // some point between, don't do anything
+ {}
+ else if (ib.innerHTML == "Install") // install button pressed!
+ {
+ let req = requestInstall(ib.id.slice(0,-7))
+ if (req == true)
+ {
+ ib.classList.replace("btn-primary", "btn-secondary");
+ ib.innerHTML = "Installing...";
+ }
+ else
+ {
+ let uhoh = new bsModal("Error", "Could not install: "+req, "", null, false, true);
+ }
+ }
+ else if (ib.innerHTML == "Uninstall")
+ {
+ let req = requestInstall(ib.id.slice(0,-7), true); // true = uninstall
+ if (req == true)
+ {
+ ib.classList.replace("btn-outline-danger", "btn-secondary");
+ ib.innerHTML = "Uninstalling...";
+ }
+ else
+ {
+ let uhoh = new bsModal("Error", "Could not uninstall: "+req, "", null, false, true);
+ }
+ }
+ });
+ })
+ const installed = document.querySelectorAll(".installed");
+ installed.forEach((el) => {
+ let btn = document.getElementById(el.id + 'install');
+ btn.classList.replace("btn-primary", "btn-outline-danger");
+ btn.innerHTML = "Uninstall";
+ });
+</script>
+