X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/905f0895c2fa97abaa331e8a667ada80128be19b..6ae326cb8d203015fa158b04e5b3b584f86c3654:/js/bs-modal.js
diff --git a/js/bs-modal.js b/js/bs-modal.js
index d87f6c1..2a9466a 100644
--- a/js/bs-modal.js
+++ b/js/bs-modal.js
@@ -6,13 +6,14 @@
* @param {string} footer - HTML for the footer
*
* Optional:
- * @param {string} size - the bootstrap size category for modals (sm, lg, xl)
- * @param {boolean} static - whether or not to make the backdrop static, forcing the user to respond to the dialog
- * @param {boolean} show - whether or not to automatically show the modal
+ * @param {string|null} size - the bootstrap size category for modals (sm, lg, xl). Default is null.
+ * @param {boolean} static - whether or not to make the backdrop static, forcing the user to respond to the dialog. Default is false
+ * @param {boolean} show - whether or not to automatically show the modal. Default is false.
+ * @param {boolean} closebutton - display and allow the close button. Default is true.
* @returns {string} returns the ID
*/
-function bsModal(title, body, footer, size = null, static = false, show = false)
+function bsModal(title, body, footer, size = null, static = false, show = false, closebutton = true)
{
/* generate a random number between 1000 and 90000 to use as an id */
const min = 1000;
@@ -46,9 +47,11 @@ function bsModal(title, body, footer, size = null, static = false, show = false)
mHeader.classList.add("modal-header");
mHeader.id = id + "-header";
- mHeader.innerHTML =`
` + title + `
- `;
+ mHeader.innerHTML =`
` + title + `
`;
+
+ if (closebutton)
+ mHeader.innerHTML += ``;
mBody.classList.add("modal-body");
mBody.id = id + "-body";
@@ -71,4 +74,187 @@ function bsModal(title, body, footer, size = null, static = false, show = false)
if (show)
$('#' + m1.id).modal('show');
+
+ 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
+ "
`;
+ }
+ }
+ 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);
+ });
}