2 * JavaScript for common installer functions
3 * --------------------------------------------------------------------
4 * Copyright (c) 2003 - 2009 by Roland Haeder
5 * Copyright (c) 2009 - 2016 by Mailer Developer Team
6 * For more information visit: http://mxchange.org
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
24 // Installation steps array
25 var installationSteps = new Array();
30 // Init all installation steps
31 installationSteps[0] = 'import_tables_sql';
32 installationSteps[1] = 'import_menu_sql';
33 installationSteps[2] = 'install_extensions';
34 installationSteps[3] = 'register_first_admin';
36 // Always keep as last step
37 installationSteps[installationSteps.length] = 'write_local_config';
39 // Switches instaler by redirecting
40 function switchInstaller (installer) {
42 document.location.href = 'install.php?installer=' + installer;
45 // User has clicked on 'finish'
46 function doFinishInstallation () {
47 // First disable all buttons button
48 resetFooterNavigation();
50 // Display progress window
51 displayProgressWindow('install', 'Init ...');
53 // Wait for window fader
54 $().ready(function () {
55 // Start installation loop delayed
56 window.setTimeout('doInstallationLoop()', 500);
63 // Does the "installation loop"
64 function doInstallationLoop () {
68 // For-loop for all installation steps
69 for (var i = 0; i < installationSteps.length; i++) {
71 outputInstallationStepMessage(installationSteps[i]);
73 // Initialize next step
74 if (sendInstallationStepRequest(i) === false) {
75 // Failed step, so remember it for later display
76 failedStep = installationSteps[i];
85 // Update progress bar
86 updateProgressBar(installationSteps.length);
89 // Is success counter same as array size
90 if (counterSuccess != installationSteps.length) {
91 // Display error message
92 displayErrorWindow('install', getAjaxContent() + ':' + counterSuccess + '/' + installationSteps.length + ':' + failedStep);
94 // Redirect to admin.php
95 document.location.href = 'admin.php';
99 // Sends an "installation step" request out
100 function sendInstallationStepRequest (i) {
102 if (installationSteps[i] == undefined) {
103 // Not set installation step, so don't send it out
104 throw new 'installationSteps[' + i + '] is not set.';
107 // Send out the request
108 return sendAjaxRequest('install', 'do_step', '&step=' + installationSteps[i], false);
111 // Outputs a "step message"
112 function outputInstallationStepMessage (step) {
114 // @TODO Progress bar is out-of-order: + '<div id="progressbar"></div>'
115 setProgressContent('install', step);