X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/e8b225fd0d606166c953be789f930e594ddf8bb1..452b8eada34a0857aee8b5ea2a1dcb0a550626d3:/js/bs-modal.js
diff --git a/js/bs-modal.js b/js/bs-modal.js
index 2fea1da..2a9466a 100644
--- a/js/bs-modal.js
+++ b/js/bs-modal.js
@@ -77,3 +77,184 @@ function bsModal(title, body, footer, size = null, static = false, show = false,
return m1.id;
}
+
+
+function create_plugin_info_modal(modname)
+{
+ let found = false;
+ 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)
+ {
+ found = true;
+ const modal = bsModal(
+ "Information about " + data.list[i].title + "", // title
+ "
",
+ "Close
", null, 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 += `
+
+
`;
+ }
+ 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+` |
+
+
+
+
`;
+ }
+ }
+ if (!found)
+ {
+ bsModal("Hmmm. Something went wrong.", "It seems we can't find any information about that plugin! Maybe it's built-in? If not, please report this via GitHub or email. ", "", null, null, true, true);
+ }
+ })
+ .catch(error => {
+ // Handle any errors that occur during the request
+ bsModal("Hmmm. Something went wrong.", "It seems we can't query our own API! Please report this via GitHub or email. ", "", null, null, true, true);
+ });
+}
+
+
+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() }, 2000);
+ }
+ }
+ }
+ };
+
+ xhr.open('GET', BASE_URL + 'api/plugin.php?'+inst+'=' + name, true);
+ xhr.send();
+ return true;
+}
+
+
+function create_plugin_info_modal(modname)
+{
+ let found = false;
+ 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)
+ {
+ found = true;
+ const modal = bsModal(
+ "Information about " + data.list[i].title + "", // title
+ "
",
+ "Close
", null, 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 += `
+
+
`;
+ }
+ 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+` |
+
+
+
+
`;
+ }
+ }
+ if (!found)
+ {
+ bsModal("Hmmm. Something went wrong.", "It seems we can't find any information about that plugin! Maybe it's built-in? If not, please report this via GitHub or email. ", "", null, null, true, true);
+ }
+ })
+ .catch(error => {
+ // Handle any errors that occur during the request
+ bsModal("Hmmm. Something went wrong.", "It seems we can't query our own API! Please report this via GitHub or email. ", "", null, null, true, true);
+ });
+}