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