Fixed various JS-API errors
authorAlexander Ebert <ebert@woltlab.com>
Fri, 7 Oct 2011 16:57:48 +0000 (18:57 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 7 Oct 2011 16:57:48 +0000 (18:57 +0200)
Form element values were included in POST-requests, even if they were not checked (violating intended behavior). Furthermore inner template content is now properly purged if the next step would evaluate as 'success'.

wcfsetup/install/files/acp/js/WCF.ACP.js

index c66b32d8863fa90de76a3cbc1109f3e383296432..ed4f2aa87ea7ab9e0793de90aa4afde226a5f561 100644 (file)
@@ -205,14 +205,16 @@ WCF.ACP.PackageInstallation.prototype = {
                
                // handle success
                if ($data.step == 'success') {
-                       var $id = WCF.getRandomID();
-                       $('#packageInstallationInnerContent').append('<div class="formSubmit"><input type="button" id="' + $id + '" value="' + WCF.Language.get('wcf.global.button.next') + '" class="default" /></div>');
-                       
-                       $('#' + $id).click($.proxy(function() {
-                               window.location.href = "index.php?page=PackageList" + SID_ARG_2ND;
-                       }, this));
-                       
-                       $('#packageInstallationInnerContentContainer').wcfBlindIn();
+                       this._purgeTemplateContent(function() {
+                               var $id = WCF.getRandomID();
+                               $('#packageInstallationInnerContent').append('<div class="formSubmit"><input type="button" id="' + $id + '" value="' + WCF.Language.get('wcf.global.button.next') + '" class="default" /></div>');
+                               
+                               $('#' + $id).click($.proxy(function() {
+                                       window.location.href = "index.php?page=PackageList" + SID_ARG_2ND;
+                               }, this));
+                               
+                               $('#packageInstallationInnerContentContainer').wcfBlindIn();
+                       });
                        
                        return;
                }
@@ -240,7 +242,11 @@ WCF.ACP.PackageInstallation.prototype = {
                                        // collect form values
                                        var $additionalData = {};
                                        $('#packageInstallationInnerContent').find('input').each(function(index, inputElement) {
-                                               $additionalData[$(inputElement).attr('name')] = $(inputElement).attr('value');
+                                               var $inputElement = $(inputElement);
+                                               
+                                               if ($inputElement.is(':checked')) {
+                                                       $additionalData[$inputElement.attr('name')] = $inputElement.val();
+                                               }
                                        });
                                        
                                        this._executeStep($data.step, $data.node, $additionalData);
@@ -254,22 +260,31 @@ WCF.ACP.PackageInstallation.prototype = {
                }
                
                // purge content
+               this._purgeTemplateContent($.proxy(function() {
+                       // execute next step
+                       if ($data.step && $data.node) {
+                               this._executeStep($data.step, $data.node);
+                       }
+               }, this));
+       },
+       
+       /**
+        * Purges template content.
+        * 
+        * @param       function        callback
+        */
+       _purgeTemplateContent: function(callback) {
                if ($('#packageInstallationInnerContent').children().length > 1) {
                        $('#packageInstallationInnerContentContainer').wcfBlindOut('down', $.proxy(function() {
                                $('#packageInstallationInnerContent').empty();
                                this._dialog.wcfDialog('redraw');
                                
-                               // execute next step
-                               if ($data.step && $data.node) {
-                                       this._executeStep($data.step, $data.node);
-                               }
+                               // execute callback
+                               callback();
                        }, this));
                }
                else {
-                       // execute next step
-                       if ($data.step && $data.node) {
-                               this._executeStep($data.step, $data.node);
-                       }
+                       callback();
                }
        },