From e6f60ab93a03da39425b1d09cd62958c92398dce Mon Sep 17 00:00:00 2001 From: Dimitris Grammatikogiannis Date: Sat, 7 Oct 2023 00:12:23 +0300 Subject: [PATCH] Update patchtester.js --- media/com_patchtester/js/patchtester.js | 73 +++++++++++-------------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/media/com_patchtester/js/patchtester.js b/media/com_patchtester/js/patchtester.js index a040914..dce3493 100644 --- a/media/com_patchtester/js/patchtester.js +++ b/media/com_patchtester/js/patchtester.js @@ -9,48 +9,41 @@ if (typeof Joomla === 'undefined') { throw new Error('PatchTester JavaScript requires the Joomla core JavaScript API') } -document.addEventListener("DOMContentLoaded", function (event) { - const submitPatch = document.querySelectorAll(".submitPatch"); +Joomla.submitbutton = (task) => { + if (task !== 'reset' || confirm(Joomla.JText._('COM_PATCHTESTER_CONFIRM_RESET', 'Resetting will attempt to revert all applied patches and removes all backed up files. This may result in a corrupted environment. Are you sure you want to continue?'))) { + Joomla.submitform(task); + } +}; - /** - * EventListener which listens on submitPatch Button, - * checks if it is an apply or revert method and - * processes the patch action - * - * @param {Event} event - */ - submitPatch.forEach(function (element) { - element.addEventListener("click", function (event) { - const currentTarget = event.currentTarget; - const task = `${currentTarget.dataset.task}.${currentTarget.dataset.task}` - const id = parseInt(currentTarget.dataset.id) +const PatchTester = { + /** + * Process the patch action + * + * @param {String} task The task to perform + * @param {Number} id The item ID + */ + submitpatch: function (task, id) { + var idField = document.getElementById('pull_id'); + idField.value = id; - PatchTester.submitpatch(task, id); - }); - }); -}); + Joomla.submitform(task); + } +}; -!function (Joomla, window, document) { - 'use strict'; +/** + * EventListener which listens on submitPatch Button, + * checks if it is an apply or revert method and + * processes the patch action + * + * @param {Event} event + */ +function patchSubmit(event) { + const currentTarget = event.currentTarget; + const task = `${currentTarget.dataset.task}.${currentTarget.dataset.task}` + const id = parseInt(currentTarget.dataset.id) + + PatchTester.submitpatch(task, id); +} - window.PatchTester = { - /** - * Process the patch action - * - * @param {String} task The task to perform - * @param {Number} id The item ID - */ - submitpatch: function (task, id) { - var idField = document.getElementById('pull_id'); - idField.value = id; - Joomla.submitform(task); - } - }; - - Joomla.submitbutton = function (task) { - if (task !== 'reset' || confirm(Joomla.JText._('COM_PATCHTESTER_CONFIRM_RESET', 'Resetting will attempt to revert all applied patches and removes all backed up files. This may result in a corrupted environment. Are you sure you want to continue?'))) { - Joomla.submitform(task); - } - }; -}(Joomla, window, document); +document.querySelectorAll(".submitPatch").forEach((element) => element.addEventListener("click", patchSubmit));