- 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);
- });
- }