Fix several JS problems with MSIE/Mac:
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 18 Jul 2007 22:13:35 +0000 (22:13 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 18 Jul 2007 22:13:35 +0000 (22:13 +0000)
* Use of Array.push() broke things, as it's not missing. Work around with a[a.length] = foo
 -- shift-checkbox selection and sortable table setup were causing JS errors on every page view
* Use of 'if (x in arr)' breaks *parsing* in MSIE/Mac. :P Work around work 'for (y in arr) if (x == y)'
 -- broke upload.js, so the license selector hackaround didn't get run
* Upload AJAX calls weren't checking for client compatibility before doing things
 -- littered spinners on the page

RELEASE-NOTES
includes/DefaultSettings.php
skins/common/upload.js
skins/common/wikibits.js

index ab934fe..df05c50 100644 (file)
@@ -313,6 +313,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 8054) Return search page for empty search requests with ugly URLs
 * (bug 10572) Force refresh after clearing visitation timestamps on watchlist
 * (bug 10631) Warn when illegal characters are removed from filename at upload
+* Fix several JavaScript bugs under MSIE 5/Macintosh
 
 == API changes since 1.10 ==
 
index a80ab6d..bf087db 100644 (file)
@@ -1201,7 +1201,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '87';
+$wgStyleVersion = '88';
 
 
 # Server-side caching:
index 6477e12..7cbfc9a 100644 (file)
@@ -8,9 +8,7 @@ function licenseSelectorCheck() {
                }
        }
        // We might show a preview
-       if( wgAjaxLicensePreview ) {
-               wgUploadLicenseObj.fetchPreview( selection );
-       }
+       wgUploadLicenseObj.fetchPreview( selection );
 }
 
 function licenseSelectorFixup() {
@@ -36,6 +34,8 @@ var wgUploadWarningObj = {
        'timeoutID': false,
 
        'keypress': function () {
+               if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
+
                // Find file to upload
                var destFile = document.getElementById('wpDestFile');
                var warningElt = document.getElementById( 'wpDestFile-warning' );
@@ -48,15 +48,18 @@ var wgUploadWarningObj = {
                        window.clearTimeout( this.timeoutID );
                }
                // Check response cache
-               if ( this.nameToCheck in this.responseCache ) {
-                       this.setWarning(this.responseCache[this.nameToCheck]);
-                       return;
+               for (cached in this.responseCache) {
+                       if (this.nameToCheck == cached) {
+                               this.setWarning(this.responseCache[this.nameToCheck]);
+                               return;
+                       }
                }
 
                this.timeoutID = window.setTimeout( 'wgUploadWarningObj.timeout()', this.delay );
        },
 
        'checkNow': function (fname) {
+               if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
                if ( this.timeoutID ) {
                        window.clearTimeout( this.timeoutID );
                }
@@ -65,6 +68,7 @@ var wgUploadWarningObj = {
        },
        
        'timeout' : function() {
+               if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
                injectSpinner( document.getElementById( 'wpDestFile' ), 'destcheck' );
 
                // Get variables into local scope so that they will be preserved for the 
@@ -131,9 +135,7 @@ function fillDestFilename(id) {
        var destFile = document.getElementById('wpDestFile');
        if (destFile) {
                destFile.value = fname;
-               if ( wgAjaxUploadDestCheck ) {
-                       wgUploadWarningObj.checkNow(fname) ;
-               }
+               wgUploadWarningObj.checkNow(fname) ;
        }
 }
 
@@ -142,18 +144,19 @@ var wgUploadLicenseObj = {
        'responseCache' : { '' : '' },
 
        'fetchPreview': function( license ) {
-               if( license == "" ) {
-                       this.showPreview( "" );
-               } else if( license in this.responseCache ) {
-                       this.showPreview( this.responseCache[license] );
-               } else {
-                       injectSpinner( document.getElementById( 'wpLicense' ), 'license' );
-                       sajax_do_call( 'UploadForm::ajaxGetLicensePreview', [license],
-                               function( result ) {
-                                       wgUploadLicenseObj.processResult( result, license );
-                               }
-                       );
+               if( !wgAjaxLicensePreview || !sajax_init_object() ) return;
+               for (cached in this.responseCache) {
+                       if (cached == license) {
+                               this.showPreview( this.responseCache[license] );
+                               return;
+                       }
                }
+               injectSpinner( document.getElementById( 'wpLicense' ), 'license' );
+               sajax_do_call( 'UploadForm::ajaxGetLicensePreview', [license],
+                       function( result ) {
+                               wgUploadLicenseObj.processResult( result, license );
+                       }
+               );
        },
 
        'processResult' : function( result, license ) {
index 484ef01..becd511 100644 (file)
@@ -725,7 +725,9 @@ function addCheckboxClickHandlers(inputs, start) {
                var cb = inputs[i];
                if ( !cb.type || cb.type.toLowerCase() != 'checkbox' )
                        continue;
-               cb.index = checkboxes.push(cb) - 1;
+               var end = checkboxes.length;
+               checkboxes[end] = cb;
+               cb.index = end;
                cb.onmouseup = checkboxMouseupHandler;
        }
 
@@ -890,11 +892,13 @@ function getElementsByClassName(oElm, strTagName, oClassNames){
        var arrRegExpClassNames = new Array();
        if(typeof oClassNames == "object"){
                for(var i=0; i<oClassNames.length; i++){
-                       arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
+                       arrRegExpClassNames[arrRegExpClassNames.length] =
+                               new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)");
                }
        }
        else{
-               arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
+               arrRegExpClassNames[arrRegExpClassNames.length] =
+                       new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)");
        }
        var oElement;
        var bMatchesAll;
@@ -908,7 +912,7 @@ function getElementsByClassName(oElm, strTagName, oClassNames){
                        }
                }
                if(bMatchesAll){
-                       arrReturnElements.push(oElement);
+                       arrReturnElements[arrReturnElements.length] = oElement;
                }
        }
        return (arrReturnElements)