[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 /** 2 * @package Joomla.Installation 3 * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> 4 * @license GNU General Public License version 2 or later; see LICENSE.txt 5 */ 6 // Init on dom content loaded event 7 var url = Joomla.getOptions('system.installation').url ? Joomla.getOptions('system.installation').url.replace(/&/g, '&') : 'index.php'; 8 9 if (document.getElementById('installAddFeatures')) { 10 document.getElementById('installAddFeatures').addEventListener('click', function(e) { 11 e.preventDefault(); 12 document.getElementById('installLanguages').classList.add('active'); 13 document.getElementById('installCongrat').classList.remove('active'); 14 document.getElementById('installFinal').classList.remove('active'); 15 document.getElementById('installRecommended').classList.remove('active'); 16 }) 17 } 18 19 if (document.getElementById('skipLanguages')) { 20 document.getElementById('skipLanguages').addEventListener('click', function(e) { 21 e.preventDefault(); 22 document.getElementById('installCongrat').classList.add('active'); 23 document.getElementById('installFinal').classList.add('active'); 24 document.getElementById('installRecommended').classList.add('active'); 25 document.getElementById('installLanguages').classList.remove('active'); 26 27 if (document.getElementById('installFinal')) { 28 document.getElementById('installFinal').focus(); 29 } 30 }) 31 } 32 33 if (document.getElementById('removeInstallationFolder')) { 34 document.getElementById('removeInstallationFolder') 35 .addEventListener('click', function (e) { 36 e.preventDefault(); 37 let confirm = window.confirm(Joomla.Text._('INSTL_REMOVE_INST_FOLDER').replace('%s', 'installation')); 38 if (confirm) { 39 Joomla.deleteJoomlaInstallationDirectory(); 40 } 41 }); 42 } 43 44 const completeInstallationOptions = document.querySelectorAll('.complete-installation'); 45 46 completeInstallationOptions.forEach(function(item) { 47 item.addEventListener('click', function (e) { 48 // In development mode we show the user a pretty button to allow them to choose whether to delete the installation 49 // directory or not. In this case or when the installation folder has been deleted or might be partly deleted, 50 // the buttons just redirect to the admin or site. 51 // In stable release we always try to delete the folder at the first click. Maximum extermination! 52 if ('development' in item.dataset || 'installremoved' in item.dataset) { 53 window.location.href = item.dataset.href; 54 } else { 55 Joomla.deleteJoomlaInstallationDirectory(item.dataset.href); 56 } 57 58 return false; 59 }); 60 }); 61 62 Joomla.deleteJoomlaInstallationDirectory = function (redirectUrl) { 63 Joomla.request({ 64 method: "POST", 65 url: Joomla.installationBaseUrl + '?task=installation.removeFolder&format=json', 66 perform: true, 67 token: true, 68 headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, 69 onSuccess: function (response) { 70 // If the installation folder has been deleted at least partly, i.e. also 71 // in case of a failure, we cannot use it anymore. 72 // Therefore set a marker in the admin and site buttons so they still work 73 // and disable buttons which will not work anymore. 74 completeInstallationOptions.forEach(function(item) { 75 item.dataset.installremoved = 'true'; 76 }); 77 if (document.getElementById('installAddFeatures')) { 78 document.getElementById('installAddFeatures').disabled = true; 79 } 80 if (document.getElementById('removeInstallationFolder')) { 81 document.getElementById('removeInstallationFolder').disabled = true; 82 } 83 const successresponse = JSON.parse(response); 84 if (successresponse.error === true) { 85 if (successresponse.messages) { 86 Joomla.renderMessages(successresponse.messages); 87 Joomla.loadOptions({'csrf.token': successresponse.token}); 88 } else { 89 // Stuff went wrong. No error messages. Just panic bail! 90 Joomla.renderMessages({error:['Unknown error deleting the installation folder.']}); 91 } 92 } else { 93 const customInstallation = document.getElementById('customInstallation'); 94 customInstallation.parentNode.removeChild(customInstallation); 95 const removeInstallationTab = document.getElementById('removeInstallationTab'); 96 97 // This will only exist in debug mode 98 if (removeInstallationTab) { 99 removeInstallationTab.parentNode.removeChild(removeInstallationTab); 100 } 101 102 if (redirectUrl) { 103 window.location.href = redirectUrl; 104 } 105 } 106 }, 107 onError: function (xhr) { 108 Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr)); 109 } 110 }); 111 } 112 113 if (document.getElementById('installLanguagesButton')) { 114 document.getElementById('installLanguagesButton').addEventListener('click', function(e) { 115 e.preventDefault(); 116 var form = document.getElementById('languagesForm'); 117 if (form) { 118 // Install the extra languages 119 if (Joomla.install(['languages'], form)) { 120 document.getElementById('installLanguages').classList.remove('active'); 121 document.getElementById('installFinal').classList.add('active'); 122 } 123 } 124 }) 125 } 126 127 if (document.getElementById('defaultLanguagesButton')) { 128 document.getElementById('defaultLanguagesButton') 129 .addEventListener('click', (e) => { 130 let frontendlang = 'en-GB'; 131 if (document.querySelector('input[name="frontendlang"]:checked')) { 132 frontendlang = document.querySelector('input[name="frontendlang"]:checked').value; 133 } 134 135 let administratorlang = 'en-GB'; 136 if (document.querySelector('input[name="administratorlang"]:checked')) { 137 administratorlang = document.querySelector('input[name="administratorlang"]:checked').value; 138 } 139 140 e.preventDefault(); 141 142 Joomla.request({ 143 method: 'POST', 144 url: `$Joomla.installationBaseUrl}?view=setup&frontendlang=$frontendlang}&administratorlang=$administratorlang}&task=language.setdefault&format=json`, 145 perform: true, 146 token: true, 147 headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, 148 onSuccess(response) { 149 const successresponse = JSON.parse(response); 150 if (successresponse.messages) { 151 Joomla.renderMessages(successresponse.messages, '#system-message-container'); 152 } 153 Joomla.loadOptions({'csrf.token': successresponse.token}); 154 }, 155 onError(xhr) { 156 Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr)); 157 }, 158 }); 159 160 if (document.getElementById('header')) { 161 document.getElementById('header').scrollIntoView(); 162 } 163 }); 164 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |