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