]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - settings/add-plugin.php
Security: check passwords against Have I Been Pwned
[irc/unrealircd/unrealircd-webpanel.git] / settings / add-plugin.php
index fd265719c4b06784347a61bab4f51d01ca48df5e..1b38740f76b844f4968f3d065d856a41227f4fe0 100644 (file)
@@ -34,7 +34,6 @@ $p = new PluginRepo();
     const ibtns = document.querySelectorAll(".btn-install-plugin");
     ibtns.forEach((ib) => {
         ib.addEventListener('click', (e) => {
-            console.log("Button clicked! " +ib.innerHTML);
             if (ib.innerHTML !== "Install" && ib.innerHTML !== "Uninstall") // some point between, don't do anything
             {}
             else if (ib.innerHTML == "Install") // install button pressed!
@@ -72,84 +71,12 @@ $p = new PluginRepo();
         btn.innerHTML = "Uninstall";
     });
 
-    function requestInstall(name, uninstall = false)
-    {
-        let inst = (uninstall) ? "uninstall" : "install";
-        var xhr = new XMLHttpRequest();
 
-        xhr.onload = function() {
-            if (xhr.status === 200) {
-                var response = JSON.parse(xhr.responseText);
-                console.log(response.success);
-                let install_button = document.getElementById(name+'install');
-                if (response.success !== undefined)
-                {
-                    if (install_button)
-                    {
-                        install_button.innerHTML = (inst == "uninstall") ? "Install" : "Uninstall";
-                        install_button.classList.replace('btn-secondary', (inst == "uninstall") ? 'btn-primary' : 'btn-outline-danger');
-                        let icomplete = bsModal(((inst == "uninstall") ? "Uninstall" : "Install") + " Plugin", response.success,"<div id=\""+name+"closebtn\" class=\"btn btn-danger\">Close</div>", null, true, true, false);
-                        let closebtn = document.getElementById(name+"closebtn");
-                        closebtn.addEventListener('click', e => {
-                            location.reload();
-                        });
-                    }
-                }
-                else
-                {
-                    if (install_button)
-                    {
-                        install_button.innerHTML = (inst == "uninstall") ? "Uninstall" : "Install";
-                        install_button.classList.replace('btn-secondary', (inst == "uninstall") ? 'btn-outline-danger' : 'btn-primary');
-                        let icomplete = bsModal(((inst == "uninstall") ? "Uninstall" : "Install") + " Plugin", response.error,"", null, false, true);
-                        let closebtn = document.getElementById(name+"closebtn");
-                        closebtn.addEventListener('click', e => {
-                            location.reload();
-                        });
-                    }
-                }
-            }
-        };
-
-        xhr.open('GET', BASE_URL + 'api/plugin.php?'+inst+'=' + name, true);
-        xhr.send();
-        return true;
-    }
-
-    function create_info_modal(modname)
-    {
-        fetch(BASE_URL + 'api/plugin.php')
-        .then(response => response.json()) // Parse the response as JSON
-        .then(data => {
-            for (let i = 0; data[i]; i++)
-            {
-                if (data[i].name == modname)
-                {
-                    const modal = bsModal(
-                        "<i>Information about " + data[i].title + "</i>", // title
-                        "<div class=\"" + data[i].name + "_screenshots\"><i class=\"fa fa-spinner\" aria-hidden=\"true\"></i></div><div class=\"" + data[i].name + "_description\"><i class=\"fa fa-spinner\" aria-hidden=\"true\"></i></div>",
-                        "<div id=\""+modname+"closebtn\" class=\"btn btn-danger\">Close</div>", null, true, true, false
-                    );
-                    let modalclose = document.getElementById(modal);
-                    modalclose.addEventListener('click', (e) => {
-                        $("#"+modal).modal('hide');
-                    });
-                    console.log(modal + '-body');
-                    boobs = document.getElementById(modal + '-body');
-                    boobs.innerHTML = data[i].description;
-                }
-            }
-        })
-        .catch(error => {
-            // Handle any errors that occur during the request
-            console.error('Error:', error);
-        });
-    }
 
     const infoButtons = document.querySelectorAll('.more-info');
     infoButtons.forEach((el) => {
         el.addEventListener('click', (event) => {
-            create_info_modal(el.id);
+            create_plugin_info_modal(el.id);
             
         });
     });