*/
// Installation steps array
-var installSteps = new Array();
+var installationSteps = new Array();
// Failed step
var failedStep = '';
var counterSuccess = 0;
// Init all installation steps
-installSteps[0] = 'import_tables_sql';
-installSteps[1] = 'import_menu_sql';
-installSteps[2] = 'write_local_config';
-installSteps[3] = 'install_extensions';
+installationSteps[0] = 'import_tables_sql';
+installationSteps[1] = 'import_menu_sql';
+installationSteps[2] = 'install_extensions';
+
+// Always keep as last step
+installationSteps[installationSteps.length] = 'write_local_config';
// Switches instaler by redirecting
function switchInstaller (installer) {
// Switch installer
- document.location.href='install.php?installer=' + installer;
+ document.location.href = 'install.php?installer=' + installer;
}
// User has clicked on 'finish'
function doFinishInstallation () {
// First disable all buttons button
- disableElement('input#next_page');
- disableElement('input#previous_page');
- disableElement('input#finish');
+ resetFooterNavigation();
- // Display process window
- displayProcessWindow('install', '');
+ // Display progress window
+ displayProgressWindow('install', 'Init ...');
// Start installation loop delayed
- window.setTimeout("doInstallationLoop()", 500);
+ window.setTimeout('doInstallationLoop()', 500);
- // Is success counter same as array size
- if (counterSuccess != installSteps.length) {
- // Display error message
- displayErrorWindow('install', getAjaxContent());
+ // Wait here
+ window.setTimeout('doWait()', 500);
+}
+
+// Do wait
+function doWait () {
+ // Is still something to do?
+ if ((failedStep == '') && (counterSuccess != installationSteps.length)) {
+ // Wait one round more
+ window.setTimeout('doWait()', 500);
+ } else if ((failedStep == '') && (counterSuccess == installationSteps.length)) {
+ // Close window
+ closeProgressWindow('install', true, false);
+
+ // Redirect to old 'finished' page
+ document.location.href = 'admin.php';
+ } else if (failedStep != '') {
+ // Something happens that should not happen!
+ displayErrorWindow('install', 'failedStep=' + failedStep);
}
}
+// Update progress bar
+function updateProgressBar () {
+ // Increment counter
+ counterSuccess++;
+
+ // Do only update <= 100% values
+ if (counterSuccess <= installationSteps.length) {
+ // Update progress bar
+ $('#progressbar').progressbar({
+ value: (counterSuccess / installationSteps.length * 100)
+ });
+ } // END - if
+}
+
// Does the "installation loop"
function doInstallationLoop () {
// For-loop for all installation steps
- for (var i = 0; i < installSteps.length; i++) {
+ for (var i = 0; i < installationSteps.length; i++) {
// Output message
- outputInstallationStepMessage(installSteps[i]);
+ outputInstallationStepMessage(installationSteps[i]);
// Initialize next step
- if (!sendInstallationStepRequest(installSteps[i]) == true) {
+ if (!sendInstallationStepRequest(i) == true) {
// Failed step, so remember it for later display
- failedStep = installSteps[i];
+ failedStep = installationSteps[i];
// Stop here
break;
- }
-
- // Did went okay
- counterSuccess++;
+ } // END - if
// Wait a little
+ $('body').delay(500);
+
+ // Update progress bar
+ updateProgressBar();
} // END - for
+
+ // Is success counter same as array size
+ if (counterSuccess != installationSteps.length) {
+ // Display error message
+ displayErrorWindow('install', getAjaxContent() + ':' + counterSuccess + '/' + installationSteps.length + ':' + failedStep);
+ } // END - if
}
// Sends an "installation step" request out
-function sendInstallationStepRequest (step) {
+function sendInstallationStepRequest (i) {
+ // Is it set?
+ if (installationSteps[i] == undefined) {
+ // Not set installation step, so don't send it out
+ throw new 'installationSteps[' + i + '] is not set.';
+ } // END - if
+
// Send out the request
- return sendAjaxRequest('install', 'do_step', '&step=' + step, true);
+ return sendAjaxRequest('install', 'do_step', '&step=' + installationSteps[i], true);
}
// Outputs a "step message"
function outputInstallationStepMessage (step) {
// Set content
- setProcessContent('install', step);
+ // @TODO Progress bar is out-of-order: + '<div id="progressbar"></div>'
+ setProgressContent('install', step);
}