X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/f2e770d4a1cd1ee639e70fe0a6f9752de16f21e9..6ae326cb8d203015fa158b04e5b3b584f86c3654:/settings/add-plugin.php diff --git a/settings/add-plugin.php b/settings/add-plugin.php index cf55227..1b38740 100644 --- a/settings/add-plugin.php +++ b/settings/add-plugin.php @@ -71,111 +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'); - setTimeout(() => { location.reload() }, 500); - } - } - else - { - if (install_button) - { - install_button.innerHTML = (inst == "uninstall") ? "Uninstall" : "Install"; - install_button.classList.replace('btn-secondary', (inst == "uninstall") ? 'btn-outline-danger' : 'btn-primary'); - setTimeout(() => { location.reload() }, 500); - } - } - } - }; - - 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.list[i]; i++) - { - if (data.list[i].name == modname) - { - const modal = bsModal( - "Information about " + data.list[i].title + "", // title - "
", - "
Close
", "lg", true, true, true - ); - let modalclose = document.getElementById(modal); - modalclose.addEventListener('click', (e) => { - $("#"+modal).modal('hide'); - }); - boobs = document.getElementById(modal + '-body'); - boobs.innerHTML = ""; - if (data.list[i].screenshot.length) - { - boobs.innerHTML += `
- ` + data.list[i].screenshot[1] + ` style= -
`; - } - boobs.innerHTML += "

Description:
" + atob(data.list[i].readme.replace(["\n",""],["
","
"])) + "

"; - boobs.innerHTML += `
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Title`+data.list[i].title+`
Description`+data.list[i].description+`
Version`+data.list[i].version+`
Author`+data.list[i].author+`
Min Version Required`+data.list[i].minver+`
Max Version`+data.list[i].maxver+`
-
`; - } - } - }) - .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); }); });