From 872e8818584943024e57c22331689128a49996c7 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Sun, 12 Oct 2025 19:39:41 +0200 Subject: [PATCH 1/2] apply autoformat (vscode) mixed indentation (2 spaces, 4 spaces, 1 tab) --- installation/template/js/remove.js | 209 +++++++++++++-------------- installation/template/js/setup.js | 36 ++--- installation/template/js/template.js | 61 ++++---- 3 files changed, 151 insertions(+), 155 deletions(-) diff --git a/installation/template/js/remove.js b/installation/template/js/remove.js index c430c7e7f7268..139e7d6e51f55 100644 --- a/installation/template/js/remove.js +++ b/installation/template/js/remove.js @@ -7,7 +7,7 @@ var url = Joomla.getOptions('system.installation').url ? Joomla.getOptions('system.installation').url.replace(/&/g, '&') : 'index.php'; if (document.getElementById('installAddFeatures')) { - document.getElementById('installAddFeatures').addEventListener('click', function(e) { + document.getElementById('installAddFeatures').addEventListener('click', function (e) { e.preventDefault(); document.getElementById('installLanguages').classList.add('active'); document.getElementById('installCongrat').classList.remove('active'); @@ -17,28 +17,27 @@ if (document.getElementById('installAddFeatures')) { } if (document.getElementById('skipLanguages')) { - document.getElementById('skipLanguages').addEventListener('click', function(e) { - e.preventDefault(); - document.getElementById('installCongrat').classList.add('active'); - document.getElementById('installFinal').classList.add('active'); - document.getElementById('installRecommended').classList.add('active'); - document.getElementById('installLanguages').classList.remove('active'); - - if (document.getElementById('installFinal')) { - document.getElementById('installFinal').focus(); - } - }) + document.getElementById('skipLanguages').addEventListener('click', function (e) { + e.preventDefault(); + document.getElementById('installCongrat').classList.add('active'); + document.getElementById('installFinal').classList.add('active'); + document.getElementById('installRecommended').classList.add('active'); + document.getElementById('installLanguages').classList.remove('active'); + + if (document.getElementById('installFinal')) { + document.getElementById('installFinal').focus(); + } + }) } if (document.getElementById('removeInstallationFolder')) { - document.getElementById('removeInstallationFolder') - .addEventListener('click', function (e) { - e.preventDefault(); - let confirm = window.confirm(Joomla.Text._('INSTL_REMOVE_INST_FOLDER').replace('%s', 'installation')); - if (confirm) { - Joomla.deleteJoomlaInstallationDirectory(); - } - }); + document.getElementById('removeInstallationFolder').addEventListener('click', function (e) { + e.preventDefault(); + let confirm = window.confirm(Joomla.Text._('INSTL_REMOVE_INST_FOLDER').replace('%s', 'installation')); + if (confirm) { + Joomla.deleteJoomlaInstallationDirectory(); + } + }); } if (document.getElementById('automatedUpdatesDisableButton')) { @@ -54,20 +53,20 @@ if (document.getElementById('automatedUpdatesDisableButton')) { const completeInstallationOptions = document.querySelectorAll('.complete-installation'); -completeInstallationOptions.forEach(function(item) { - item.addEventListener('click', function (e) { - // In development mode we show the user a pretty button to allow them to choose whether to delete the installation - // directory or not. In this case or when the installation folder has been deleted or might be partly deleted, - // the buttons just redirect to the admin or site. - // In stable release we always try to delete the folder at the first click. Maximum extermination! - if ('development' in item.dataset || 'installremoved' in item.dataset) { - window.location.href = item.dataset.href; - } else { - Joomla.deleteJoomlaInstallationDirectory(item.dataset.href); - } +completeInstallationOptions.forEach(function (item) { + item.addEventListener('click', function (e) { + // In development mode we show the user a pretty button to allow them to choose whether to delete the installation + // directory or not. In this case or when the installation folder has been deleted or might be partly deleted, + // the buttons just redirect to the admin or site. + // In stable release we always try to delete the folder at the first click. Maximum extermination! + if ('development' in item.dataset || 'installremoved' in item.dataset) { + window.location.href = item.dataset.href; + } else { + Joomla.deleteJoomlaInstallationDirectory(item.dataset.href); + } - return false; - }); + return false; + }); }); @@ -83,10 +82,10 @@ Joomla.disableAutomatedUpdates = function () { if (successresponse.error === true) { if (successresponse.messages) { Joomla.renderMessages(successresponse.messages); - Joomla.loadOptions({'csrf.token': successresponse.token}); + Joomla.loadOptions({ 'csrf.token': successresponse.token }); } else { // Stuff went wrong. No error messages. Just panic bail! - Joomla.renderMessages({error:['Unknown error disabling the automated updates.']}); + Joomla.renderMessages({ error: ['Unknown error disabling the automated updates.'] }); } } else { const automatedUpdates = document.getElementById('automatedUpdates'); @@ -100,79 +99,79 @@ Joomla.disableAutomatedUpdates = function () { } Joomla.deleteJoomlaInstallationDirectory = function (redirectUrl) { - Joomla.request({ - method: "POST", - url: Joomla.installationBaseUrl + '?task=installation.removeFolder&format=json', - perform: true, - token: true, - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - onSuccess: function (response) { - // If the installation folder has been deleted at least partly, i.e. also - // in case of a failure, we cannot use it anymore. - // Therefore set a marker in the admin and site buttons so they still work - // and disable buttons which will not work anymore. - completeInstallationOptions.forEach(function(item) { - item.dataset.installremoved = 'true'; - }); - if (document.getElementById('installAddFeatures')) { - document.getElementById('installAddFeatures').disabled = true; - } - if (document.getElementById('automatedUpdatesDisableButton')) { - document.getElementById('automatedUpdatesDisableButton').disabled = true; - } - if (document.getElementById('removeInstallationFolder')) { - document.getElementById('removeInstallationFolder').disabled = true; - } - const successresponse = JSON.parse(response); - if (successresponse.error === true) { - if (successresponse.messages) { - Joomla.renderMessages(successresponse.messages); - Joomla.loadOptions({'csrf.token': successresponse.token}); - } else { - // Stuff went wrong. No error messages. Just panic bail! - Joomla.renderMessages({error:['Unknown error deleting the installation folder.']}); - } - } else { - const customInstallation = document.getElementById('customInstallation'); - customInstallation.parentNode.removeChild(customInstallation); - - const automatedUpdates = document.getElementById('automatedUpdates'); - - // This will only exist if it has not been removed with a previous step - if (automatedUpdates) { - automatedUpdates.parentNode.removeChild(automatedUpdates); - } - - const removeInstallationTab = document.getElementById('removeInstallationTab'); - - // This will only exist in debug mode - if (removeInstallationTab) { - removeInstallationTab.parentNode.removeChild(removeInstallationTab); - } - - if (redirectUrl) { - window.location.href = redirectUrl; - } - } - }, - onError: function (xhr) { - Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr)); + Joomla.request({ + method: "POST", + url: Joomla.installationBaseUrl + '?task=installation.removeFolder&format=json', + perform: true, + token: true, + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + onSuccess: function (response) { + // If the installation folder has been deleted at least partly, i.e. also + // in case of a failure, we cannot use it anymore. + // Therefore set a marker in the admin and site buttons so they still work + // and disable buttons which will not work anymore. + completeInstallationOptions.forEach(function (item) { + item.dataset.installremoved = 'true'; + }); + if (document.getElementById('installAddFeatures')) { + document.getElementById('installAddFeatures').disabled = true; + } + if (document.getElementById('automatedUpdatesDisableButton')) { + document.getElementById('automatedUpdatesDisableButton').disabled = true; + } + if (document.getElementById('removeInstallationFolder')) { + document.getElementById('removeInstallationFolder').disabled = true; + } + const successresponse = JSON.parse(response); + if (successresponse.error === true) { + if (successresponse.messages) { + Joomla.renderMessages(successresponse.messages); + Joomla.loadOptions({ 'csrf.token': successresponse.token }); + } else { + // Stuff went wrong. No error messages. Just panic bail! + Joomla.renderMessages({ error: ['Unknown error deleting the installation folder.'] }); } - }); + } else { + const customInstallation = document.getElementById('customInstallation'); + customInstallation.parentNode.removeChild(customInstallation); + + const automatedUpdates = document.getElementById('automatedUpdates'); + + // This will only exist if it has not been removed with a previous step + if (automatedUpdates) { + automatedUpdates.parentNode.removeChild(automatedUpdates); + } + + const removeInstallationTab = document.getElementById('removeInstallationTab'); + + // This will only exist in debug mode + if (removeInstallationTab) { + removeInstallationTab.parentNode.removeChild(removeInstallationTab); + } + + if (redirectUrl) { + window.location.href = redirectUrl; + } + } + }, + onError: function (xhr) { + Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr)); + } + }); } if (document.getElementById('installLanguagesButton')) { - document.getElementById('installLanguagesButton').addEventListener('click', function(e) { - e.preventDefault(); - var form = document.getElementById('languagesForm'); - if (form) { - // Install the extra languages - if (Joomla.install(['languages'], form)) { - document.getElementById('installLanguages').classList.remove('active'); - document.getElementById('installFinal').classList.add('active'); - } - } - }) + document.getElementById('installLanguagesButton').addEventListener('click', function (e) { + e.preventDefault(); + var form = document.getElementById('languagesForm'); + if (form) { + // Install the extra languages + if (Joomla.install(['languages'], form)) { + document.getElementById('installLanguages').classList.remove('active'); + document.getElementById('installFinal').classList.add('active'); + } + } + }) } if (document.getElementById('defaultLanguagesButton')) { @@ -201,7 +200,7 @@ if (document.getElementById('defaultLanguagesButton')) { if (successresponse.messages) { Joomla.renderMessages(successresponse.messages, '#system-message-container'); } - Joomla.loadOptions({'csrf.token': successresponse.token}); + Joomla.loadOptions({ 'csrf.token': successresponse.token }); }, onError(xhr) { Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr)); diff --git a/installation/template/js/setup.js b/installation/template/js/setup.js index e52141385bdd4..8321a8228a5a5 100644 --- a/installation/template/js/setup.js +++ b/installation/template/js/setup.js @@ -9,7 +9,7 @@ * * @return {Boolean} */ -Joomla.setlanguage = function(form) { +Joomla.setlanguage = function (form) { var data = Joomla.serialiseForm(form); Joomla.removeMessages(); document.body.appendChild(document.createElement('joomla-core-loader')); @@ -19,7 +19,7 @@ Joomla.setlanguage = function(form) { method: 'POST', data: data, perform: true, - onSuccess: function(response, xhr){ + onSuccess: function (response, xhr) { response = JSON.parse(response); Joomla.replaceTokens(response.token); var loaderElement = document.querySelector('joomla-core-loader'); @@ -30,32 +30,32 @@ Joomla.setlanguage = function(form) { if (response.error) { loaderElement.parentNode.removeChild(loaderElement); - Joomla.renderMessages({'error': [response.message]}); + Joomla.renderMessages({ 'error': [response.message] }); } else { loaderElement.parentNode.removeChild(loaderElement); Joomla.goToPage(response.data.view, true); } }, - onError: function(xhr){ + onError: function (xhr) { var loaderElement = document.querySelector('joomla-core-loader'); loaderElement.parentNode.removeChild(loaderElement); try { var r = JSON.parse(xhr.responseText); Joomla.replaceTokens(r.token); alert(r.message); - } catch (e) {} + } catch (e) { } } }); return false; }; -Joomla.checkInputs = function() { +Joomla.checkInputs = function () { document.getElementById('jform_admin_password2').value = document.getElementById('jform_admin_password').value; var inputs = [].slice.call(document.querySelectorAll('input[type="password"], input[type="text"], input[type="email"], select')), state = true; - inputs.forEach(function(item) { + inputs.forEach(function (item) { if (!item.valid) state = false; }); document.getElementById('progress-text').classList.remove('error'); @@ -73,7 +73,7 @@ Joomla.checkInputs = function() { } }; -Joomla.checkDbCredentials = function() { +Joomla.checkDbCredentials = function () { const progress = document.getElementById('progressbar'); const progress_text = document.getElementById('progress-text'); var form = document.getElementById('adminForm'), @@ -91,11 +91,11 @@ Joomla.checkDbCredentials = function() { Joomla.request({ method: "POST", - url : Joomla.installationBaseUrl + '?task=installation.dbcheck&format=json', + url: Joomla.installationBaseUrl + '?task=installation.dbcheck&format=json', data: data, perform: true, - headers: {'Content-Type': 'application/x-www-form-urlencoded'}, - onSuccess: function(response, xhr){ + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + onSuccess: function (response, xhr) { try { response = JSON.parse(response); } catch (e) { @@ -104,7 +104,7 @@ Joomla.checkDbCredentials = function() { progress_text.innerText = response; console.error('Error in DB Check Endpoint'); console.error(response); - Joomla.renderMessages({'error': [Joomla.Text._('INSTL_DATABASE_RESPONSE_ERROR')]}); + Joomla.renderMessages({ 'error': [Joomla.Text._('INSTL_DATABASE_RESPONSE_ERROR')] }); return false; } @@ -129,7 +129,7 @@ Joomla.checkDbCredentials = function() { Joomla.install(['create', 'populate1', 'populate2', 'populate3', 'custom1', 'custom2', 'config'], form); } }, - onError: function(xhr){ + onError: function (xhr) { Joomla.renderMessages([['', Joomla.Text._('JLIB_DATABASE_ERROR_DATABASE_CONNECT', 'A Database error occurred.')]]); progress_text.setAttribute('role', 'alert'); progress_text.classList.add('error'); @@ -147,7 +147,7 @@ Joomla.checkDbCredentials = function() { }; -(function() { +(function () { // Merge options from the session storage if (sessionStorage && sessionStorage.getItem('installation-data')) { Joomla.extend(this.options, sessionStorage.getItem('installation-data')); @@ -168,14 +168,14 @@ Joomla.checkDbCredentials = function() { var languageEl = document.getElementById('jform_language'); if (languageEl) { - languageEl.addEventListener('change', function(e) { + languageEl.addEventListener('change', function (e) { var form = document.getElementById('languageForm'); Joomla.setlanguage(form) }) } if (document.getElementById('step1')) { - document.getElementById('step1').addEventListener('click', function(e) { + document.getElementById('step1').addEventListener('click', function (e) { e.preventDefault(); if (Joomla.checkFormField(['#jform_site_name'])) { if (document.getElementById('languageForm')) { @@ -195,7 +195,7 @@ Joomla.checkDbCredentials = function() { } if (document.getElementById('step2')) { - document.getElementById('step2').addEventListener('click', function(e) { + document.getElementById('step2').addEventListener('click', function (e) { e.preventDefault(); if (Joomla.checkFormField(['#jform_admin_user', '#jform_admin_email', '#jform_admin_password'])) { if (document.getElementById('installStep3')) { @@ -213,7 +213,7 @@ Joomla.checkDbCredentials = function() { } }); - document.getElementById('setupButton').addEventListener('click', function(e) { + document.getElementById('setupButton').addEventListener('click', function (e) { e.preventDefault(); e.stopPropagation(); Joomla.checkInputs(); diff --git a/installation/template/js/template.js b/installation/template/js/template.js index 568c45909ae9e..33106e90c56f5 100644 --- a/installation/template/js/template.js +++ b/installation/template/js/template.js @@ -3,17 +3,17 @@ * @copyright (C) 2017 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -(function() { +(function () { // Make sure that we have the Joomla object Joomla = window.Joomla || {}; Joomla.installation = Joomla.installation || {}; - Joomla.serialiseForm = function( form ) { - var i, l, obj = [], elements = form.querySelectorAll( "input, select, textarea" ); - for(i = 0, l = elements.length; i < l; i++) { + Joomla.serialiseForm = function (form) { + var i, l, obj = [], elements = form.querySelectorAll("input, select, textarea"); + for (i = 0, l = elements.length; i < l; i++) { var name = elements[i].name; var value = elements[i].value; - if(name) { + if (name) { if (((elements[i].type === 'checkbox' || elements[i].type === 'radio') && elements[i].checked === true) || (elements[i].type !== 'checkbox' && elements[i].type !== 'radio')) { obj.push(name.replace('[', '%5B').replace(']', '%5D') + '=' + encodeURIComponent(value)); } @@ -31,7 +31,7 @@ * * @return {Boolean} */ - Joomla.goToPage = function(page, fromSubmit) { + Joomla.goToPage = function (page, fromSubmit) { if (!fromSubmit) { Joomla.removeMessages(); document.body.appendChild(document.createElement('joomla-core-loader')); @@ -49,17 +49,17 @@ * * @return {Boolean} */ - Joomla.submitform = function(form) { + Joomla.submitform = function (form) { var data = Joomla.serialiseForm(form); document.body.appendChild(document.createElement('joomla-core-loader')); Joomla.removeMessages(); Joomla.request({ - type : "POST", - url : Joomla.baseUrl, - data : data, - dataType : 'json', + type: "POST", + url: Joomla.baseUrl, + data: data, + dataType: 'json', onSuccess: function (response, xhr) { response = JSON.parse(response); var spinnerElement = document.querySelector('joomla-core-loader'); @@ -69,7 +69,7 @@ } if (response.error) { - Joomla.renderMessages({'error': [response.message]}); + Joomla.renderMessages({ 'error': [response.message] }); spinnerElement.parentNode.removeChild(spinnerElement); } else { spinnerElement.parentNode.removeChild(spinnerElement); @@ -78,7 +78,7 @@ } } }, - onError : function (xhr) { + onError: function (xhr) { var spinnerElement = document.querySelector('joomla-core-loader'); spinnerElement.parentNode.removeChild(spinnerElement); busy = false; @@ -94,12 +94,10 @@ return false; }; - Joomla.scrollTo = function (elem, pos) - { + Joomla.scrollTo = function (elem, pos) { var y = elem.scrollTop; y += (pos - y) * 0.3; - if (Math.abs(y-pos) < 2) - { + if (Math.abs(y - pos) < 2) { elem.scrollTop = pos; return; } @@ -107,9 +105,9 @@ setTimeout(Joomla.scrollTo, 40, elem, pos); }; - Joomla.checkFormField = function(fields) { + Joomla.checkFormField = function (fields) { var state = []; - fields.forEach(function(field) { + fields.forEach(function (field) { state.push(document.formvalidator.validate(document.querySelector(field))); }); @@ -120,11 +118,11 @@ }; // Init on dom content loaded event - Joomla.makeRandomDbPrefix = function() { + Joomla.makeRandomDbPrefix = function () { var numbers = '0123456789', letters = 'abcdefghijklmnopqrstuvwxyz', symbols = numbers + letters; var prefix = letters[Math.floor(Math.random() * 24)]; - for (var i = 0; i < 4; i++ ) { + for (var i = 0; i < 4; i++) { prefix += symbols[Math.floor(Math.random() * 34)]; } @@ -136,9 +134,9 @@ /** * Initializes JavaScript events on each request, required for AJAX */ - Joomla.pageInit = function() { + Joomla.pageInit = function () { // Attach the validator - [].slice.call(document.querySelectorAll('form.form-validate')).forEach(function(form) { + [].slice.call(document.querySelectorAll('form.form-validate')).forEach(function (form) { document.formvalidator.attachToForm(form); }); @@ -153,7 +151,7 @@ * * @param tasks An array of install tasks to execute */ - Joomla.install = function(tasks, form) { + Joomla.install = function (tasks, form) { const progress = document.getElementById('progressbar'); const progress_text = document.getElementById('progress-text'); if (!form) { @@ -172,10 +170,10 @@ Joomla.request({ method: "POST", - url : Joomla.baseUrl + '?task=installation.' + task + '&format=json', + url: Joomla.baseUrl + '?task=installation.' + task + '&format=json', data: data, perform: true, - onSuccess: function(response, xhr){ + onSuccess: function (response, xhr) { try { response = JSON.parse(response); } catch (e) { @@ -186,15 +184,14 @@ } console.error('Error in ' + task + ' Endpoint'); console.error(response); - Joomla.renderMessages({'error': [Joomla.Text._('INSTL_DATABASE_RESPONSE_ERROR')]}); + Joomla.renderMessages({ 'error': [Joomla.Text._('INSTL_DATABASE_RESPONSE_ERROR')] }); return false; } Joomla.replaceTokens(response.token); - if (response.error === true) - { + if (response.error === true) { progress_text.setAttribute('role', 'alert'); progress_text.classList.add('error'); progress_text.innerText = response.message; @@ -204,7 +201,7 @@ } if (response.message) { - Joomla.renderMessages({"error": [response.message]}); + Joomla.renderMessages({ "error": [response.message] }); } // @todo: Add a delay and red background before removing the progress bar? @@ -228,7 +225,7 @@ } Joomla.install(tasks, form); }, - onError: function(xhr){ + onError: function (xhr) { if (progress_text) { progress_text.setAttribute('role', 'alert'); progress_text.classList.add('error'); @@ -248,7 +245,7 @@ }; /* Load scripts async */ - document.addEventListener('DOMContentLoaded', function() { + document.addEventListener('DOMContentLoaded', function () { var page = document.getElementById('installer-view'); // Set the base URL From 08a071f22069a122a2a8ed8e60a66392b3896481 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Sun, 12 Oct 2025 19:41:32 +0200 Subject: [PATCH 2/2] [5.4] hide container automated updates when install additional language --- installation/template/js/remove.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/installation/template/js/remove.js b/installation/template/js/remove.js index 139e7d6e51f55..3085a0ff4e565 100644 --- a/installation/template/js/remove.js +++ b/installation/template/js/remove.js @@ -13,6 +13,9 @@ if (document.getElementById('installAddFeatures')) { document.getElementById('installCongrat').classList.remove('active'); document.getElementById('installFinal').classList.remove('active'); document.getElementById('installRecommended').classList.remove('active'); + if (document.getElementById('automatedUpdates')) { + document.getElementById('automatedUpdates').classList.remove('active'); + } }) } @@ -23,6 +26,9 @@ if (document.getElementById('skipLanguages')) { document.getElementById('installFinal').classList.add('active'); document.getElementById('installRecommended').classList.add('active'); document.getElementById('installLanguages').classList.remove('active'); + if (document.getElementById('automatedUpdates')) { + document.getElementById('automatedUpdates').classList.add('active'); + } if (document.getElementById('installFinal')) { document.getElementById('installFinal').focus();