r78523 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78522‎ | r78523 | r78524 >
Date:23:21, 16 December 2010
Author:neilk
Status:deferred
Tags:
Comment:
replace string.trim() with .trim() for compatibility with older JS versions
Modified paths:
  • /trunk/extensions/UploadWizard/resources/combined.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/combined.min.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/jquery/jquery.mwCoolCats.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/jquery/jquery.mwCoolCats.js
@@ -63,9 +63,9 @@
6464 _processInput();
6565 });
6666
67 - function _processInput() {
 67+ function _processInput() {
6868 var $input = $container.find( 'input' );
69 - _insertCat( $input.val().trim() );
 69+ _insertCat( $j.trim( $input.val() ) );
7070 $input.val("");
7171 }
7272
Index: trunk/extensions/UploadWizard/resources/combined.js
@@ -6360,9 +6360,9 @@
63616361 _processInput();
63626362 });
63636363
6364 - function _processInput() {
 6364+ function _processInput() {
63656365 var $input = $container.find( 'input' );
6366 - _insertCat( $input.val().trim() );
 6366+ _insertCat( $j.trim( $input.val() ) );
63676367 $input.val("");
63686368 }
63696369
@@ -11072,13 +11072,13 @@
1107311073 */
1107411074 getWikiText: function() {
1107511075 var _this = this;
11076 - var description = $j( _this.input ).val().trim();
 11076+ var description = $j.trim( $j( _this.input ).val() );
1107711077 // we assume that form validation has caught this problem if this is a required field
1107811078 // if not, assume the user is trying to blank a description in another language
1107911079 if ( description.length === 0 ) {
1108011080 return '';
1108111081 }
11082 - var language = $j( _this.languageMenu ).val().trim();
 11082+ var language = $j.trim( $j( _this.languageMenu ).val() );
1108311083 var fix = mw.UploadWizard.config[ "languageTemplateFixups" ];
1108411084 if (fix[language]) {
1108511085 language = fix[language];
@@ -11583,7 +11583,7 @@
1158411584 $j.each([metadata.datetimeoriginal, metadata.datetimedigitized, metadata.datetime, metadata['date']],
1158511585 function( i, imageinfoDate ) {
1158611586 if ( ! mw.isEmpty( imageinfoDate ) ) {
11587 - var matches = imageinfoDate.trim().match( yyyyMmDdRegex );
 11587+ var matches = $j.trim( imageinfoDate ).match( yyyyMmDdRegex );
1158811588 if ( ! mw.isEmpty( matches ) ) {
1158911589 dateObj = new Date( parseInt( matches[1], 10 ),
1159011590 parseInt( matches[2], 10 ) - 1,
@@ -11760,7 +11760,7 @@
1176111761 } );
1176211762
1176311763 // XXX add a sanity check here for good date
11764 - information['date'] = $j( _this.dateInput ).val().trim();
 11764+ information['date'] = $j.trim( $j( _this.dateInput ).val() );
1176511765
1176611766 var deed = _this.upload.deedChooser.deed;
1176711767
@@ -11780,7 +11780,7 @@
1178111781 // add a location template if possible
1178211782
1178311783 // add an "anything else" template if needed
11784 - var otherInfoWikiText = $j( _this.otherInformationInput ).val().trim();
 11784+ var otherInfoWikiText = $j.trim( $j( _this.otherInformationInput ).val() );
1178511785 if ( ! mw.isEmpty( otherInfoWikiText ) ) {
1178611786 wikiText += otherInfoWikiText + "\n\n";
1178711787 }
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -687,13 +687,13 @@
688688 */
689689 getWikiText: function() {
690690 var _this = this;
691 - var description = $j( _this.input ).val().trim();
 691+ var description = $j.trim( $j( _this.input ).val() );
692692 // we assume that form validation has caught this problem if this is a required field
693693 // if not, assume the user is trying to blank a description in another language
694694 if ( description.length === 0 ) {
695695 return '';
696696 }
697 - var language = $j( _this.languageMenu ).val().trim();
 697+ var language = $j.trim( $j( _this.languageMenu ).val() );
698698 var fix = mw.UploadWizard.config[ "languageTemplateFixups" ];
699699 if (fix[language]) {
700700 language = fix[language];
@@ -1198,7 +1198,7 @@
11991199 $j.each([metadata.datetimeoriginal, metadata.datetimedigitized, metadata.datetime, metadata['date']],
12001200 function( i, imageinfoDate ) {
12011201 if ( ! mw.isEmpty( imageinfoDate ) ) {
1202 - var matches = imageinfoDate.trim().match( yyyyMmDdRegex );
 1202+ var matches = $j.trim( imageinfoDate ).match( yyyyMmDdRegex );
12031203 if ( ! mw.isEmpty( matches ) ) {
12041204 dateObj = new Date( parseInt( matches[1], 10 ),
12051205 parseInt( matches[2], 10 ) - 1,
@@ -1375,7 +1375,7 @@
13761376 } );
13771377
13781378 // XXX add a sanity check here for good date
1379 - information['date'] = $j( _this.dateInput ).val().trim();
 1379+ information['date'] = $j.trim( $j( _this.dateInput ).val() );
13801380
13811381 var deed = _this.upload.deedChooser.deed;
13821382
@@ -1395,7 +1395,7 @@
13961396 // add a location template if possible
13971397
13981398 // add an "anything else" template if needed
1399 - var otherInfoWikiText = $j( _this.otherInformationInput ).val().trim();
 1399+ var otherInfoWikiText = $j.trim( $j( _this.otherInformationInput ).val() );
14001400 if ( ! mw.isEmpty( otherInfoWikiText ) ) {
14011401 wikiText += otherInfoWikiText + "\n\n";
14021402 }
Index: trunk/extensions/UploadWizard/resources/combined.min.js
@@ -6362,7 +6362,7 @@
63636363
63646364 function _processInput(){
63656365 var $input=$container.find('input');
6366 -_insertCat($input.val().trim());
 6366+_insertCat($j.trim($input.val()));
63676367 $input.val("");
63686368 }
63696369
@@ -11072,13 +11072,13 @@
1107311073
1107411074 getWikiText:function(){
1107511075 var _this=this;
11076 -var description=$j(_this.input).val().trim();
 11076+var description=$j.trim($j(_this.input).val());
1107711077
1107811078
1107911079 if(description.length===0){
1108011080 return'';
1108111081 }
11082 -var language=$j(_this.languageMenu).val().trim();
 11082+var language=$j.trim($j(_this.languageMenu).val());
1108311083 var fix=mw.UploadWizard.config["languageTemplateFixups"];
1108411084 if(fix[language]){
1108511085 language=fix[language];
@@ -11583,7 +11583,7 @@
1158411584 $j.each([metadata.datetimeoriginal,metadata.datetimedigitized,metadata.datetime,metadata['date']],
1158511585 function(i,imageinfoDate){
1158611586 if(!mw.isEmpty(imageinfoDate)){
11587 -var matches=imageinfoDate.trim().match(yyyyMmDdRegex);
 11587+var matches=$j.trim(imageinfoDate).match(yyyyMmDdRegex);
1158811588 if(!mw.isEmpty(matches)){
1158911589 dateObj=new Date(parseInt(matches[1],10),
1159011590 parseInt(matches[2],10)-1,
@@ -11760,7 +11760,7 @@
1176111761 });
1176211762
1176311763
11764 -information['date']=$j(_this.dateInput).val().trim();
 11764+information['date']=$j.trim($j(_this.dateInput).val());
1176511765
1176611766 var deed=_this.upload.deedChooser.deed;
1176711767
@@ -11780,7 +11780,7 @@
1178111781
1178211782
1178311783
11784 -var otherInfoWikiText=$j(_this.otherInformationInput).val().trim();
 11784+var otherInfoWikiText=$j.trim($j(_this.otherInformationInput).val());
1178511785 if(!mw.isEmpty(otherInfoWikiText)){
1178611786 wikiText+=otherInfoWikiText+"\n\n";
1178711787 }

Status & tagging log