r83619 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83618‎ | r83619 | r83620 >
Date:00:14, 10 March 2011
Author:neilk
Status:ok
Tags:
Comment:
fixed some parseInts to have a base, renamed a var from number -> num since number is reserved
Modified paths:
  • /trunk/phase3/resources/mediawiki.language/mediawiki.language.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.language/mediawiki.language.js
@@ -28,7 +28,7 @@
2929 // Restore the count into a Number ( if it got converted earlier )
3030 var count = mw.language.convertNumber( template.title, true );
3131 // Do convertPlural call
32 - return mw.language.convertPlural( parseInt( count ), template.parameters );
 32+ return mw.language.convertPlural( parseInt( count, 10 ), template.parameters );
3333 }
3434 // Could not process plural return first form or nothing
3535 if ( template.parameters[0] ) {
@@ -47,7 +47,7 @@
4848 if ( !forms || forms.length == 0 ) {
4949 return '';
5050 }
51 - return ( parseInt( count ) == 1 ) ? forms[0] : forms[1];
 51+ return ( parseInt( count, 10 ) == 1 ) ? forms[0] : forms[1];
5252 },
5353 /**
5454 * Pads an array to a specific length by copying the last one element.
@@ -68,16 +68,16 @@
6969 * @param {number} number Value to be converted
7070 * @param {boolean} integer Convert the return value to an integer
7171 */
72 - 'convertNumber': function( number, integer ) {
 72+ 'convertNumber': function( num, integer ) {
7373 if ( !mw.language.digitTransformTable ) {
74 - return number;
 74+ return num;
7575 }
7676 // Set the target Transform table:
7777 var transformTable = mw.language.digitTransformTable;
7878 // Check if the "restore" to Latin number flag is set:
7979 if ( integer ) {
80 - if ( parseInt( number ) == number ) {
81 - return number;
 80+ if ( parseInt( num, 10 ) == num ) {
 81+ return num;
8282 }
8383 var tmp = [];
8484 for ( var i in transformTable ) {
@@ -85,7 +85,7 @@
8686 }
8787 transformTable = tmp;
8888 }
89 - var numberString = '' + number;
 89+ var numberString = '' + num;
9090 var convertedNumber = '';
9191 for ( var i = 0; i < numberString.length; i++ ) {
9292 if ( transformTable[ numberString[i] ] ) {
@@ -99,4 +99,4 @@
100100 // Digit Transform Table, populated by language classes where applicable
101101 'digitTransformTable': null
102102 };
103 -} )( jQuery, mediaWiki );
\ No newline at end of file
 103+} )( jQuery, mediaWiki );

Follow-up revisions

RevisionCommit summaryAuthorDate
r84201parseInt with base 10, update comment (number -> num)...hashar20:37, 17 March 2011

Status & tagging log