r78845 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78844‎ | r78845 | r78846 >
Date:21:51, 22 December 2010
Author:neilk
Status:deferred
Tags:
Comment:
jslint fixes
Modified paths:
  • /trunk/extensions/UploadWizard/resources/language/mw.Language.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/language/mw.Language.js
@@ -33,7 +33,7 @@
3434 for ( var i in msgSet ) {
3535 messageCache[ i ] = msgSet[i];
3636 }
37 - }
 37+ };
3838
3939 /**
4040 * Returns a transformed msg string
@@ -79,7 +79,7 @@
8080 }
8181 }
8282 // Fast check message text return ( no arguments and no parsing needed )
83 - if( ( !args || args.length == 0 )
 83+ if( ( !args || args.length === 0 )
8484 && messageCache[ messageKey ].indexOf( '{{' ) === -1
8585 && messageCache[ messageKey ].indexOf( '[' ) === -1
8686 ) {
@@ -91,7 +91,7 @@
9292
9393 // Return the jQuery object or message string
9494 return messageSwap.getMsg();
95 - }
 95+ };
9696
9797 /**
9898 * A message Swap Object
@@ -103,16 +103,14 @@
104104
105105 mw.Language.messageSwapObject = function( message, arguments ){
106106 this.init( message, arguments );
107 - }
 107+ };
108108
109109 mw.Language.messageSwapObject.prototype= {
110110 /* constructor */
111111 init: function( message, arguments ){
112112 this.message = message;
113113 this.arguments = arguments;
114 -
115 - // Set the includesjQueryArgs flag to false
116 - includesjQueryArgs: false;
 114+ this.includesjQueryArgs = false;
117115 },
118116
119117 // Return the transformed message text or jQuery object
@@ -126,7 +124,7 @@
127125 && ! this.includesjQueryArgs )
128126 {
129127 // replaceStringArgs is all we need, return the msg
130 - return this.message
 128+ return this.message;
131129 }
132130
133131 // Else Send the messageText through the parser
@@ -165,12 +163,12 @@
166164 var replaceValue = this.arguments[ v ];
167165
168166 // Convert number if applicable
169 - if( parseInt( replaceValue ) == replaceValue ) {
 167+ if( parseInt( replaceValue, 10 ) == replaceValue ) {
170168 replaceValue = mw.Language.convertNumber( replaceValue );
171169 }
172170
173171 // Message test replace arguments start at 1 instead of zero:
174 - var argumentRegExp = new RegExp( '\\$' + ( parseInt( v ) + 1 ), 'g' );
 172+ var argumentRegExp = new RegExp( '\\$' + ( parseInt( v, 10 ) + 1 ), 'g' );
175173
176174 // Check if we got passed in a jQuery object:
177175 if( replaceValue instanceof jQuery) {
@@ -215,7 +213,7 @@
216214 continue;
217215 }
218216
219 - if( $swapTarget.html() != '' ) {
 217+ if( $swapTarget.html() !== '' ) {
220218 $replaceValue.html( $swapTarget.html() );
221219 }
222220
@@ -226,7 +224,7 @@
227225 // Return the jQuery object ( if no jQuery substitution occurred we return false )
228226 return $jQueryMessage;
229227 }
230 - }
 228+ };
231229
232230 /**
233231 * Get msg content without transformation
@@ -234,12 +232,12 @@
235233 * @returns string The msg key without transforming it
236234 */
237235 mw.Language.msgNoTrans = function( key ) {
238 - if ( messageCache[ key ] )
239 - return messageCache[ key ]
240 -
 236+ if ( messageCache[ key ] ) {
 237+ return messageCache[ key ];
 238+ }
241239 // Missing key placeholder
242240 return '<' + key + '>';
243 - }
 241+ };
244242
245243 /**
246244 * Add Supported Magic Words to parser
@@ -251,12 +249,12 @@
252250 mw.addTemplateTransform ( {
253251 'PLURAL' : mw.Language.procPLURAL,
254252 'GENDER' : mw.Language.procGENDER
255 - } )
 253+ } );
256254
257255 mw.Language.doneSetup = true;
258256 }
259257
260 - }
 258+ };
261259
262260 /**
263261 * List of all languages mediaWiki supports ( Avoid an api call to get this same info )
@@ -668,14 +666,14 @@
669667
670668 if( templateObject.arg && templateObject.param && mw.Language.convertPlural) {
671669 // Check if we have forms to replace
672 - if ( templateObject.param.length == 0 ) {
 670+ if ( templateObject.param.length === 0 ) {
673671 return '';
674672 }
675673 // Restore the count into a Number ( if it got converted earlier )
676674 var count = mw.Language.convertNumber( templateObject.arg, true );
677675
678676 // Do convertPlural call
679 - return mw.Language.convertPlural( parseInt( count ), templateObject.param );
 677+ return mw.Language.convertPlural( parseInt( count, 10 ), templateObject.param );
680678
681679 }
682680 // Could not process plural return first form or nothing
@@ -688,15 +686,15 @@
689687 // NOTE:: add gender support here
690688 mw.Language.procGENDER = function( templateObject ){
691689 return 'gender-not-supported-in-js-yet';
692 - }
 690+ };
693691 /*
694692 * Base convertPlural function:
695693 */
696694 mw.Language.convertPlural = function( count, forms ){
697 - if ( !forms || forms.length == 0 ) {
 695+ if ( !forms || forms.length === 0 ) {
698696 return '';
699697 }
700 - return ( parseInt( count ) == 1 ) ? forms[0] : forms[1];
 698+ return ( parseInt( count, 10 ) === 1 ) ? forms[0] : forms[1];
701699 };
702700 /**
703701 * Checks that convertPlural was given an array and pads it to requested
@@ -732,7 +730,7 @@
733731
734732 // Check if the "restore" to latin number flag is set:
735733 if( typeInt ) {
736 - if( parseInt( number ) == number )
 734+ if( parseInt( number, 10 ) === number )
737735 return number;
738736 var tmp = [];
739737 for( var i in transformTable ) {
@@ -743,15 +741,15 @@
744742
745743 var numberString = '' + number;
746744 var convertedNumber = '';
747 - for( var i =0; i < numberString.length; i++) {
 745+ for( var i = 0; i < numberString.length; i++) {
748746 if( transformTable[ numberString[i] ] ) {
749747 convertedNumber += transformTable[ numberString[i] ];
750 - }else{
 748+ } else {
751749 convertedNumber += numberString[i];
752750 }
753751 }
754 - return ( typeInt )? parseInt( convertedNumber) : convertedNumber;
755 - }
 752+ return ( typeInt ) ? parseInt( convertedNumber, 10 ) : convertedNumber;
 753+ };
756754
757755 /**
758756 * Checks if a language key is valid ( is part of languageCodeList )
@@ -760,7 +758,7 @@
761759 */
762760 mw.isValidLang = function( langKey ) {
763761 return ( mw.Language.names[ langKey ] )? true : false;
764 - }
 762+ };
765763
766764 /**
767765 * Format a number
@@ -790,7 +788,7 @@
791789 }
792790 // @@todo read language code and give periods or comas:
793791 return addSeparatorsNF( num, '.', ',' );
794 - }
 792+ };
795793
796794 }) ( window.mediaWiki );
797795

Status & tagging log