r24259 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24258‎ | r24259 | r24260 >
Date:22:13, 18 July 2007
Author:brion
Status:old
Tags:
Comment:
Fix several JS problems with MSIE/Mac:
* 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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/skins/common/upload.js (modified) (history)
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/upload.js
@@ -8,9 +8,7 @@
99 }
1010 }
1111 // We might show a preview
12 - if( wgAjaxLicensePreview ) {
13 - wgUploadLicenseObj.fetchPreview( selection );
14 - }
 12+ wgUploadLicenseObj.fetchPreview( selection );
1513 }
1614
1715 function licenseSelectorFixup() {
@@ -36,6 +34,8 @@
3735 'timeoutID': false,
3836
3937 'keypress': function () {
 38+ if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
 39+
4040 // Find file to upload
4141 var destFile = document.getElementById('wpDestFile');
4242 var warningElt = document.getElementById( 'wpDestFile-warning' );
@@ -48,15 +48,18 @@
4949 window.clearTimeout( this.timeoutID );
5050 }
5151 // Check response cache
52 - if ( this.nameToCheck in this.responseCache ) {
53 - this.setWarning(this.responseCache[this.nameToCheck]);
54 - return;
 52+ for (cached in this.responseCache) {
 53+ if (this.nameToCheck == cached) {
 54+ this.setWarning(this.responseCache[this.nameToCheck]);
 55+ return;
 56+ }
5557 }
5658
5759 this.timeoutID = window.setTimeout( 'wgUploadWarningObj.timeout()', this.delay );
5860 },
5961
6062 'checkNow': function (fname) {
 63+ if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
6164 if ( this.timeoutID ) {
6265 window.clearTimeout( this.timeoutID );
6366 }
@@ -65,6 +68,7 @@
6669 },
6770
6871 'timeout' : function() {
 72+ if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
6973 injectSpinner( document.getElementById( 'wpDestFile' ), 'destcheck' );
7074
7175 // Get variables into local scope so that they will be preserved for the
@@ -131,9 +135,7 @@
132136 var destFile = document.getElementById('wpDestFile');
133137 if (destFile) {
134138 destFile.value = fname;
135 - if ( wgAjaxUploadDestCheck ) {
136 - wgUploadWarningObj.checkNow(fname) ;
137 - }
 139+ wgUploadWarningObj.checkNow(fname) ;
138140 }
139141 }
140142
@@ -142,18 +144,19 @@
143145 'responseCache' : { '' : '' },
144146
145147 'fetchPreview': function( license ) {
146 - if( license == "" ) {
147 - this.showPreview( "" );
148 - } else if( license in this.responseCache ) {
149 - this.showPreview( this.responseCache[license] );
150 - } else {
151 - injectSpinner( document.getElementById( 'wpLicense' ), 'license' );
152 - sajax_do_call( 'UploadForm::ajaxGetLicensePreview', [license],
153 - function( result ) {
154 - wgUploadLicenseObj.processResult( result, license );
155 - }
156 - );
 148+ if( !wgAjaxLicensePreview || !sajax_init_object() ) return;
 149+ for (cached in this.responseCache) {
 150+ if (cached == license) {
 151+ this.showPreview( this.responseCache[license] );
 152+ return;
 153+ }
157154 }
 155+ injectSpinner( document.getElementById( 'wpLicense' ), 'license' );
 156+ sajax_do_call( 'UploadForm::ajaxGetLicensePreview', [license],
 157+ function( result ) {
 158+ wgUploadLicenseObj.processResult( result, license );
 159+ }
 160+ );
158161 },
159162
160163 'processResult' : function( result, license ) {
Index: trunk/phase3/skins/common/wikibits.js
@@ -725,7 +725,9 @@
726726 var cb = inputs[i];
727727 if ( !cb.type || cb.type.toLowerCase() != 'checkbox' )
728728 continue;
729 - cb.index = checkboxes.push(cb) - 1;
 729+ var end = checkboxes.length;
 730+ checkboxes[end] = cb;
 731+ cb.index = end;
730732 cb.onmouseup = checkboxMouseupHandler;
731733 }
732734
@@ -890,11 +892,13 @@
891893 var arrRegExpClassNames = new Array();
892894 if(typeof oClassNames == "object"){
893895 for(var i=0; i<oClassNames.length; i++){
894 - arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
 896+ arrRegExpClassNames[arrRegExpClassNames.length] =
 897+ new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)");
895898 }
896899 }
897900 else{
898 - arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
 901+ arrRegExpClassNames[arrRegExpClassNames.length] =
 902+ new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)");
899903 }
900904 var oElement;
901905 var bMatchesAll;
@@ -908,7 +912,7 @@
909913 }
910914 }
911915 if(bMatchesAll){
912 - arrReturnElements.push(oElement);
 916+ arrReturnElements[arrReturnElements.length] = oElement;
913917 }
914918 }
915919 return (arrReturnElements)
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1201,7 +1201,7 @@
12021202 * to ensure that client-side caches don't keep obsolete copies of global
12031203 * styles.
12041204 */
1205 -$wgStyleVersion = '87';
 1205+$wgStyleVersion = '88';
12061206
12071207
12081208 # Server-side caching:
Index: trunk/phase3/RELEASE-NOTES
@@ -313,6 +313,7 @@
314314 * (bug 8054) Return search page for empty search requests with ugly URLs
315315 * (bug 10572) Force refresh after clearing visitation timestamps on watchlist
316316 * (bug 10631) Warn when illegal characters are removed from filename at upload
 317+* Fix several JavaScript bugs under MSIE 5/Macintosh
317318
318319 == API changes since 1.10 ==
319320

Follow-up revisions

RevisionCommit summaryAuthorDate
r24276Merged revisions 24213-24275 via svnmerge from...david20:20, 19 July 2007

Status & tagging log