]> git.mxchange.org Git - mailer.git/blobdiff - js/install-common.js
Continued on AJAX installer to start first step (more are easily to add)
[mailer.git] / js / install-common.js
index 87fcbda4b0b577d8f9d87ba2d90cc0e8296ad492..2983c6543134cdd8036b6b7f78f8ab90f85af94c 100644 (file)
 // Installation steps array
 var installSteps = new Array();
 
+// Failed step
+var failedStep = '';
+var counterSuccess = 0;
+
 // Init all installation steps
-installSteps[0] = '';
-installSteps[1] = '';
-installSteps[2] = '';
-installSteps[3] = '';
+installSteps[0] = 'import_tables_sql';
+installSteps[1] = 'import_menu_sql';
+installSteps[2] = 'write_local_config';
+installSteps[3] = 'install_extensions';
 
 // Switches instaler by redirecting
 function switchInstaller (installer) {
@@ -50,4 +54,48 @@ function doFinishInstallation () {
 
        // Display process window
        displayProcessWindow('install', '');
+
+       // Start installation loop
+       doInstallationLoop();
+
+       // Is success counter same as array size
+       if (counterSuccess != installSteps.length) {
+               // Display error message
+               displayErrorWindow('install', getAjaxContent());
+       }
+}
+
+// Does the "installation loop"
+function doInstallationLoop () {
+       // For-loop for all installation steps
+       for (var i = 0; i < installSteps.length; i++) {
+               // Output message
+               outputInstallationStepMessage(installSteps[i]);
+
+               // Initialize next step
+               if (!sendInstallationStepRequest(installSteps[i]) == true) {
+                       // Failed step, so remember it for later display
+                       failedStep = installSteps[i];
+
+                       // Stop here
+                       break;
+               }
+
+               // Did went okay
+               counterSuccess++;
+
+               // Wait a little
+       } // END - for
+}
+
+// Sends an "installation step" request out
+function sendInstallationStepRequest (step) {
+       // Send out the request
+       return sendAjaxRequest('install', 'do_step', '&step=' + step, true);
+}
+
+// Outputs a "step message"
+function outputInstallationStepMessage (step) {
+       // Set content
+       setProcessContent('install', step);
 }