Updated copyright notice as there are changes in this year
[mailer.git] / js / install-common.js
1 /**
2  * JavaScript for common installer functions
3  * --------------------------------------------------------------------
4  * $Revision::                                                        $
5  * $Date::                                                            $
6  * $Tag:: 0.2.1-FINAL                                                 $
7  * $Author::                                                          $
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
12  *
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.
17  *
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.
22  *
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,
26  * MA  02110-1301  USA
27  */
28
29 // Installation steps array
30 var installationSteps = new Array();
31
32 // Failed step
33 var failedStep = '';
34
35 // Init all installation steps
36 installationSteps[0] = 'import_tables_sql';
37 installationSteps[1] = 'import_menu_sql';
38 installationSteps[2] = 'install_extensions';
39
40 // Always keep as last step
41 installationSteps[installationSteps.length] = 'write_local_config';
42
43 // Switches instaler by redirecting
44 function switchInstaller (installer) {
45         // Switch installer
46         document.location.href = 'install.php?installer=' + installer;
47 }
48
49 // User has clicked on 'finish'
50 function doFinishInstallation () {
51         // First disable all buttons button
52         resetFooterNavigation();
53
54         // Display progress window
55         displayProgressWindow('install', 'Init ...');
56
57         // Wait for window fader
58         $().ready(function () {
59                 // Start installation loop delayed
60                 window.setTimeout('doInstallationLoop()', 500);
61
62                 // Wait here
63                 $('body').delay(500);
64         });
65 }
66
67 // Does the "installation loop"
68 function doInstallationLoop () {
69         // For-loop for all installation steps
70         for (var i = 0; i < installationSteps.length; i++) {
71                 // Output message
72                 outputInstallationStepMessage(installationSteps[i]);
73
74                 // Initialize next step
75                 if (sendInstallationStepRequest(i) === false) {
76                         // Failed step, so remember it for later display
77                         failedStep = installationSteps[i];
78
79                         // Stop here
80                         break;
81                 } // END - if
82
83                 // Wait a little
84                 $('body').delay(500);
85
86                 // Update progress bar
87                 updateProgressBar(installationSteps.length);
88         } // END - for
89
90         // Is success counter same as array size
91         if (counterSuccess != installationSteps.length) {
92                 // Display error message
93                 displayErrorWindow('install', getAjaxContent() + ':' + counterSuccess + '/' + installationSteps.length + ':' + failedStep);
94         } // END - if
95 }
96
97 // Sends an "installation step" request out
98 function sendInstallationStepRequest (i) {
99         // Is it set?
100         if (installationSteps[i] == undefined) {
101                 // Not set installation step, so don't send it out
102                 throw new 'installationSteps[' + i + '] is not set.';
103         } // END - if
104
105         // Send out the request
106         return sendAjaxRequest('install', 'do_step', '&step=' + installationSteps[i], false);
107 }
108
109 // Outputs a "step message"
110 function outputInstallationStepMessage (step) {
111         // Set content
112         // @TODO Progress bar is out-of-order: + '<div id="progressbar"></div>'
113         setProgressContent('install', step);
114 }