From aceff2e778270345fa4bebf536d70fe278712885 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Thu, 3 Sep 2015 13:15:33 -0700 Subject: [PATCH] build: Enable jscs rules 'requireSpacesInside*Brackets' and make pass Change-Id: I1cd5b9b92b6e9419d99d9a15ad88a996253ca4cf --- .jscsrc | 2 - Gruntfile.js | 6 +- resources/src/jquery/jquery.accessKeyLabel.js | 4 +- resources/src/jquery/jquery.autoEllipsis.js | 38 +-- resources/src/jquery/jquery.byteLimit.js | 6 +- resources/src/jquery/jquery.color.js | 10 +- resources/src/jquery/jquery.colorUtil.js | 124 ++++---- .../src/jquery/jquery.expandableField.js | 14 +- resources/src/jquery/jquery.getAttrs.js | 4 +- resources/src/jquery/jquery.hidpi.js | 8 +- resources/src/jquery/jquery.highlightText.js | 8 +- resources/src/jquery/jquery.localize.js | 6 +- resources/src/jquery/jquery.mwExtension.js | 16 +- resources/src/jquery/jquery.placeholder.js | 12 +- .../jquery/jquery.qunit.completenessTest.js | 6 +- resources/src/jquery/jquery.suggestions.js | 34 +-- resources/src/jquery/jquery.tablesorter.js | 204 ++++++------- resources/src/jquery/jquery.textSelection.js | 4 +- ...mediawiki.action.edit.collapsibleFooter.js | 6 +- .../mediawiki.action.edit.preview.js | 26 +- resources/src/mediawiki.api/mediawiki.api.js | 14 +- .../mediawiki.api/mediawiki.api.options.js | 4 +- .../src/mediawiki.api/mediawiki.api.parse.js | 2 +- .../src/mediawiki.api/mediawiki.api.upload.js | 12 +- .../src/mediawiki.api/mediawiki.api.watch.js | 2 +- .../src/mediawiki.language/languages/bs.js | 4 +- .../src/mediawiki.language/languages/dsb.js | 4 +- .../src/mediawiki.language/languages/fi.js | 4 +- .../src/mediawiki.language/languages/ga.js | 4 +- .../src/mediawiki.language/languages/he.js | 4 +- .../src/mediawiki.language/languages/hsb.js | 4 +- .../src/mediawiki.language/languages/hu.js | 4 +- .../src/mediawiki.language/languages/hy.js | 4 +- .../src/mediawiki.language/languages/la.js | 4 +- .../src/mediawiki.language/languages/os.js | 4 +- .../src/mediawiki.language/languages/ru.js | 4 +- .../src/mediawiki.language/languages/sl.js | 4 +- .../src/mediawiki.language/languages/uk.js | 4 +- .../src/mediawiki.language/mediawiki.cldr.js | 2 +- .../mediawiki.language.init.js | 10 +- .../mediawiki.language/mediawiki.language.js | 24 +- .../mediawiki.language.numbers.js | 48 ++-- resources/src/mediawiki.legacy/protect.js | 2 +- resources/src/mediawiki.legacy/wikibits.js | 10 +- .../mediawiki.messagePoster.factory.js | 12 +- .../mediawiki.page/mediawiki.page.gallery.js | 36 +-- .../mediawiki.page.image.pagination.js | 8 +- .../mediawiki.page.watch.ajax.js | 8 +- .../mediawiki.special.preferences.js | 10 +- .../mediawiki.special.search.js | 6 +- .../mediawiki.special.upload.js | 32 +-- .../mediawiki.special.userlogin.signup.js | 2 +- resources/src/mediawiki.toolbar/toolbar.js | 2 +- .../mw.widgets.CalendarWidget.js | 2 +- .../mw.widgets.DateInputWidget.js | 2 +- .../mw.widgets.TitleInputWidget.js | 26 +- .../mw.widgets.UserInputWidget.js | 4 +- .../mediawiki.ForeignStructuredUpload.js | 6 +- resources/src/mediawiki/mediawiki.Title.js | 40 +-- resources/src/mediawiki/mediawiki.Uri.js | 8 +- resources/src/mediawiki/mediawiki.debug.js | 14 +- .../src/mediawiki/mediawiki.experiments.js | 4 +- resources/src/mediawiki/mediawiki.htmlform.js | 34 +-- resources/src/mediawiki/mediawiki.inspect.js | 22 +- .../src/mediawiki/mediawiki.jqueryMsg.js | 124 ++++---- resources/src/mediawiki/mediawiki.js | 264 ++++++++--------- .../src/mediawiki/mediawiki.notification.js | 2 +- .../src/mediawiki/mediawiki.searchSuggest.js | 12 +- resources/src/mediawiki/mediawiki.template.js | 8 +- resources/src/mediawiki/mediawiki.user.js | 20 +- .../src/mediawiki/mediawiki.userSuggest.js | 6 +- resources/src/mediawiki/mediawiki.util.js | 8 +- resources/src/startup.js | 12 +- tests/qunit/data/testrunner.js | 12 +- .../jquery/jquery.accessKeyLabel.test.js | 38 +-- .../jquery/jquery.autoEllipsis.test.js | 4 +- .../resources/jquery/jquery.color.test.js | 2 +- .../resources/jquery/jquery.colorUtil.test.js | 36 +-- .../resources/jquery/jquery.localize.test.js | 6 +- .../jquery/jquery.mwExtension.test.js | 4 +- .../jquery/jquery.placeholder.test.js | 10 +- .../jquery/jquery.tablesorter.parsers.test.js | 210 +++++++------- .../jquery/jquery.tablesorter.test.js | 272 +++++++++--------- .../jquery/jquery.textSelection.test.js | 4 +- .../mediawiki.api/mediawiki.api.test.js | 6 +- .../mediawiki.api.upload.test.js | 2 +- .../mediawiki.api/mediawiki.api.watch.test.js | 6 +- .../mediawiki/mediawiki.Title.test.js | 28 +- .../resources/mediawiki/mediawiki.Uri.test.js | 6 +- .../mediawiki/mediawiki.cldr.test.js | 6 +- .../mediawiki/mediawiki.cookie.test.js | 4 +- .../mediawiki/mediawiki.jqueryMsg.test.js | 22 +- .../mediawiki/mediawiki.language.test.js | 12 +- .../mediawiki.messagePoster.factory.test.js | 2 +- .../resources/mediawiki/mediawiki.test.js | 118 ++++---- .../mediawiki/mediawiki.util.test.js | 108 +++---- 96 files changed, 1185 insertions(+), 1187 deletions(-) diff --git a/.jscsrc b/.jscsrc index 35465eae40..70a404b621 100644 --- a/.jscsrc +++ b/.jscsrc @@ -2,9 +2,7 @@ "preset": "wikimedia", "disallowQuotedKeysInObjects": null, - "requireSpacesInsideArrayBrackets": null, "requireVarDeclFirst": null, - "requireSpacesInsideBrackets": null, "jsDoc": null, "requireDotNotation": { "allExcept": [ "keywords" ] }, diff --git a/Gruntfile.js b/Gruntfile.js index 4d713f2a58..035a208131 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,7 +12,7 @@ module.exports = function ( grunt ) { wgScriptPath = process.env.MW_SCRIPT_PATH, karmaProxy = {}; - karmaProxy[wgScriptPath] = wgServer + wgScriptPath; + karmaProxy[ wgScriptPath ] = wgServer + wgScriptPath; grunt.initConfig( { jshint: { @@ -92,9 +92,9 @@ module.exports = function ( grunt ) { return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH ); } ); - grunt.registerTask( 'lint', ['jshint', 'jscs', 'jsonlint', 'banana'] ); + grunt.registerTask( 'lint', [ 'jshint', 'jscs', 'jsonlint', 'banana' ] ); grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] ); - grunt.registerTask( 'test', ['lint'] ); + grunt.registerTask( 'test', [ 'lint' ] ); grunt.registerTask( 'default', 'test' ); }; diff --git a/resources/src/jquery/jquery.accessKeyLabel.js b/resources/src/jquery/jquery.accessKeyLabel.js index 1ac34a5271..92f8eb9c54 100644 --- a/resources/src/jquery/jquery.accessKeyLabel.js +++ b/resources/src/jquery/jquery.accessKeyLabel.js @@ -150,14 +150,14 @@ function updateTooltip( element ) { if ( id ) { $label = $( 'label[for="' + id + '"]' ); if ( $label.length === 1 ) { - updateTooltipOnElement( element, $label[0] ); + updateTooltipOnElement( element, $label[ 0 ] ); } } // Search it as parent, because the form control can also be inside the label element itself $labelParent = $element.parents( 'label' ); if ( $labelParent.length === 1 ) { - updateTooltipOnElement( element, $labelParent[0] ); + updateTooltipOnElement( element, $labelParent[ 0 ] ); } } } diff --git a/resources/src/jquery/jquery.autoEllipsis.js b/resources/src/jquery/jquery.autoEllipsis.js index 9a196b5dbc..e1115d6504 100644 --- a/resources/src/jquery/jquery.autoEllipsis.js +++ b/resources/src/jquery/jquery.autoEllipsis.js @@ -69,16 +69,16 @@ $.fn.autoEllipsis = function ( options ) { // Try cache if ( options.matchText ) { if ( !( text in matchTextCache ) ) { - matchTextCache[text] = {}; + matchTextCache[ text ] = {}; } - if ( !( options.matchText in matchTextCache[text] ) ) { - matchTextCache[text][options.matchText] = {}; + if ( !( options.matchText in matchTextCache[ text ] ) ) { + matchTextCache[ text ][ options.matchText ] = {}; } - if ( !( w in matchTextCache[text][options.matchText] ) ) { - matchTextCache[text][options.matchText][w] = {}; + if ( !( w in matchTextCache[ text ][ options.matchText ] ) ) { + matchTextCache[ text ][ options.matchText ][ w ] = {}; } - if ( options.position in matchTextCache[text][options.matchText][w] ) { - $container.html( matchTextCache[text][options.matchText][w][options.position] ); + if ( options.position in matchTextCache[ text ][ options.matchText ][ w ] ) { + $container.html( matchTextCache[ text ][ options.matchText ][ w ][ options.position ] ); if ( options.tooltip ) { $container.attr( 'title', text ); } @@ -86,13 +86,13 @@ $.fn.autoEllipsis = function ( options ) { } } else { if ( !( text in cache ) ) { - cache[text] = {}; + cache[ text ] = {}; } - if ( !( w in cache[text] ) ) { - cache[text][w] = {}; + if ( !( w in cache[ text ] ) ) { + cache[ text ][ w ] = {}; } - if ( options.position in cache[text][w] ) { - $container.html( cache[text][w][options.position] ); + if ( options.position in cache[ text ][ w ] ) { + $container.html( cache[ text ][ w ][ options.position ] ); if ( options.tooltip ) { $container.attr( 'title', text ); } @@ -120,19 +120,19 @@ $.fn.autoEllipsis = function ( options ) { break; case 'center': // TODO: Use binary search like for 'right' - i = [Math.round( trimmableText.length / 2 ), Math.round( trimmableText.length / 2 )]; + i = [ Math.round( trimmableText.length / 2 ), Math.round( trimmableText.length / 2 ) ]; // Begin with making the end shorter side = 1; - while ( $trimmableText.outerWidth() + pw > w && i[0] > 0 ) { - $trimmableText.text( trimmableText.slice( 0, i[0] ) + '...' + trimmableText.slice( i[1] ) ); + while ( $trimmableText.outerWidth() + pw > w && i[ 0 ] > 0 ) { + $trimmableText.text( trimmableText.slice( 0, i[ 0 ] ) + '...' + trimmableText.slice( i[ 1 ] ) ); // Alternate between trimming the end and begining if ( side === 0 ) { // Make the begining shorter - i[0]--; + i[ 0 ]--; side = 1; } else { // Make the end shorter - i[1]++; + i[ 1 ]++; side = 0; } } @@ -152,9 +152,9 @@ $.fn.autoEllipsis = function ( options ) { } if ( options.matchText ) { $container.highlightText( options.matchText ); - matchTextCache[text][options.matchText][w][options.position] = $container.html(); + matchTextCache[ text ][ options.matchText ][ w ][ options.position ] = $container.html(); } else { - cache[text][w][options.position] = $container.html(); + cache[ text ][ w ][ options.position ] = $container.html(); } } ); diff --git a/resources/src/jquery/jquery.byteLimit.js b/resources/src/jquery/jquery.byteLimit.js index afff463e92..6203239066 100644 --- a/resources/src/jquery/jquery.byteLimit.js +++ b/resources/src/jquery/jquery.byteLimit.js @@ -77,12 +77,12 @@ // until the limit is statisfied. if ( fn ) { // stop, when there is nothing to slice - bug 41450 - while ( $.byteLength( fn( inpParts.join( '' ) ) ) > byteLimit && inpParts[1].length > 0 ) { - inpParts[1] = inpParts[1].slice( 0, -1 ); + while ( $.byteLength( fn( inpParts.join( '' ) ) ) > byteLimit && inpParts[ 1 ].length > 0 ) { + inpParts[ 1 ] = inpParts[ 1 ].slice( 0, -1 ); } } else { while ( $.byteLength( inpParts.join( '' ) ) > byteLimit ) { - inpParts[1] = inpParts[1].slice( 0, -1 ); + inpParts[ 1 ] = inpParts[ 1 ].slice( 0, -1 ); } } diff --git a/resources/src/jquery/jquery.color.js b/resources/src/jquery/jquery.color.js index 5357a85874..a3cc8fc3af 100644 --- a/resources/src/jquery/jquery.color.js +++ b/resources/src/jquery/jquery.color.js @@ -37,17 +37,17 @@ 'color', 'outlineColor' ], function ( i, attr ) { - $.fx.step[attr] = function ( fx ) { + $.fx.step[ attr ] = function ( fx ) { if ( !fx.colorInit ) { fx.start = getColor( fx.elem, attr ); fx.end = $.colorUtil.getRGB( fx.end ); fx.colorInit = true; } - fx.elem.style[attr] = 'rgb(' + [ - Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[0] - fx.start[0] ) ) + fx.start[0], 10 ), 255 ), 0 ), - Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[1] - fx.start[1] ) ) + fx.start[1], 10 ), 255 ), 0 ), - Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[2] - fx.start[2] ) ) + fx.start[2], 10 ), 255 ), 0 ) + fx.elem.style[ attr ] = 'rgb(' + [ + Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[ 0 ] - fx.start[ 0 ] ) ) + fx.start[ 0 ], 10 ), 255 ), 0 ), + Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[ 1 ] - fx.start[ 1 ] ) ) + fx.start[ 1 ], 10 ), 255 ), 0 ), + Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[ 2 ] - fx.start[ 2 ] ) ) + fx.start[ 2 ], 10 ), 255 ), 0 ) ].join( ',' ) + ')'; }; } ); diff --git a/resources/src/jquery/jquery.colorUtil.js b/resources/src/jquery/jquery.colorUtil.js index d5bb051be2..c14f2c861c 100644 --- a/resources/src/jquery/jquery.colorUtil.js +++ b/resources/src/jquery/jquery.colorUtil.js @@ -34,36 +34,36 @@ // Look for rgb(num,num,num) if ( result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec( color ) ) { return [ - parseInt( result[1], 10 ), - parseInt( result[2], 10 ), - parseInt( result[3], 10 ) + parseInt( result[ 1 ], 10 ), + parseInt( result[ 2 ], 10 ), + parseInt( result[ 3 ], 10 ) ]; } // Look for rgb(num%,num%,num%) if ( result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec( color ) ) { return [ - parseFloat( result[1] ) * 2.55, - parseFloat( result[2] ) * 2.55, - parseFloat( result[3] ) * 2.55 + parseFloat( result[ 1 ] ) * 2.55, + parseFloat( result[ 2 ] ) * 2.55, + parseFloat( result[ 3 ] ) * 2.55 ]; } // Look for #a0b1c2 if ( result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec( color ) ) { return [ - parseInt( result[1], 16 ), - parseInt( result[2], 16 ), - parseInt( result[3], 16 ) + parseInt( result[ 1 ], 16 ), + parseInt( result[ 2 ], 16 ), + parseInt( result[ 3 ], 16 ) ]; } // Look for #fff if ( result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec( color ) ) { return [ - parseInt( result[1] + result[1], 16 ), - parseInt( result[2] + result[2], 16 ), - parseInt( result[3] + result[3], 16 ) + parseInt( result[ 1 ] + result[ 1 ], 16 ), + parseInt( result[ 2 ] + result[ 2 ], 16 ), + parseInt( result[ 3 ] + result[ 3 ], 16 ) ]; } @@ -73,7 +73,7 @@ } // Otherwise, we're most likely dealing with a named color - return $.colorUtil.colors[$.trim( color ).toLowerCase()]; + return $.colorUtil.colors[ $.trim( color ).toLowerCase() ]; }, /** @@ -85,50 +85,50 @@ * @property {Object} */ colors: { - aqua: [0, 255, 255], - azure: [240, 255, 255], - beige: [245, 245, 220], - black: [0, 0, 0], - blue: [0, 0, 255], - brown: [165, 42, 42], - cyan: [0, 255, 255], - darkblue: [0, 0, 139], - darkcyan: [0, 139, 139], - darkgrey: [169, 169, 169], - darkgreen: [0, 100, 0], - darkkhaki: [189, 183, 107], - darkmagenta: [139, 0, 139], - darkolivegreen: [85, 107, 47], - darkorange: [255, 140, 0], - darkorchid: [153, 50, 204], - darkred: [139, 0, 0], - darksalmon: [233, 150, 122], - darkviolet: [148, 0, 211], - fuchsia: [255, 0, 255], - gold: [255, 215, 0], - green: [0, 128, 0], - indigo: [75, 0, 130], - khaki: [240, 230, 140], - lightblue: [173, 216, 230], - lightcyan: [224, 255, 255], - lightgreen: [144, 238, 144], - lightgrey: [211, 211, 211], - lightpink: [255, 182, 193], - lightyellow: [255, 255, 224], - lime: [0, 255, 0], - magenta: [255, 0, 255], - maroon: [128, 0, 0], - navy: [0, 0, 128], - olive: [128, 128, 0], - orange: [255, 165, 0], - pink: [255, 192, 203], - purple: [128, 0, 128], - violet: [128, 0, 128], - red: [255, 0, 0], - silver: [192, 192, 192], - white: [255, 255, 255], - yellow: [255, 255, 0], - transparent: [255, 255, 255] + aqua: [ 0, 255, 255 ], + azure: [ 240, 255, 255 ], + beige: [ 245, 245, 220 ], + black: [ 0, 0, 0 ], + blue: [ 0, 0, 255 ], + brown: [ 165, 42, 42 ], + cyan: [ 0, 255, 255 ], + darkblue: [ 0, 0, 139 ], + darkcyan: [ 0, 139, 139 ], + darkgrey: [ 169, 169, 169 ], + darkgreen: [ 0, 100, 0 ], + darkkhaki: [ 189, 183, 107 ], + darkmagenta: [ 139, 0, 139 ], + darkolivegreen: [ 85, 107, 47 ], + darkorange: [ 255, 140, 0 ], + darkorchid: [ 153, 50, 204 ], + darkred: [ 139, 0, 0 ], + darksalmon: [ 233, 150, 122 ], + darkviolet: [ 148, 0, 211 ], + fuchsia: [ 255, 0, 255 ], + gold: [ 255, 215, 0 ], + green: [ 0, 128, 0 ], + indigo: [ 75, 0, 130 ], + khaki: [ 240, 230, 140 ], + lightblue: [ 173, 216, 230 ], + lightcyan: [ 224, 255, 255 ], + lightgreen: [ 144, 238, 144 ], + lightgrey: [ 211, 211, 211 ], + lightpink: [ 255, 182, 193 ], + lightyellow: [ 255, 255, 224 ], + lime: [ 0, 255, 0 ], + magenta: [ 255, 0, 255 ], + maroon: [ 128, 0, 0 ], + navy: [ 0, 0, 128 ], + olive: [ 128, 128, 0 ], + orange: [ 255, 165, 0 ], + pink: [ 255, 192, 203 ], + purple: [ 128, 0, 128 ], + violet: [ 128, 0, 128 ], + red: [ 255, 0, 0 ], + silver: [ 192, 192, 192 ], + white: [ 255, 255, 255 ], + yellow: [ 255, 255, 0 ], + transparent: [ 255, 255, 255 ] }, /** @@ -179,7 +179,7 @@ h /= 6; } - return [h, s, l]; + return [ h, s, l ]; }, /** @@ -230,7 +230,7 @@ b = hue2rgb( p, q, h - 1 / 3 ); } - return [r * 255, g * 255, b * 255]; + return [ r * 255, g * 255, b * 255 ]; }, /** @@ -249,11 +249,11 @@ */ getColorBrightness: function ( currentColor, mod ) { var rgbArr = $.colorUtil.getRGB( currentColor ), - hslArr = $.colorUtil.rgbToHsl( rgbArr[0], rgbArr[1], rgbArr[2] ); - rgbArr = $.colorUtil.hslToRgb( hslArr[0], hslArr[1], hslArr[2] + mod ); + hslArr = $.colorUtil.rgbToHsl( rgbArr[ 0 ], rgbArr[ 1 ], rgbArr[ 2 ] ); + rgbArr = $.colorUtil.hslToRgb( hslArr[ 0 ], hslArr[ 1 ], hslArr[ 2 ] + mod ); return 'rgb(' + - [parseInt( rgbArr[0], 10 ), parseInt( rgbArr[1], 10 ), parseInt( rgbArr[2], 10 )].join( ',' ) + + [ parseInt( rgbArr[ 0 ], 10 ), parseInt( rgbArr[ 1 ], 10 ), parseInt( rgbArr[ 2 ], 10 ) ].join( ',' ) + ')'; } diff --git a/resources/src/jquery/jquery.expandableField.js b/resources/src/jquery/jquery.expandableField.js index 48341bc541..10d814ccff 100644 --- a/resources/src/jquery/jquery.expandableField.js +++ b/resources/src/jquery/jquery.expandableField.js @@ -44,7 +44,7 @@ */ configure: function ( context, property, value ) { // TODO: Validate creation using fallback values - context.config[property] = value; + context.config[ property ] = value; } }; @@ -87,20 +87,20 @@ /* API */ // Handle various calling styles if ( args.length > 0 ) { - if ( typeof args[0] === 'object' ) { + if ( typeof args[ 0 ] === 'object' ) { // Apply set of properties - for ( key in args[0] ) { - $.expandableField.configure( context, key, args[0][key] ); + for ( key in args[ 0 ] ) { + $.expandableField.configure( context, key, args[ 0 ][ key ] ); } - } else if ( typeof args[0] === 'string' ) { + } else if ( typeof args[ 0 ] === 'string' ) { if ( args.length > 1 ) { // Set property values - $.expandableField.configure( context, args[0], args[1] ); + $.expandableField.configure( context, args[ 0 ], args[ 1 ] ); // TODO: Do we need to check both null and undefined? } else if ( returnValue === null || returnValue === undefined ) { // Get property values, but don't give access to internal data - returns only the first - returnValue = ( args[0] in context.config ? undefined : context.config[args[0]] ); + returnValue = ( args[ 0 ] in context.config ? undefined : context.config[ args[ 0 ] ] ); } } } diff --git a/resources/src/jquery/jquery.getAttrs.js b/resources/src/jquery/jquery.getAttrs.js index 64827fb785..3064b42341 100644 --- a/resources/src/jquery/jquery.getAttrs.js +++ b/resources/src/jquery/jquery.getAttrs.js @@ -8,7 +8,7 @@ function serializeControls( controls ) { len = controls.length; for ( i = 0; i < len; i++ ) { - data[ controls[i].name ] = controls[i].value; + data[ controls[ i ].name ] = controls[ i ].value; } return data; @@ -23,7 +23,7 @@ function serializeControls( controls ) { * @return {Object} */ jQuery.fn.getAttrs = function () { - return serializeControls( this[0].attributes ); + return serializeControls( this[ 0 ].attributes ); }; /** diff --git a/resources/src/jquery/jquery.hidpi.js b/resources/src/jquery/jquery.hidpi.js index 8fca05677e..2b9bf7a313 100644 --- a/resources/src/jquery/jquery.hidpi.js +++ b/resources/src/jquery/jquery.hidpi.js @@ -106,11 +106,11 @@ $.matchSrcSet = function ( devicePixelRatio, srcset ) { selectedSrc = null; candidates = srcset.split( / *, */ ); for ( i = 0; i < candidates.length; i++ ) { - candidate = candidates[i]; + candidate = candidates[ i ]; bits = candidate.split( / +/ ); - src = bits[0]; - if ( bits.length > 1 && bits[1].charAt( bits[1].length - 1 ) === 'x' ) { - ratioStr = bits[1].slice( 0, -1 ); + src = bits[ 0 ]; + if ( bits.length > 1 && bits[ 1 ].charAt( bits[ 1 ].length - 1 ) === 'x' ) { + ratioStr = bits[ 1 ].slice( 0, -1 ); ratio = parseFloat( ratioStr ); if ( ratio <= devicePixelRatio && ratio > selectedRatio ) { selectedRatio = ratio; diff --git a/resources/src/jquery/jquery.highlightText.js b/resources/src/jquery/jquery.highlightText.js index 1ec4db0505..e37f19b04a 100644 --- a/resources/src/jquery/jquery.highlightText.js +++ b/resources/src/jquery/jquery.highlightText.js @@ -12,10 +12,10 @@ var i, patArray = pat.split( ' ' ); for ( i = 0; i < patArray.length; i++ ) { - if ( patArray[i].length === 0 ) { + if ( patArray[ i ].length === 0 ) { continue; } - $.highlightText.innerHighlight( node, patArray[i] ); + $.highlightText.innerHighlight( node, patArray[ i ] ); } return node; }, @@ -30,7 +30,7 @@ // look for an occurrence of our pattern and store the starting position match = node.data.match( new RegExp( '(^|\\s)' + mw.RegExp.escape( pat ), 'i' ) ); if ( match ) { - pos = match.index + match[1].length; // include length of any matched spaces + pos = match.index + match[ 1 ].length; // include length of any matched spaces // create the span wrapper for the matched text spannode = document.createElement( 'span' ); spannode.className = 'highlight'; @@ -55,7 +55,7 @@ ) { for ( i = 0; i < node.childNodes.length; ++i ) { // call the highlight function for each child node - $.highlightText.innerHighlight( node.childNodes[i], pat ); + $.highlightText.innerHighlight( node.childNodes[ i ], pat ); } } } diff --git a/resources/src/jquery/jquery.localize.js b/resources/src/jquery/jquery.localize.js index 0b423545a1..2122146cd2 100644 --- a/resources/src/jquery/jquery.localize.js +++ b/resources/src/jquery/jquery.localize.js @@ -12,9 +12,9 @@ * @return {string} Localized message */ function msg( options, key ) { - var args = options.params[key] || []; + var args = options.params[ key ] || []; // Format: mw.msg( key [, p1, p2, ...] ) - args.unshift( options.prefix + ( options.keys[key] || key ) ); + args.unshift( options.prefix + ( options.keys[ key ] || key ) ); return mw.msg.apply( mw, args ); } @@ -108,7 +108,7 @@ function msg( options, key ) { */ $.fn.localize = function ( options ) { var $target = this, - attributes = ['title', 'alt', 'placeholder']; + attributes = [ 'title', 'alt', 'placeholder' ]; // Extend options options = $.extend( { diff --git a/resources/src/jquery/jquery.mwExtension.js b/resources/src/jquery/jquery.mwExtension.js index 548421286d..27ceb2bc45 100644 --- a/resources/src/jquery/jquery.mwExtension.js +++ b/resources/src/jquery/jquery.mwExtension.js @@ -44,11 +44,11 @@ return false; } for ( var i = 0; i < arrThis.length; i++ ) { - if ( $.isArray( arrThis[i] ) ) { - if ( !$.compareArray( arrThis[i], arrAgainst[i] ) ) { + if ( $.isArray( arrThis[ i ] ) ) { + if ( !$.compareArray( arrThis[ i ], arrAgainst[ i ] ) ) { return false; } - } else if ( arrThis[i] !== arrAgainst[i] ) { + } else if ( arrThis[ i ] !== arrAgainst[ i ] ) { return false; } } @@ -71,24 +71,24 @@ // Check if this property is also present in the other object if ( prop in objectB ) { // Compare the types of the properties - type = typeof objectA[prop]; - if ( type === typeof objectB[prop] ) { + type = typeof objectA[ prop ]; + if ( type === typeof objectB[ prop ] ) { // Recursively check objects inside this one switch ( type ) { case 'object' : - if ( !$.compareObject( objectA[prop], objectB[prop] ) ) { + if ( !$.compareObject( objectA[ prop ], objectB[ prop ] ) ) { return false; } break; case 'function' : // Functions need to be strings to compare them properly - if ( objectA[prop].toString() !== objectB[prop].toString() ) { + if ( objectA[ prop ].toString() !== objectB[ prop ].toString() ) { return false; } break; default: // Strings, numbers - if ( objectA[prop] !== objectB[prop] ) { + if ( objectA[ prop ] !== objectB[ prop ] ) { return false; } break; diff --git a/resources/src/jquery/jquery.placeholder.js b/resources/src/jquery/jquery.placeholder.js index bdd2cefad4..e385089610 100644 --- a/resources/src/jquery/jquery.placeholder.js +++ b/resources/src/jquery/jquery.placeholder.js @@ -37,7 +37,7 @@ rinlinejQuery = /^jQuery\d+$/; $.each( elem.attributes, function ( i, attr ) { if ( attr.specified && !rinlinejQuery.test( attr.name ) ) { - newAttrs[attr.name] = attr.value; + newAttrs[ attr.name ] = attr.value; } } ); return newAttrs; @@ -51,7 +51,7 @@ $input = $input.hide().next().show().attr( 'id', $input.removeAttr( 'id' ).data( 'placeholder-id' ) ); // If `clearPlaceholder` was called from `$.valHooks.input.set` if ( event === true ) { - $input[0].value = value; + $input[ 0 ].value = value; return value; } $input.focus(); @@ -96,7 +96,7 @@ // Note: `$input[0] != input` now! } $input.addClass( 'placeholder' ); - $input[0].value = $input.attr( 'placeholder' ); + $input[ 0 ].value = $input.attr( 'placeholder' ); } else { $input.removeClass( 'placeholder' ); } @@ -109,7 +109,7 @@ if ( $input.attr( 'placeholder' ) !== text ) { $input.prop( 'placeholder', text ); if ( $input.hasClass( 'placeholder' ) ) { - $input[0].value = text; + $input[ 0 ].value = text; } } } @@ -161,7 +161,7 @@ var $element = $( element ), $passwordInput = $element.data( 'placeholder-password' ); if ( $passwordInput ) { - return $passwordInput[0].value; + return $passwordInput[ 0 ].value; } return $element.data( 'placeholder-enabled' ) && $element.hasClass( 'placeholder' ) ? '' : element.value; @@ -170,7 +170,7 @@ var $element = $( element ), $passwordInput = $element.data( 'placeholder-password' ); if ( $passwordInput ) { - $passwordInput[0].value = value; + $passwordInput[ 0 ].value = value; return value; } diff --git a/resources/src/jquery/jquery.qunit.completenessTest.js b/resources/src/jquery/jquery.qunit.completenessTest.js index 8908067c68..e34592cb14 100644 --- a/resources/src/jquery/jquery.qunit.completenessTest.js +++ b/resources/src/jquery/jquery.qunit.completenessTest.js @@ -132,7 +132,7 @@ elOutputWrapper.appendChild( elContainer ); util.each( style, function ( key, value ) { - elOutputWrapper.style[key] = value; + elOutputWrapper.style[ key ] = value; } ); return elOutputWrapper; } @@ -201,7 +201,7 @@ if ( currName ) { currPathArray.push( currName ); - currVal = currObj[currName]; + currVal = currObj[ currName ]; } else { currName = '(root)'; currVal = currObj; @@ -263,7 +263,7 @@ */ hasTest: function ( fnName ) { if ( !( fnName in this.methodCallTracker ) ) { - this.missingTests[fnName] = true; + this.missingTests[ fnName ] = true; return false; } return true; diff --git a/resources/src/jquery/jquery.suggestions.js b/resources/src/jquery/jquery.suggestions.js index 7c9bec3220..c43e0ff55f 100644 --- a/resources/src/jquery/jquery.suggestions.js +++ b/resources/src/jquery/jquery.suggestions.js @@ -246,10 +246,10 @@ $.suggestions = { case 'update': case '$region': case 'expandFrom': - context.config[property] = value; + context.config[ property ] = value; break; case 'suggestions': - context.config[property] = value; + context.config[ property ] = value; // Update suggestions if ( context.data !== undefined ) { if ( context.data.$textbox.val().length === 0 ) { @@ -277,7 +277,7 @@ $.suggestions = { expandFrom = 'left'; // Catch invalid values, default to 'auto' - } else if ( $.inArray( expandFrom, ['left', 'right', 'start', 'end', 'auto'] ) === -1 ) { + } else if ( $.inArray( expandFrom, [ 'left', 'right', 'start', 'end', 'auto' ] ) === -1 ) { expandFrom = 'auto'; } @@ -336,11 +336,11 @@ $.suggestions = { expWidth = -1; for ( i = 0; i < context.config.suggestions.length; i++ ) { /*jshint loopfunc:true */ - text = context.config.suggestions[i]; + text = context.config.suggestions[ i ]; $result = $( '
' ) .addClass( 'suggestions-result' ) .attr( 'rel', i ) - .data( 'text', context.config.suggestions[i] ) + .data( 'text', context.config.suggestions[ i ] ) .mousemove( function () { context.data.selectedWithMouse = true; $.suggestions.highlight( @@ -352,7 +352,7 @@ $.suggestions = { .appendTo( $results ); // Allow custom rendering if ( typeof context.config.result.render === 'function' ) { - context.config.result.render.call( $result, context.config.suggestions[i], context ); + context.config.result.render.call( $result, context.config.suggestions[ i ], context ); } else { $result.text( text ); } @@ -393,22 +393,22 @@ $.suggestions = { } break; case 'maxRows': - context.config[property] = Math.max( 1, Math.min( 100, value ) ); + context.config[ property ] = Math.max( 1, Math.min( 100, value ) ); break; case 'delay': - context.config[property] = Math.max( 0, Math.min( 1200, value ) ); + context.config[ property ] = Math.max( 0, Math.min( 1200, value ) ); break; case 'cacheMaxAge': - context.config[property] = Math.max( 1, value ); + context.config[ property ] = Math.max( 1, value ); break; case 'maxExpandFactor': - context.config[property] = Math.max( 1, value ); + context.config[ property ] = Math.max( 1, value ); break; case 'cache': case 'submitOnClick': case 'positionFromLeft': case 'highlightInput': - context.config[property] = !!value; + context.config[ property ] = !!value; break; } }, @@ -595,18 +595,18 @@ $.fn.suggestions = function () { // Handle various calling styles if ( args.length > 0 ) { - if ( typeof args[0] === 'object' ) { + if ( typeof args[ 0 ] === 'object' ) { // Apply set of properties - for ( key in args[0] ) { - $.suggestions.configure( context, key, args[0][key] ); + for ( key in args[ 0 ] ) { + $.suggestions.configure( context, key, args[ 0 ][ key ] ); } - } else if ( typeof args[0] === 'string' ) { + } else if ( typeof args[ 0 ] === 'string' ) { if ( args.length > 1 ) { // Set property values - $.suggestions.configure( context, args[0], args[1] ); + $.suggestions.configure( context, args[ 0 ], args[ 1 ] ); } else if ( returnValue === null || returnValue === undefined ) { // Get property values, but don't give access to internal data - returns only the first - returnValue = ( args[0] in context.config ? undefined : context.config[args[0]] ); + returnValue = ( args[ 0 ] in context.config ? undefined : context.config[ args[ 0 ] ] ); } } } diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index 00fb480ebe..40c828a42f 100644 --- a/resources/src/jquery/jquery.tablesorter.js +++ b/resources/src/jquery/jquery.tablesorter.js @@ -70,8 +70,8 @@ var i, len = parsers.length; for ( i = 0; i < len; i++ ) { - if ( parsers[i].id.toLowerCase() === name.toLowerCase() ) { - return parsers[i]; + if ( parsers[ i ].id.toLowerCase() === name.toLowerCase() ) { + return parsers[ i ]; } } return false; @@ -115,19 +115,19 @@ needed = ( rows.length > 4 ) ? 5 : rows.length; while ( i < l ) { - if ( rows[rowIndex] && rows[rowIndex].cells[cellIndex] ) { - nodeValue = $.trim( getElementSortKey( rows[rowIndex].cells[cellIndex] ) ); + if ( rows[ rowIndex ] && rows[ rowIndex ].cells[ cellIndex ] ) { + nodeValue = $.trim( getElementSortKey( rows[ rowIndex ].cells[ cellIndex ] ) ); } else { nodeValue = ''; } if ( nodeValue !== '' ) { - if ( parsers[i].is( nodeValue, table ) ) { + if ( parsers[ i ].is( nodeValue, table ) ) { concurrent++; rowIndex++; if ( concurrent >= needed ) { // Confirmed the parser for multiple cells, let's return it - return parsers[i]; + return parsers[ i ]; } } else { // Check next parser, reset rows @@ -146,17 +146,17 @@ } // 0 is always the generic parser (text) - return parsers[0]; + return parsers[ 0 ]; } function buildParserCache( table, $headers ) { var sortType, cells, len, i, parser, - rows = table.tBodies[0].rows, + rows = table.tBodies[ 0 ].rows, parsers = []; - if ( rows[0] ) { + if ( rows[ 0 ] ) { - cells = rows[0].cells; + cells = rows[ 0 ].cells; len = cells.length; for ( i = 0; i < len; i++ ) { @@ -180,8 +180,8 @@ function buildCache( table ) { var i, j, $row, cols, - totalRows = ( table.tBodies[0] && table.tBodies[0].rows.length ) || 0, - totalCells = ( table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length ) || 0, + totalRows = ( table.tBodies[ 0 ] && table.tBodies[ 0 ].rows.length ) || 0, + totalCells = ( table.tBodies[ 0 ].rows[ 0 ] && table.tBodies[ 0 ].rows[ 0 ].cells.length ) || 0, config = $( table ).data( 'tablesorter' ).config, parsers = config.parsers, cache = { @@ -192,13 +192,13 @@ for ( i = 0; i < totalRows; ++i ) { // Add the table data to main data array - $row = $( table.tBodies[0].rows[i] ); + $row = $( table.tBodies[ 0 ].rows[ i ] ); cols = []; // if this is a child row, add it to the last row's children and // continue to the next row if ( $row.hasClass( config.cssChildRow ) ) { - cache.row[cache.row.length - 1] = cache.row[cache.row.length - 1].add( $row ); + cache.row[ cache.row.length - 1 ] = cache.row[ cache.row.length - 1 ].add( $row ); // go to the next for loop continue; } @@ -206,7 +206,7 @@ cache.row.push( $row ); for ( j = 0; j < totalCells; ++j ) { - cols.push( parsers[j].format( getElementSortKey( $row[0].cells[j] ), table, $row[0].cells[j] ) ); + cols.push( parsers[ j ].format( getElementSortKey( $row[ 0 ].cells[ j ] ), table, $row[ 0 ].cells[ j ] ) ); } cols.push( cache.normalized.length ); // add position for rowCache @@ -222,20 +222,20 @@ row = cache.row, normalized = cache.normalized, totalRows = normalized.length, - checkCell = ( normalized[0].length - 1 ), + checkCell = ( normalized[ 0 ].length - 1 ), fragment = document.createDocumentFragment(); for ( i = 0; i < totalRows; i++ ) { - pos = normalized[i][checkCell]; + pos = normalized[ i ][ checkCell ]; - l = row[pos].length; + l = row[ pos ].length; for ( j = 0; j < l; j++ ) { - fragment.appendChild( row[pos][j] ); + fragment.appendChild( row[ pos ][ j ] ); } } - table.tBodies[0].appendChild( fragment ); + table.tBodies[ 0 ].appendChild( fragment ); $( table ).trigger( 'sortEnd.tablesorter' ); } @@ -269,10 +269,10 @@ $tfoot = $( '' ); len = $rows.length; for ( i = len - 1; i >= 0; i-- ) { - if ( $( $rows[i] ).children( 'td' ).length ) { + if ( $( $rows[ i ] ).children( 'td' ).length ) { break; } - $tfoot.prepend( $( $rows[i] ) ); + $tfoot.prepend( $( $rows[ i ] ) ); } $table.append( $tfoot ); } @@ -317,7 +317,7 @@ colspan = Number( cell.colSpan ); // Skip the spots in the exploded matrix that are already filled - while ( exploded[rowIndex] && exploded[rowIndex][columnIndex] !== undefined ) { + while ( exploded[ rowIndex ] && exploded[ rowIndex ][ columnIndex ] !== undefined ) { ++columnIndex; } @@ -325,10 +325,10 @@ // in the exploded matrix rowspan times colspan times, with the proper offsets for ( matrixColumnIndex = columnIndex; matrixColumnIndex < columnIndex + colspan; ++matrixColumnIndex ) { for ( matrixRowIndex = rowIndex; matrixRowIndex < rowIndex + rowspan; ++matrixRowIndex ) { - if ( !exploded[matrixRowIndex] ) { - exploded[matrixRowIndex] = []; + if ( !exploded[ matrixRowIndex ] ) { + exploded[ matrixRowIndex ] = []; } - exploded[matrixRowIndex][matrixColumnIndex] = cell; + exploded[ matrixRowIndex ][ matrixColumnIndex ] = cell; } } } ); @@ -342,7 +342,7 @@ } } ); // We cannot use $.unique() here because it sorts into dom order, which is undesirable - $tableHeaders = $( uniqueElements( exploded[longestTR] ) ).filter( 'th' ); + $tableHeaders = $( uniqueElements( exploded[ longestTR ] ) ).filter( 'th' ); } // as each header can span over multiple columns (using colspan=N), @@ -375,12 +375,12 @@ .prop( 'tabIndex', 0 ) .attr( { role: 'columnheader button', - title: msg[1] + title: msg[ 1 ] } ); } // add cell to headerList - config.headerList[headerIndex] = this; + config.headerList[ headerIndex ] = this; } ); return $tableHeaders; @@ -391,7 +391,7 @@ var i, len = a.length; for ( i = 0; i < len; i++ ) { - if ( a[i][0] === v ) { + if ( a[ i ][ 0 ] === v ) { return true; } } @@ -411,7 +411,7 @@ $.each( headerToColumns, function ( headerIndex, columns ) { $.each( columns, function ( i, columnIndex ) { - var header = $headers[headerIndex], + var header = $headers[ headerIndex ], $header = $( header ); if ( !isValueInArray( columnIndex, sortList ) ) { @@ -423,10 +423,10 @@ } else { // Column shall be sorted: Apply designated count and order. $.each( sortList, function ( j, sortColumn ) { - if ( sortColumn[0] === i ) { + if ( sortColumn[ 0 ] === i ) { $header.data( { - order: sortColumn[1], - count: sortColumn[1] + 1 + order: sortColumn[ 1 ], + count: sortColumn[ 1 ] + 1 } ); return false; } @@ -439,12 +439,12 @@ function setHeadersCss( table, $headers, list, css, msg, columnToHeader ) { // Remove all header information and reset titles to default message - $headers.removeClass( css[0] ).removeClass( css[1] ).attr( 'title', msg[1] ); + $headers.removeClass( css[ 0 ] ).removeClass( css[ 1 ] ).attr( 'title', msg[ 1 ] ); for ( var i = 0; i < list.length; i++ ) { - $headers.eq( columnToHeader[ list[i][0] ] ) - .addClass( css[ list[i][1] ] ) - .attr( 'title', msg[ list[i][1] ] ); + $headers.eq( columnToHeader[ list[ i ][ 0 ] ] ) + .addClass( css[ list[ i ][ 1 ] ] ) + .attr( 'title', msg[ list[ i ][ 1 ] ] ); } } @@ -461,19 +461,19 @@ sortFn = [], len = sortList.length; for ( i = 0; i < len; i++ ) { - sortFn[i] = ( sortList[i][1] ) ? sortTextDesc : sortText; + sortFn[ i ] = ( sortList[ i ][ 1 ] ) ? sortTextDesc : sortText; } cache.normalized.sort( function ( array1, array2 ) { var i, col, ret; for ( i = 0; i < len; i++ ) { - col = sortList[i][0]; - ret = sortFn[i].call( this, array1[col], array2[col] ); + col = sortList[ i ][ 0 ]; + ret = sortFn[ i ].call( this, array1[ col ], array2[ col ] ); if ( ret !== 0 ) { return ret; } } // Fall back to index number column to ensure stable sort - return sortText.call( this, array1[array1.length - 1], array2[array2.length - 1] ); + return sortText.call( this, array1[ array1.length - 1 ], array2[ array2.length - 1 ] ); } ); return cache; } @@ -484,19 +484,19 @@ separatorTransformTable = mw.config.get( 'wgSeparatorTransformTable' ), digitTransformTable = mw.config.get( 'wgDigitTransformTable' ); - if ( separatorTransformTable === null || ( separatorTransformTable[0] === '' && digitTransformTable[2] === '' ) ) { + if ( separatorTransformTable === null || ( separatorTransformTable[ 0 ] === '' && digitTransformTable[ 2 ] === '' ) ) { ts.transformTable = false; } else { ts.transformTable = {}; // Unpack the transform table - ascii = separatorTransformTable[0].split( '\t' ).concat( digitTransformTable[0].split( '\t' ) ); - localised = separatorTransformTable[1].split( '\t' ).concat( digitTransformTable[1].split( '\t' ) ); + ascii = separatorTransformTable[ 0 ].split( '\t' ).concat( digitTransformTable[ 0 ].split( '\t' ) ); + localised = separatorTransformTable[ 1 ].split( '\t' ).concat( digitTransformTable[ 1 ].split( '\t' ) ); // Construct regex for number identification for ( i = 0; i < ascii.length; i++ ) { - ts.transformTable[localised[i]] = ascii[i]; - digits.push( mw.RegExp.escape( localised[i] ) ); + ts.transformTable[ localised[ i ] ] = ascii[ i ]; + digits.push( mw.RegExp.escape( localised[ i ] ) ); } } digitClass = '[' + digits.join( '', digits ) + ']'; @@ -515,14 +515,14 @@ ts.monthNames = {}; for ( i = 0; i < 12; i++ ) { - name = mw.language.months.names[i].toLowerCase(); - ts.monthNames[name] = i + 1; + name = mw.language.months.names[ i ].toLowerCase(); + ts.monthNames[ name ] = i + 1; regex.push( mw.RegExp.escape( name ) ); - name = mw.language.months.genitive[i].toLowerCase(); - ts.monthNames[name] = i + 1; + name = mw.language.months.genitive[ i ].toLowerCase(); + ts.monthNames[ name ] = i + 1; regex.push( mw.RegExp.escape( name ) ); - name = mw.language.months.abbrev[i].toLowerCase().replace( '.', '' ); - ts.monthNames[name] = i + 1; + name = mw.language.months.abbrev[ i ].toLowerCase().replace( '.', '' ); + ts.monthNames[ name ] = i + 1; regex.push( mw.RegExp.escape( name ) ); } @@ -531,13 +531,13 @@ // Build RegEx // Any date formated with . , ' - or / - ts.dateRegex[0] = new RegExp( /^\s*(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{2,4})\s*?/i ); + ts.dateRegex[ 0 ] = new RegExp( /^\s*(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{2,4})\s*?/i ); // Written Month name, dmy - ts.dateRegex[1] = new RegExp( '^\\s*(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' ); + ts.dateRegex[ 1 ] = new RegExp( '^\\s*(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' ); // Written Month name, mdy - ts.dateRegex[2] = new RegExp( '^\\s*(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' ); + ts.dateRegex[ 2 ] = new RegExp( '^\\s*(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' ); } @@ -565,11 +565,11 @@ col = 0, l = this.cells.length; for ( i = 0; i < l; i++ ) { - $( this.cells[i] ).data( 'tablesorter', { + $( this.cells[ i ] ).data( 'tablesorter', { realCellIndex: col, realRowIndex: this.rowIndex } ); - col += this.cells[i].colSpan; + col += this.cells[ i ].colSpan; } } ); @@ -608,7 +608,7 @@ } while ( rowspanCells.length ) { - if ( $.data( rowspanCells[0], 'tablesorter' ).needResort ) { + if ( $.data( rowspanCells[ 0 ], 'tablesorter' ).needResort ) { resortCells(); } @@ -620,7 +620,7 @@ cell.rowSpan = 1; $nextRows = $( cell ).parent().nextAll(); for ( i = 0; i < rowSpan - 1; i++ ) { - $tds = $( $nextRows[i].cells ).filter( filterfunc ); + $tds = $( $nextRows[ i ].cells ).filter( filterfunc ); $clone = $( cell ).clone(); $clone.data( 'tablesorter', { realCellIndex: spanningRealCellIndex, @@ -698,7 +698,7 @@ $.each( sortObjects, function ( i, sortObject ) { $.each( sortObject, function ( columnIndex, order ) { var orderIndex = ( order === 'desc' ) ? 1 : 0; - sortList.push( [parseInt( columnIndex, 10 ), orderIndex] ); + sortList.push( [ parseInt( columnIndex, 10 ), orderIndex ] ); } ); } ); return sortList; @@ -832,7 +832,7 @@ // cells get event .change() and bubbles up to the here cache = buildCache( table ); - totalRows = ( $table[0].tBodies[0] && $table[0].tBodies[0].rows.length ) || 0; + totalRows = ( $table[ 0 ].tBodies[ 0 ] && $table[ 0 ].tBodies[ 0 ].rows.length ) || 0; if ( !table.sortDisabled && totalRows > 0 ) { cell = this; $cell = $( cell ); @@ -848,12 +848,12 @@ columns = config.headerToColumns[ $cell.data( 'headerIndex' ) ]; newSortList = $.map( columns, function ( c ) { // jQuery "helpfully" flattens the arrays... - return [[c, $cell.data( 'order' )]]; + return [ [ c, $cell.data( 'order' ) ] ]; } ); // Index of first column belonging to this header - i = columns[0]; + i = columns[ 0 ]; - if ( !e[config.sortMultiSortKey] ) { + if ( !e[ config.sortMultiSortKey ] ) { // User only wants to sort on one column set // Flush the sort list and add new columns config.sortList = newSortList; @@ -865,11 +865,11 @@ // The user has clicked on an already sorted column. // Reverse the sorting direction for all tables. for ( j = 0; j < config.sortList.length; j++ ) { - s = config.sortList[j]; - o = config.headerList[s[0]]; - if ( isValueInArray( s[0], newSortList ) ) { - $( o ).data( 'count', s[1] + 1 ); - s[1] = $( o ).data( 'count' ) % 2; + s = config.sortList[ j ]; + o = config.headerList[ s[ 0 ] ]; + if ( isValueInArray( s[ 0 ], newSortList ) ) { + $( o ).data( 'count', s[ 1 ] + 1 ); + s[ 1 ] = $( o ).data( 'count' ) % 2; } } } else { @@ -882,9 +882,9 @@ setHeadersOrder( $headers, config.sortList, config.headerToColumns ); // Set CSS for headers - setHeadersCss( $table[0], $headers, config.sortList, sortCSS, sortMsg, config.columnToHeader ); + setHeadersCss( $table[ 0 ], $headers, config.sortList, sortCSS, sortMsg, config.columnToHeader ); appendToTable( - $table[0], multisort( $table[0], config.sortList, cache ) + $table[ 0 ], multisort( $table[ 0 ], config.sortList, cache ) ); // Stop normal event by returning false @@ -950,7 +950,7 @@ len = parsers.length, a = true; for ( i = 0; i < len; i++ ) { - if ( parsers[i].id.toLowerCase() === parser.id.toLowerCase() ) { + if ( parsers[ i ].id.toLowerCase() === parser.id.toLowerCase() ) { a = false; } } @@ -966,7 +966,7 @@ for ( p = 0; p < s.length; p++ ) { c = s.charAt( p ); if ( c in ts.transformTable ) { - out += ts.transformTable[c]; + out += ts.transformTable[ c ]; } else { out += c; } @@ -988,7 +988,7 @@ }, clearTableBody: function ( table ) { - $( table.tBodies[0] ).empty(); + $( table.tBodies[ 0 ] ).empty(); }, getParser: function ( id ) { @@ -1020,7 +1020,7 @@ if ( ts.collationRegex ) { var tsc = ts.collationTable; s = s.replace( ts.collationRegex, function ( match ) { - var r = tsc[match] ? tsc[match] : tsc[match.toUpperCase()]; + var r = tsc[ match ] ? tsc[ match ] : tsc[ match.toUpperCase() ]; return r.toLowerCase(); } ); } @@ -1032,7 +1032,7 @@ ts.addParser( { id: 'IPAddress', is: function ( s ) { - return ts.rgx.IPAddress[0].test( s ); + return ts.rgx.IPAddress[ 0 ].test( s ); }, format: function ( s ) { var i, item, @@ -1040,7 +1040,7 @@ r = '', len = a.length; for ( i = 0; i < len; i++ ) { - item = a[i]; + item = a[ i ]; if ( item.length === 1 ) { r += '00' + item; } else if ( item.length === 2 ) { @@ -1057,10 +1057,10 @@ ts.addParser( { id: 'currency', is: function ( s ) { - return ts.rgx.currency[0].test( s ); + return ts.rgx.currency[ 0 ].test( s ); }, format: function ( s ) { - return $.tablesorter.formatDigit( s.replace( ts.rgx.currency[1], '' ) ); + return $.tablesorter.formatDigit( s.replace( ts.rgx.currency[ 1 ], '' ) ); }, type: 'numeric' } ); @@ -1068,10 +1068,10 @@ ts.addParser( { id: 'url', is: function ( s ) { - return ts.rgx.url[0].test( s ); + return ts.rgx.url[ 0 ].test( s ); }, format: function ( s ) { - return $.trim( s.replace( ts.rgx.url[1], '' ) ); + return $.trim( s.replace( ts.rgx.url[ 1 ], '' ) ); }, type: 'text' } ); @@ -1079,7 +1079,7 @@ ts.addParser( { id: 'isoDate', is: function ( s ) { - return ts.rgx.isoDate[0].test( s ); + return ts.rgx.isoDate[ 0 ].test( s ); }, format: function ( s ) { return $.tablesorter.formatFloat( ( s !== '' ) ? new Date( s.replace( @@ -1091,7 +1091,7 @@ ts.addParser( { id: 'usLongDate', is: function ( s ) { - return ts.rgx.usLongDate[0].test( s ); + return ts.rgx.usLongDate[ 0 ].test( s ); }, format: function ( s ) { return $.tablesorter.formatFloat( new Date( s ).getTime() ); @@ -1102,49 +1102,49 @@ ts.addParser( { id: 'date', is: function ( s ) { - return ( ts.dateRegex[0].test( s ) || ts.dateRegex[1].test( s ) || ts.dateRegex[2].test( s ) ); + return ( ts.dateRegex[ 0 ].test( s ) || ts.dateRegex[ 1 ].test( s ) || ts.dateRegex[ 2 ].test( s ) ); }, format: function ( s ) { var match, y; s = $.trim( s.toLowerCase() ); - if ( ( match = s.match( ts.dateRegex[0] ) ) !== null ) { + if ( ( match = s.match( ts.dateRegex[ 0 ] ) ) !== null ) { if ( mw.config.get( 'wgDefaultDateFormat' ) === 'mdy' || mw.config.get( 'wgPageContentLanguage' ) === 'en' ) { - s = [ match[3], match[1], match[2] ]; + s = [ match[ 3 ], match[ 1 ], match[ 2 ] ]; } else if ( mw.config.get( 'wgDefaultDateFormat' ) === 'dmy' ) { - s = [ match[3], match[2], match[1] ]; + s = [ match[ 3 ], match[ 2 ], match[ 1 ] ]; } else { // If we get here, we don't know which order the dd-dd-dddd // date is in. So return something not entirely invalid. return '99999999'; } - } else if ( ( match = s.match( ts.dateRegex[1] ) ) !== null ) { - s = [ match[3], String( ts.monthNames[match[2]] ), match[1] ]; - } else if ( ( match = s.match( ts.dateRegex[2] ) ) !== null ) { - s = [ match[3], String( ts.monthNames[match[1]] ), match[2] ]; + } else if ( ( match = s.match( ts.dateRegex[ 1 ] ) ) !== null ) { + s = [ match[ 3 ], String( ts.monthNames[ match[ 2 ] ] ), match[ 1 ] ]; + } else if ( ( match = s.match( ts.dateRegex[ 2 ] ) ) !== null ) { + s = [ match[ 3 ], String( ts.monthNames[ match[ 1 ] ] ), match[ 2 ] ]; } else { // Should never get here return '99999999'; } // Pad Month and Day - if ( s[1].length === 1 ) { - s[1] = '0' + s[1]; + if ( s[ 1 ].length === 1 ) { + s[ 1 ] = '0' + s[ 1 ]; } - if ( s[2].length === 1 ) { - s[2] = '0' + s[2]; + if ( s[ 2 ].length === 1 ) { + s[ 2 ] = '0' + s[ 2 ]; } - if ( ( y = parseInt( s[0], 10 ) ) < 100 ) { + if ( ( y = parseInt( s[ 0 ], 10 ) ) < 100 ) { // Guestimate years without centuries if ( y < 30 ) { - s[0] = 2000 + y; + s[ 0 ] = 2000 + y; } else { - s[0] = 1900 + y; + s[ 0 ] = 1900 + y; } } - while ( s[0].length < 4 ) { - s[0] = '0' + s[0]; + while ( s[ 0 ].length < 4 ) { + s[ 0 ] = '0' + s[ 0 ]; } return parseInt( s.join( '' ), 10 ); }, @@ -1154,7 +1154,7 @@ ts.addParser( { id: 'time', is: function ( s ) { - return ts.rgx.time[0].test( s ); + return ts.rgx.time[ 0 ].test( s ); }, format: function ( s ) { return $.tablesorter.formatFloat( new Date( '2000/01/01 ' + s ).getTime() ); diff --git a/resources/src/jquery/jquery.textSelection.js b/resources/src/jquery/jquery.textSelection.js index 5111930517..367c78e914 100644 --- a/resources/src/jquery/jquery.textSelection.js +++ b/resources/src/jquery/jquery.textSelection.js @@ -138,7 +138,7 @@ insertText = '', selTextArr = selText.split( '\n' ); for ( i = 0; i < selTextArr.length; i++ ) { - insertText += pre + selTextArr[i] + post; + insertText += pre + selTextArr[ i ] + post; if ( i !== selTextArr.length - 1 ) { insertText += '\n'; } @@ -576,7 +576,7 @@ context.fn.restoreSelection(); needSave = true; } - retval = ( alternateFn && alternateFn[command] || fn[command] ).call( this, options ); + retval = ( alternateFn && alternateFn[ command ] || fn[ command ] ).call( this, options ); if ( hasWikiEditor && needSave ) { context.fn.saveSelection(); } diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js b/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js index e181472dfc..011f9c55ef 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js @@ -53,9 +53,9 @@ for ( i = 0; i < collapsibleLists.length; i++ ) { // Pass to a function for iteration-local variables handleOne( - $editForm.find( collapsibleLists[i].listSel ), - $editForm.find( collapsibleLists[i].togglerSel ), - collapsibleLists[i].cookieName + $editForm.find( collapsibleLists[ i ].listSel ), + $editForm.find( collapsibleLists[ i ].togglerSel ), + collapsibleLists[ i ].cookieName ); } } ); diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js index 5f1058f14b..ce627f56fa 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js @@ -36,7 +36,7 @@ $wikiPreview.show(); // Jump to where the preview will appear - $wikiPreview[0].scrollIntoView(); + $wikiPreview[ 0 ].scrollIntoView(); copySelectors = [ // Main @@ -98,7 +98,7 @@ indexpageids: '', prop: 'revisions', titles: mw.config.get( 'wgPageName' ), - rvdifftotext: response.parse.text['*'], + rvdifftotext: response.parse.text[ '*' ], rvprop: '' }; if ( section !== '' ) { @@ -106,8 +106,8 @@ } return api.post( postData ).done( function ( result2 ) { try { - var diffHtml = result2.query.pages[result2.query.pageids[0]] - .revisions[0].diff['*']; + var diffHtml = result2.query.pages[ result2.query.pageids[ 0 ] ] + .revisions[ 0 ].diff[ '*' ]; $wikiDiff.find( 'table.diff tbody' ).html( diffHtml ); } catch ( e ) { // "result.blah is undefined" error, ignore @@ -151,7 +151,7 @@ ); } if ( response.parse.categorieshtml ) { - $( '#catlinks' ).replaceWith( response.parse.categorieshtml['*'] ); + $( '#catlinks' ).replaceWith( response.parse.categorieshtml[ '*' ] ); } if ( response.parse.templates ) { newList = []; @@ -159,10 +159,10 @@ li = $( '
  • ' ) .append( $( '' ) .attr( { - 'href': mw.util.getUrl( template['*'] ), + 'href': mw.util.getUrl( template[ '*' ] ), 'class': ( template.exists !== undefined ? '' : 'new' ) } ) - .text( template['*'] ) + .text( template[ '*' ] ) ); newList.push( li ); } ); @@ -170,7 +170,7 @@ $editform.find( '.templatesUsed .mw-editfooter-list' ).detach().empty().append( newList ).appendTo( '.templatesUsed' ); } if ( response.parse.limitreporthtml ) { - $( '.limitreport' ).html( response.parse.limitreporthtml['*'] ); + $( '.limitreport' ).html( response.parse.limitreporthtml[ '*' ] ); } if ( response.parse.langlinks && mw.config.get( 'skin' ) === 'vector' ) { newList = []; @@ -180,7 +180,7 @@ .append( $( '' ) .attr( { 'href': langlink.url, - 'title': langlink['*'] + ' - ' + langlink.langname, + 'title': langlink[ '*' ] + ' - ' + langlink.langname, 'lang': langlink.lang, 'hreflang': langlink.lang } ) @@ -193,11 +193,11 @@ $list.detach().empty().append( newList ).prependTo( $parent ); } - if ( response.parse.text['*'] ) { + if ( response.parse.text[ '*' ] ) { $content = $wikiPreview.children( '.mw-content-ltr,.mw-content-rtl' ); $content .detach() - .html( response.parse.text['*'] ); + .html( response.parse.text[ '*' ] ); mw.hook( 'wikipage.content' ).fire( $content ); @@ -213,14 +213,14 @@ var isSubject = ( section === 'new' ), summaryMsg = isSubject ? 'subject-preview' : 'summary-preview', $summaryPreview = $editform.find( '.mw-summary-preview' ).empty(); - if ( response.parse.parsedsummary && response.parse.parsedsummary['*'] !== '' ) { + if ( response.parse.parsedsummary && response.parse.parsedsummary[ '*' ] !== '' ) { $summaryPreview.append( mw.message( summaryMsg ).parse(), ' ', $( '' ).addClass( 'comment' ).html( // There is no equivalent to rawParams mw.message( 'parentheses' ).escaped() - .replace( '$1', response.parse.parsedsummary['*'] ) + .replace( '$1', response.parse.parsedsummary[ '*' ] ) ) ); } diff --git a/resources/src/mediawiki.api/mediawiki.api.js b/resources/src/mediawiki.api/mediawiki.api.js index cae65c56b1..43b20b8b2e 100644 --- a/resources/src/mediawiki.api/mediawiki.api.js +++ b/resources/src/mediawiki.api/mediawiki.api.js @@ -122,12 +122,12 @@ // Handle common MediaWiki API idioms for passing parameters for ( key in parameters ) { // Multiple values are pipe-separated - if ( $.isArray( parameters[key] ) ) { - parameters[key] = parameters[key].join( '|' ); + if ( $.isArray( parameters[ key ] ) ) { + parameters[ key ] = parameters[ key ].join( '|' ); } // Boolean values are only false when not given at all - if ( parameters[key] === false || parameters[key] === undefined ) { - delete parameters[key]; + if ( parameters[ key ] === false || parameters[ key ] === undefined ) { + delete parameters[ key ]; } } }, @@ -166,7 +166,7 @@ formData = new FormData(); for ( key in parameters ) { - formData.append( key, parameters[key] ); + formData.append( key, parameters[ key ] ); } // If we extracted a token parameter, add it back in. if ( token ) { @@ -295,8 +295,8 @@ d = apiPromise .then( function ( data ) { - if ( data.tokens && data.tokens[type + 'token'] ) { - return data.tokens[type + 'token']; + if ( data.tokens && data.tokens[ type + 'token' ] ) { + return data.tokens[ type + 'token' ]; } // If token type is not available for this user, diff --git a/resources/src/mediawiki.api/mediawiki.api.options.js b/resources/src/mediawiki.api/mediawiki.api.options.js index b839fbdc54..399e6f4356 100644 --- a/resources/src/mediawiki.api/mediawiki.api.options.js +++ b/resources/src/mediawiki.api/mediawiki.api.options.js @@ -14,7 +14,7 @@ */ saveOption: function ( name, value ) { var param = {}; - param[name] = value; + param[ name ] = value; return this.saveOptions( param ); }, @@ -38,7 +38,7 @@ deferreds = []; for ( name in options ) { - value = options[name] === null ? null : String( options[name] ); + value = options[ name ] === null ? null : String( options[ name ] ); // Can we bundle this option, or does it need a separate request? bundleable = diff --git a/resources/src/mediawiki.api/mediawiki.api.parse.js b/resources/src/mediawiki.api/mediawiki.api.parse.js index 2dcf8078fe..bc3d44f946 100644 --- a/resources/src/mediawiki.api/mediawiki.api.parse.js +++ b/resources/src/mediawiki.api/mediawiki.api.parse.js @@ -21,7 +21,7 @@ return apiPromise .then( function ( data ) { - return data.parse.text['*']; + return data.parse.text[ '*' ]; } ) .promise( { abort: apiPromise.abort } ); } diff --git a/resources/src/mediawiki.api/mediawiki.api.upload.js b/resources/src/mediawiki.api/mediawiki.api.upload.js index 76df7c8957..cc0bef0d34 100644 --- a/resources/src/mediawiki.api/mediawiki.api.upload.js +++ b/resources/src/mediawiki.api/mediawiki.api.upload.js @@ -58,7 +58,7 @@ */ function processIframeResult( iframe ) { var json, - doc = iframe.contentDocument || frames[iframe.id].document; + doc = iframe.contentDocument || frames[ iframe.id ].document; if ( doc.XMLDocument ) { // The response is a document property in IE @@ -108,7 +108,7 @@ isFileInput = file && file.nodeType === Node.ELEMENT_NODE; if ( formDataAvailable() && isFileInput && file.files ) { - file = file.files[0]; + file = file.files[ 0 ]; } if ( !file ) { @@ -159,8 +159,8 @@ $iframe = $( iframe ); for ( key in data ) { - if ( !fieldsAllowed[key] ) { - delete data[key]; + if ( !fieldsAllowed[ key ] ) { + delete data[ key ]; } } @@ -245,8 +245,8 @@ deferred = $.Deferred(); for ( key in data ) { - if ( !fieldsAllowed[key] ) { - delete data[key]; + if ( !fieldsAllowed[ key ] ) { + delete data[ key ]; } } diff --git a/resources/src/mediawiki.api/mediawiki.api.watch.js b/resources/src/mediawiki.api/mediawiki.api.watch.js index 40ba136d3f..a2ff1292bb 100644 --- a/resources/src/mediawiki.api/mediawiki.api.watch.js +++ b/resources/src/mediawiki.api/mediawiki.api.watch.js @@ -37,7 +37,7 @@ return apiPromise .then( function ( data ) { // If a single page was given (not an array) respond with a single item as well. - return $.isArray( pages ) ? data.watch : data.watch[0]; + return $.isArray( pages ) ? data.watch : data.watch[ 0 ]; } ) .promise( { abort: apiPromise.abort } ); } diff --git a/resources/src/mediawiki.language/languages/bs.js b/resources/src/mediawiki.language/languages/bs.js index b56e4b29fd..cb9e19edb7 100644 --- a/resources/src/mediawiki.language/languages/bs.js +++ b/resources/src/mediawiki.language/languages/bs.js @@ -4,8 +4,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { var grammarForms = mediaWiki.language.getData( 'bs', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'instrumental': // instrumental diff --git a/resources/src/mediawiki.language/languages/dsb.js b/resources/src/mediawiki.language/languages/dsb.js index 69c36cc02f..dc4447abb1 100644 --- a/resources/src/mediawiki.language/languages/dsb.js +++ b/resources/src/mediawiki.language/languages/dsb.js @@ -4,8 +4,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { var grammarForms = mediaWiki.language.getData( 'dsb', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'instrumental': // instrumental diff --git a/resources/src/mediawiki.language/languages/fi.js b/resources/src/mediawiki.language/languages/fi.js index d9c2b06d28..2bbfc6b877 100644 --- a/resources/src/mediawiki.language/languages/fi.js +++ b/resources/src/mediawiki.language/languages/fi.js @@ -7,8 +7,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { var grammarForms, aou, origWord; grammarForms = mediaWiki.language.getData( 'fi', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } // vowel harmony flag diff --git a/resources/src/mediawiki.language/languages/ga.js b/resources/src/mediawiki.language/languages/ga.js index fb4e939655..a4c911a339 100644 --- a/resources/src/mediawiki.language/languages/ga.js +++ b/resources/src/mediawiki.language/languages/ga.js @@ -5,8 +5,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { /*jshint onecase:true */ var grammarForms = mediaWiki.language.getData( 'ga', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'ainmlae': diff --git a/resources/src/mediawiki.language/languages/he.js b/resources/src/mediawiki.language/languages/he.js index d1eba43b4c..945f02fed2 100644 --- a/resources/src/mediawiki.language/languages/he.js +++ b/resources/src/mediawiki.language/languages/he.js @@ -4,8 +4,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { var grammarForms = mediaWiki.language.getData( 'he', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'prefixed': diff --git a/resources/src/mediawiki.language/languages/hsb.js b/resources/src/mediawiki.language/languages/hsb.js index 2c0abd3df9..8e9b1296d0 100644 --- a/resources/src/mediawiki.language/languages/hsb.js +++ b/resources/src/mediawiki.language/languages/hsb.js @@ -4,8 +4,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { var grammarForms = mediaWiki.language.getData( 'hsb', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'instrumental': // instrumental diff --git a/resources/src/mediawiki.language/languages/hu.js b/resources/src/mediawiki.language/languages/hu.js index d72a1c05b4..4f8f74df72 100644 --- a/resources/src/mediawiki.language/languages/hu.js +++ b/resources/src/mediawiki.language/languages/hu.js @@ -5,8 +5,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { var grammarForms = mediaWiki.language.getData( 'hu', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'rol': diff --git a/resources/src/mediawiki.language/languages/hy.js b/resources/src/mediawiki.language/languages/hy.js index c4a1cf7307..935d466d14 100644 --- a/resources/src/mediawiki.language/languages/hy.js +++ b/resources/src/mediawiki.language/languages/hy.js @@ -5,8 +5,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { /*jshint onecase:true */ var grammarForms = mediaWiki.language.getData( 'hy', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } // These rules are not perfect, but they are currently only used for site names so it doesn't diff --git a/resources/src/mediawiki.language/languages/la.js b/resources/src/mediawiki.language/languages/la.js index 8dc589e5bc..29e04a6749 100644 --- a/resources/src/mediawiki.language/languages/la.js +++ b/resources/src/mediawiki.language/languages/la.js @@ -5,8 +5,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { var grammarForms = mediaWiki.language.getData( 'la', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'genitive': diff --git a/resources/src/mediawiki.language/languages/os.js b/resources/src/mediawiki.language/languages/os.js index 554e99d4c5..3e0f279def 100644 --- a/resources/src/mediawiki.language/languages/os.js +++ b/resources/src/mediawiki.language/languages/os.js @@ -14,8 +14,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { // Variable for ending ending = ''; - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } // Checking if the $word is in plural form if ( word.match( /тæ$/i ) ) { diff --git a/resources/src/mediawiki.language/languages/ru.js b/resources/src/mediawiki.language/languages/ru.js index 2077b6beb2..ee1d6ef2f2 100644 --- a/resources/src/mediawiki.language/languages/ru.js +++ b/resources/src/mediawiki.language/languages/ru.js @@ -10,8 +10,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { 'use strict'; var grammarForms = mediaWiki.language.getData( 'ru', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'genitive': // родительный падеж diff --git a/resources/src/mediawiki.language/languages/sl.js b/resources/src/mediawiki.language/languages/sl.js index d20d0b3418..3d8bdfde4b 100644 --- a/resources/src/mediawiki.language/languages/sl.js +++ b/resources/src/mediawiki.language/languages/sl.js @@ -4,8 +4,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { var grammarForms = mediaWiki.language.getData( 'sl', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'mestnik': // locative diff --git a/resources/src/mediawiki.language/languages/uk.js b/resources/src/mediawiki.language/languages/uk.js index a0215333c3..a22874b35f 100644 --- a/resources/src/mediawiki.language/languages/uk.js +++ b/resources/src/mediawiki.language/languages/uk.js @@ -4,8 +4,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) { var grammarForms = mediaWiki.language.getData( 'uk', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ]; } switch ( form ) { case 'genitive': // родовий відмінок diff --git a/resources/src/mediawiki.language/mediawiki.cldr.js b/resources/src/mediawiki.language/mediawiki.cldr.js index f6fb8f1079..ca4b6fbe49 100644 --- a/resources/src/mediawiki.language/mediawiki.cldr.js +++ b/resources/src/mediawiki.language/mediawiki.cldr.js @@ -21,7 +21,7 @@ getPluralForm: function ( number, pluralRules ) { var i; for ( i = 0; i < pluralRules.length; i++ ) { - if ( mw.libs.pluralRuleParser( pluralRules[i], number ) ) { + if ( mw.libs.pluralRuleParser( pluralRules[ i ], number ) ) { break; } } diff --git a/resources/src/mediawiki.language/mediawiki.language.init.js b/resources/src/mediawiki.language/mediawiki.language.init.js index b3765c85e7..808f6e5e02 100644 --- a/resources/src/mediawiki.language/mediawiki.language.init.js +++ b/resources/src/mediawiki.language/mediawiki.language.init.js @@ -55,8 +55,8 @@ getData: function ( langCode, dataKey ) { var langData = mw.language.data; langCode = langCode.toLowerCase(); - if ( langData && langData[langCode] instanceof mw.Map ) { - return langData[langCode].get( dataKey ); + if ( langData && langData[ langCode ] instanceof mw.Map ) { + return langData[ langCode ].get( dataKey ); } return undefined; }, @@ -73,10 +73,10 @@ setData: function ( langCode, dataKey, value ) { var langData = mw.language.data; langCode = langCode.toLowerCase(); - if ( !( langData[langCode] instanceof mw.Map ) ) { - langData[langCode] = new mw.Map(); + if ( !( langData[ langCode ] instanceof mw.Map ) ) { + langData[ langCode ] = new mw.Map(); } - langData[langCode].set( dataKey, value ); + langData[ langCode ].set( dataKey, value ); } }; diff --git a/resources/src/mediawiki.language/mediawiki.language.js b/resources/src/mediawiki.language/mediawiki.language.js index 78e391910e..81baebe433 100644 --- a/resources/src/mediawiki.language/mediawiki.language.js +++ b/resources/src/mediawiki.language/mediawiki.language.js @@ -29,8 +29,8 @@ $.extend( mw.language, { return mw.language.convertPlural( parseInt( count, 10 ), template.parameters ); } // Could not process plural return first form or nothing - if ( template.parameters[0] ) { - return template.parameters[0]; + if ( template.parameters[ 0 ] ) { + return template.parameters[ 0 ]; } return ''; }, @@ -47,8 +47,8 @@ $.extend( mw.language, { var pluralRules, pluralFormIndex = 0; - if ( explicitPluralForms && explicitPluralForms[count] ) { - return explicitPluralForms[count]; + if ( explicitPluralForms && explicitPluralForms[ count ] ) { + return explicitPluralForms[ count ]; } if ( !forms || forms.length === 0 ) { @@ -58,11 +58,11 @@ $.extend( mw.language, { pluralRules = mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'pluralRules' ); if ( !pluralRules ) { // default fallback. - return ( count === 1 ) ? forms[0] : forms[1]; + return ( count === 1 ) ? forms[ 0 ] : forms[ 1 ]; } pluralFormIndex = mw.cldr.getPluralForm( count, pluralRules ); pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 ); - return forms[pluralFormIndex]; + return forms[ pluralFormIndex ]; }, /** @@ -98,12 +98,12 @@ $.extend( mw.language, { } forms = mw.language.preConvertPlural( forms, 2 ); if ( gender === 'male' ) { - return forms[0]; + return forms[ 0 ]; } if ( gender === 'female' ) { - return forms[1]; + return forms[ 1 ]; } - return ( forms.length === 3 ) ? forms[2] : forms[0]; + return ( forms.length === 3 ) ? forms[ 2 ] : forms[ 0 ]; }, /** @@ -119,8 +119,8 @@ $.extend( mw.language, { */ convertGrammar: function ( word, form ) { var grammarForms = mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] || word; + if ( grammarForms && grammarForms[ form ] ) { + return grammarForms[ form ][ word ] || word; } return word; }, @@ -138,7 +138,7 @@ $.extend( mw.language, { i = 0; for ( ; i < list.length; i++ ) { - text += list[i]; + text += list[ i ]; if ( list.length - 2 === i ) { text += mw.msg( 'and' ) + mw.msg( 'word-separator' ); } else if ( list.length - 1 !== i ) { diff --git a/resources/src/mediawiki.language/mediawiki.language.numbers.js b/resources/src/mediawiki.language/mediawiki.language.numbers.js index 36c281c357..32df68c6ae 100644 --- a/resources/src/mediawiki.language/mediawiki.language.numbers.js +++ b/resources/src/mediawiki.language/mediawiki.language.numbers.js @@ -85,62 +85,62 @@ off, remainder, patternParts = pattern.split( '.' ), - maxPlaces = ( patternParts[1] || [] ).length, + maxPlaces = ( patternParts[ 1 ] || [] ).length, valueParts = String( Math.abs( value ) ).split( '.' ), - fractional = valueParts[1] || '', + fractional = valueParts[ 1 ] || '', groupSize = 0, groupSize2 = 0, pieces = []; - if ( patternParts[1] ) { + if ( patternParts[ 1 ] ) { // Pad fractional with trailing zeros - padLength = ( patternParts[1] && patternParts[1].lastIndexOf( '0' ) + 1 ); + padLength = ( patternParts[ 1 ] && patternParts[ 1 ].lastIndexOf( '0' ) + 1 ); if ( padLength > fractional.length ) { - valueParts[1] = pad( fractional, padLength, '0', true ); + valueParts[ 1 ] = pad( fractional, padLength, '0', true ); } // Truncate fractional if ( maxPlaces < fractional.length ) { - valueParts[1] = fractional.slice( 0, maxPlaces ); + valueParts[ 1 ] = fractional.slice( 0, maxPlaces ); } } else { - if ( valueParts[1] ) { + if ( valueParts[ 1 ] ) { valueParts.pop(); } } // Pad whole with leading zeros - patternDigits = patternParts[0].replace( ',', '' ); + patternDigits = patternParts[ 0 ].replace( ',', '' ); padLength = patternDigits.indexOf( '0' ); if ( padLength !== -1 ) { padLength = patternDigits.length - padLength; - if ( padLength > valueParts[0].length ) { - valueParts[0] = pad( valueParts[0], padLength ); + if ( padLength > valueParts[ 0 ].length ) { + valueParts[ 0 ] = pad( valueParts[ 0 ], padLength ); } // Truncate whole if ( patternDigits.indexOf( '#' ) === -1 ) { - valueParts[0] = valueParts[0].slice( valueParts[0].length - padLength ); + valueParts[ 0 ] = valueParts[ 0 ].slice( valueParts[ 0 ].length - padLength ); } } // Add group separators - index = patternParts[0].lastIndexOf( ',' ); + index = patternParts[ 0 ].lastIndexOf( ',' ); if ( index !== -1 ) { - groupSize = patternParts[0].length - index - 1; - remainder = patternParts[0].slice( 0, index ); + groupSize = patternParts[ 0 ].length - index - 1; + remainder = patternParts[ 0 ].slice( 0, index ); index = remainder.lastIndexOf( ',' ); if ( index !== -1 ) { groupSize2 = remainder.length - index - 1; } } - for ( whole = valueParts[0]; whole; ) { + for ( whole = valueParts[ 0 ]; whole; ) { off = groupSize ? whole.length - groupSize : 0; pieces.push( ( off > 0 ) ? whole.slice( off ) : whole ); whole = ( off > 0 ) ? whole.slice( 0, off ) : ''; @@ -150,7 +150,7 @@ groupSize2 = null; } } - valueParts[0] = pieces.reverse().join( options.group ); + valueParts[ 0 ] = pieces.reverse().join( options.group ); return valueParts.join( options.decimal ); } @@ -198,10 +198,10 @@ convertedNumber = ''; for ( i = 0; i < numberString.length; i++ ) { - if ( transformTable[ numberString[i] ] ) { - convertedNumber += transformTable[numberString[i]]; + if ( transformTable[ numberString[ i ] ] ) { + convertedNumber += transformTable[ numberString[ i ] ]; } else { - convertedNumber += numberString[i]; + convertedNumber += numberString[ i ]; } } return integer ? parseInt( convertedNumber, 10 ) : convertedNumber; @@ -238,20 +238,20 @@ commafy: function ( value, pattern ) { var numberPattern, transformTable = mw.language.getSeparatorTransformTable(), - group = transformTable[','] || ',', + group = transformTable[ ',' ] || ',', numberPatternRE = /[#0,]*[#0](?:\.0*#*)?/, // not precise, but good enough - decimal = transformTable['.'] || '.', + decimal = transformTable[ '.' ] || '.', patternList = pattern.split( ';' ), - positivePattern = patternList[0]; + positivePattern = patternList[ 0 ]; - pattern = patternList[ ( value < 0 ) ? 1 : 0] || ( '-' + positivePattern ); + pattern = patternList[ ( value < 0 ) ? 1 : 0 ] || ( '-' + positivePattern ); numberPattern = positivePattern.match( numberPatternRE ); if ( !numberPattern ) { throw new Error( 'unable to find a number expression in pattern: ' + pattern ); } - return pattern.replace( numberPatternRE, commafyNumber( value, numberPattern[0], { + return pattern.replace( numberPatternRE, commafyNumber( value, numberPattern[ 0 ], { decimal: decimal, group: group } ) ); diff --git a/resources/src/mediawiki.legacy/protect.js b/resources/src/mediawiki.legacy/protect.js index 3f4b263efd..d76b707876 100644 --- a/resources/src/mediawiki.legacy/protect.js +++ b/resources/src/mediawiki.legacy/protect.js @@ -146,7 +146,7 @@ var ProtectionForm = window.ProtectionForm = { */ matchAttribute: function ( objects, attrName ) { return $.map( objects, function ( object ) { - return object[attrName]; + return object[ attrName ]; } ).filter( function ( item, index, a ) { return index === a.indexOf( item ); } ).length === 1; diff --git a/resources/src/mediawiki.legacy/wikibits.js b/resources/src/mediawiki.legacy/wikibits.js index 2dcc772f99..7d1f6d73fd 100644 --- a/resources/src/mediawiki.legacy/wikibits.js +++ b/resources/src/mediawiki.legacy/wikibits.js @@ -85,7 +85,7 @@ // Execute the queued functions for ( i = 0; i < functs.length; i++ ) { - functs[i](); + functs[ i ](); } } ); @@ -168,14 +168,14 @@ * @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25. */ function importScriptURI( url ) { - if ( loadedScripts[url] ) { + if ( loadedScripts[ url ] ) { return null; } - loadedScripts[url] = true; + loadedScripts[ url ] = true; var s = document.createElement( 'script' ); s.setAttribute( 'src', url ); s.setAttribute( 'type', 'text/javascript' ); - document.getElementsByTagName( 'head' )[0].appendChild( s ); + document.getElementsByTagName( 'head' )[ 0 ].appendChild( s ); return s; } @@ -196,7 +196,7 @@ if ( media ) { l.media = media; } - document.getElementsByTagName( 'head' )[0].appendChild( l ); + document.getElementsByTagName( 'head' )[ 0 ].appendChild( l ); return l; } diff --git a/resources/src/mediawiki.messagePoster/mediawiki.messagePoster.factory.js b/resources/src/mediawiki.messagePoster/mediawiki.messagePoster.factory.js index ec14f8ba7a..6f9aa02593 100644 --- a/resources/src/mediawiki.messagePoster/mediawiki.messagePoster.factory.js +++ b/resources/src/mediawiki.messagePoster/mediawiki.messagePoster.factory.js @@ -24,11 +24,11 @@ * @param {Function} messagePosterConstructor Constructor for MessagePoster */ MwMessagePosterFactory.prototype.register = function ( contentModel, messagePosterConstructor ) { - if ( this.contentModelToClass[contentModel] !== undefined ) { + if ( this.contentModelToClass[ contentModel ] !== undefined ) { throw new Error( 'The content model \'' + contentModel + '\' is already registered.' ); } - this.contentModelToClass[contentModel] = messagePosterConstructor; + this.contentModelToClass[ contentModel ] = messagePosterConstructor; }; /** @@ -38,7 +38,7 @@ * @param {string} contentModel Content model to unregister */ MwMessagePosterFactory.prototype.unregister = function ( contentModel ) { - delete this.contentModelToClass[contentModel]; + delete this.contentModelToClass[ contentModel ]; }; /** @@ -68,8 +68,8 @@ titles: title.getPrefixedDb() } ).then( function ( result ) { if ( result.query.pageids && result.query.pageids.length > 0 ) { - pageId = result.query.pageids[0]; - page = result.query.pages[pageId]; + pageId = result.query.pageids[ 0 ]; + page = result.query.pages[ pageId ]; contentModel = page.contentmodel; moduleName = 'mediawiki.messagePoster.' + contentModel; @@ -100,7 +100,7 @@ * */ MwMessagePosterFactory.prototype.createForContentModel = function ( contentModel, title ) { - return new this.contentModelToClass[contentModel]( title ); + return new this.contentModelToClass[ contentModel ]( title ); }; mw.messagePoster = { diff --git a/resources/src/mediawiki.page/mediawiki.page.gallery.js b/resources/src/mediawiki.page/mediawiki.page.gallery.js index 95140704fd..bf34dec580 100644 --- a/resources/src/mediawiki.page/mediawiki.page.gallery.js +++ b/resources/src/mediawiki.page/mediawiki.page.gallery.js @@ -30,14 +30,14 @@ $this = $( this ); if ( top !== lastTop ) { - rows[rows.length] = []; + rows[ rows.length ] = []; lastTop = top; } $img = $this.find( 'div.thumb a.image img' ); - if ( $img.length && $img[0].height ) { - imgHeight = $img[0].height; - imgWidth = $img[0].width; + if ( $img.length && $img[ 0 ].height ) { + imgHeight = $img[ 0 ].height; + imgWidth = $img[ 0 ].width; } else { // If we don't have a real image, get the containing divs width/height. // Note that if we do have a real image, using this method will generally @@ -54,7 +54,7 @@ } captionWidth = $this.children().children( 'div.gallerytextwrapper' ).width(); - rows[rows.length - 1][rows[rows.length - 1].length] = { + rows[ rows.length - 1 ][ rows[ rows.length - 1 ].length ] = { $elm: $this, width: $this.outerWidth(), imgWidth: imgWidth, @@ -96,25 +96,25 @@ maxWidth = $gallery.width(); combinedAspect = 0; combinedPadding = 0; - curRow = rows[i]; + curRow = rows[ i ]; curRowHeight = 0; for ( j = 0; j < curRow.length; j++ ) { if ( curRowHeight === 0 ) { - if ( isFinite( curRow[j].height ) ) { + if ( isFinite( curRow[ j ].height ) ) { // Get the height of this row, by taking the first // non-out of bounds height - curRowHeight = curRow[j].height; + curRowHeight = curRow[ j ].height; } } - if ( curRow[j].aspect === 0 || !isFinite( curRow[j].aspect ) ) { + if ( curRow[ j ].aspect === 0 || !isFinite( curRow[ j ].aspect ) ) { // One of the dimensions are 0. Probably should // not try to resize. - combinedPadding += curRow[j].width; + combinedPadding += curRow[ j ].width; } else { - combinedAspect += curRow[j].aspect; - combinedPadding += curRow[j].width - curRow[j].imgWidth; + combinedAspect += curRow[ j ].aspect; + combinedPadding += curRow[ j ].width - curRow[ j ].imgWidth; } } @@ -162,13 +162,13 @@ } for ( j = 0; j < curRow.length; j++ ) { - newWidth = preferredHeight * curRow[j].aspect; - padding = curRow[j].width - curRow[j].imgWidth; - $outerDiv = curRow[j].$elm; + newWidth = preferredHeight * curRow[ j ].aspect; + padding = curRow[ j ].width - curRow[ j ].imgWidth; + $outerDiv = curRow[ j ].$elm; $innerDiv = $outerDiv.children( 'div' ).first(); $imageDiv = $innerDiv.children( 'div.thumb' ); $imageElm = $imageDiv.find( 'img' ).first(); - imageElm = $imageElm.length ? $imageElm[0] : null; + imageElm = $imageElm.length ? $imageElm[ 0 ] : null; $caption = $outerDiv.find( 'div.gallerytextwrapper' ); // Since we are going to re-adjust the height, the vertical @@ -187,7 +187,7 @@ $outerDiv.width( newWidth + padding ); $innerDiv.width( newWidth + padding ); $imageDiv.width( newWidth ); - $caption.width( curRow[j].captionWidth + ( newWidth - curRow[j].imgWidth ) ); + $caption.width( curRow[ j ].captionWidth + ( newWidth - curRow[ j ].imgWidth ) ); } if ( imageElm ) { @@ -220,7 +220,7 @@ $( this ).find( 'div.gallerytextwrapper' ).width( captionWidth ); $imageElm = $( this ).find( 'img' ).first(); - imageElm = $imageElm.length ? $imageElm[0] : null; + imageElm = $imageElm.length ? $imageElm[ 0 ] : null; if ( imageElm ) { imageElm.width = imgWidth; imageElm.height = imgHeight; diff --git a/resources/src/mediawiki.page/mediawiki.page.image.pagination.js b/resources/src/mediawiki.page/mediawiki.page.image.pagination.js index 7daf386f9f..49a51dfc23 100644 --- a/resources/src/mediawiki.page/mediawiki.page.image.pagination.js +++ b/resources/src/mediawiki.page/mediawiki.page.image.pagination.js @@ -19,11 +19,11 @@ jqXhr = undefined; // Try the cache - if ( cache[url] ) { + if ( cache[ url ] ) { // Update access freshness cacheOrder.splice( $.inArray( url, cacheOrder ), 1 ); cacheOrder.push( url ); - return $.Deferred().resolve( cache[url] ).promise(); + return $.Deferred().resolve( cache[ url ] ).promise(); } // @todo Don't fetch the entire page. Ideally we'd only fetch the content portion or the data @@ -37,12 +37,12 @@ jqXhr = undefined; // Cache the newly loaded page - cache[url] = $contents; + cache[ url ] = $contents; cacheOrder.push( url ); // Remove the oldest entry if we're over the limit if ( cacheOrder.length > 10 ) { - delete cache[ cacheOrder[0] ]; + delete cache[ cacheOrder[ 0 ] ]; cacheOrder = cacheOrder.slice( 1 ); } } ); diff --git a/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js b/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js index 9724c562a3..a3197da367 100644 --- a/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js +++ b/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js @@ -84,12 +84,12 @@ actionPaths = mw.config.get( 'wgActionPaths' ); for ( key in actionPaths ) { if ( actionPaths.hasOwnProperty( key ) ) { - parts = actionPaths[key].split( '$1' ); + parts = actionPaths[ key ].split( '$1' ); for ( i = 0; i < parts.length; i++ ) { - parts[i] = mw.RegExp.escape( parts[i] ); + parts[ i ] = mw.RegExp.escape( parts[ i ] ); } m = new RegExp( parts.join( '(.+)' ) ).exec( url ); - if ( m && m[1] ) { + if ( m && m[ 1 ] ) { return key; } @@ -138,7 +138,7 @@ api = new mw.Api(); - api[action]( title ) + api[ action ]( title ) .done( function ( watchResponse ) { var otherAction = action === 'watch' ? 'unwatch' : 'watch'; diff --git a/resources/src/mediawiki.special/mediawiki.special.preferences.js b/resources/src/mediawiki.special/mediawiki.special.preferences.js index 570a7d3153..57489faa6b 100644 --- a/resources/src/mediawiki.special/mediawiki.special.preferences.js +++ b/resources/src/mediawiki.special/mediawiki.special.preferences.js @@ -210,15 +210,15 @@ jQuery( function ( $ ) { var minutes, arr = hour.split( ':' ); - arr[0] = parseInt( arr[0], 10 ); + arr[ 0 ] = parseInt( arr[ 0 ], 10 ); if ( arr.length === 1 ) { // Specification is of the form [-]XX - minutes = arr[0] * 60; + minutes = arr[ 0 ] * 60; } else { // Specification is of the form [-]XX:XX - minutes = Math.abs( arr[0] ) * 60 + parseInt( arr[1], 10 ); - if ( arr[0] < 0 ) { + minutes = Math.abs( arr[ 0 ] ) * 60 + parseInt( arr[ 1 ], 10 ); + if ( arr[ 0 ] < 0 ) { minutes *= -1; } } @@ -245,7 +245,7 @@ jQuery( function ( $ ) { minuteDiff = hoursToMinutes( $tzTextbox.val() ); } else { // Grab data from the $tzSelect value - minuteDiff = parseInt( type.split( '|' )[1], 10 ) || 0; + minuteDiff = parseInt( type.split( '|' )[ 1 ], 10 ) || 0; $tzTextbox.val( minutesToHours( minuteDiff ) ); } diff --git a/resources/src/mediawiki.special/mediawiki.special.search.js b/resources/src/mediawiki.special/mediawiki.special.search.js index b27fe349b1..730119e862 100644 --- a/resources/src/mediawiki.special/mediawiki.special.search.js +++ b/resources/src/mediawiki.special/mediawiki.special.search.js @@ -39,12 +39,12 @@ var parts = $( this ).attr( 'href' ).split( 'search=' ), lastpart = '', prefix = 'search='; - if ( parts.length > 1 && parts[1].indexOf( '&' ) !== -1 ) { - lastpart = parts[1].slice( parts[1].indexOf( '&' ) ); + if ( parts.length > 1 && parts[ 1 ].indexOf( '&' ) !== -1 ) { + lastpart = parts[ 1 ].slice( parts[ 1 ].indexOf( '&' ) ); } else { prefix = '&search='; } - this.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart; + this.href = parts[ 0 ] + prefix + encodeURIComponent( searchterm ) + lastpart; } ); } ).trigger( 'change' ); diff --git a/resources/src/mediawiki.special/mediawiki.special.upload.js b/resources/src/mediawiki.special/mediawiki.special.upload.js index 2bacabe000..33548d79a9 100644 --- a/resources/src/mediawiki.special/mediawiki.special.upload.js +++ b/resources/src/mediawiki.special/mediawiki.special.upload.js @@ -36,7 +36,7 @@ } // Check response cache if ( this.responseCache.hasOwnProperty( this.nameToCheck ) ) { - this.setWarning( this.responseCache[this.nameToCheck] ); + this.setWarning( this.responseCache[ this.nameToCheck ] ); return; } @@ -72,7 +72,7 @@ } ).done( function ( result ) { var resultOut = ''; if ( result.query ) { - resultOut = result.query.pages[result.query.pageids[0]].imageinfo[0]; + resultOut = result.query.pages[ result.query.pageids[ 0 ] ].imageinfo[ 0 ]; } $spinnerDestCheck.remove(); uploadWarning.processResult( resultOut, uploadWarning.nameToCheck ); @@ -81,7 +81,7 @@ processResult: function ( result, fileName ) { this.setWarning( result.html ); - this.responseCache[fileName] = result.html; + this.responseCache[ fileName ] = result.html; }, setWarning: function ( warning ) { @@ -108,7 +108,7 @@ return; } if ( this.responseCache.hasOwnProperty( license ) ) { - this.showPreview( this.responseCache[license] ); + this.showPreview( this.responseCache[ license ] ); return; } @@ -127,8 +127,8 @@ }, processResult: function ( result, license ) { - this.responseCache[license] = result.parse.text['*']; - this.showPreview( this.responseCache[license] ); + this.responseCache[ license ] = result.parse.text[ '*' ]; + this.showPreview( this.responseCache[ license ] ); }, showPreview: function ( preview ) { @@ -229,7 +229,7 @@ fname = fname.replace( / /g, '_' ); // Capitalise first letter if needed if ( mw.config.get( 'wgCapitalizeUploads' ) ) { - fname = fname[0].toUpperCase() + fname.slice( 1 ); + fname = fname[ 0 ].toUpperCase() + fname.slice( 1 ); } // Output result @@ -269,7 +269,7 @@ * @return boolean */ function fileIsPreviewable( file ) { - var known = ['image/png', 'image/gif', 'image/jpeg', 'image/svg+xml'], + var known = [ 'image/png', 'image/gif', 'image/jpeg', 'image/svg+xml' ], tooHuge = 10 * 1024 * 1024; return ( $.inArray( file.type, known ) !== -1 ) && file.size > 0 && file.size < tooHuge; } @@ -283,12 +283,12 @@ * @return {string} */ function prettySize( s ) { - var sizeMsgs = ['size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes']; + var sizeMsgs = [ 'size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes' ]; while ( s >= 1024 && sizeMsgs.length > 1 ) { s /= 1024; sizeMsgs = sizeMsgs.slice( 1 ); } - return mw.msg( sizeMsgs[0], Math.round( s ) ); + return mw.msg( sizeMsgs[ 0 ], Math.round( s ) ); } /** @@ -319,7 +319,7 @@ .find( '.thumbinner' ).prepend( $spinner ).end(); $canvas = $( '' ).attr( { width: previewSize, height: previewSize } ); - ctx = $canvas[0].getContext( '2d' ); + ctx = $canvas[ 0 ].getContext( '2d' ); $( '#mw-htmlform-source' ).parent().prepend( thumb ); fetchPreview( file, function ( dataURL ) { @@ -443,7 +443,7 @@ buffer = new Uint8Array( reader.result ), string = ''; for ( i = 0; i < buffer.byteLength; i++ ) { - string += String.fromCharCode( buffer[i] ); + string += String.fromCharCode( buffer[ i ] ); } callbackBinary( string ); @@ -488,10 +488,10 @@ function getMaxUploadSize( type ) { var sizes = mw.config.get( 'wgMaxUploadSize' ); - if ( sizes[type] !== undefined ) { - return sizes[type]; + if ( sizes[ type ] !== undefined ) { + return sizes[ type ]; } - return sizes['*']; + return sizes[ '*' ]; } $( '.mw-upload-source-error' ).remove(); @@ -516,7 +516,7 @@ clearPreview(); if ( this.files && this.files.length ) { // Note: would need to be updated to handle multiple files. - var file = this.files[0]; + var file = this.files[ 0 ]; if ( !checkMaxUploadSize( file ) ) { return; diff --git a/resources/src/mediawiki.special/mediawiki.special.userlogin.signup.js b/resources/src/mediawiki.special/mediawiki.special.userlogin.signup.js index a32a790261..a0c6ee2a63 100644 --- a/resources/src/mediawiki.special/mediawiki.special.userlogin.signup.js +++ b/resources/src/mediawiki.special/mediawiki.special.userlogin.signup.js @@ -65,7 +65,7 @@ ususers: username // '|' in usernames is handled below } ) .done( function ( resp ) { - var userinfo = resp.query.users[0]; + var userinfo = resp.query.users[ 0 ]; if ( resp.query.users.length !== 1 ) { // Happens if the user types '|' into the field diff --git a/resources/src/mediawiki.toolbar/toolbar.js b/resources/src/mediawiki.toolbar/toolbar.js index 70d54ce39b..0469cc5058 100644 --- a/resources/src/mediawiki.toolbar/toolbar.js +++ b/resources/src/mediawiki.toolbar/toolbar.js @@ -174,7 +174,7 @@ $toolbar = $( '#toolbar' ); for ( i = 0; i < queue.length; i++ ) { - button = queue[i]; + button = queue[ i ]; if ( $.isArray( button ) ) { // Forwarded arguments array from mw.toolbar.addButton insertButton.apply( toolbar, button ); diff --git a/resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js index f1a08a3d80..b914f36b5c 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js @@ -173,7 +173,7 @@ } this.$oldBody = this.$body.addClass( 'mw-widget-calendarWidget-old-body' ); // Clone without children - this.$body = $( this.$body[0].cloneNode( false ) ) + this.$body = $( this.$body[ 0 ].cloneNode( false ) ) .removeClass( 'mw-widget-calendarWidget-old-body' ) .toggleClass( 'mw-widget-calendarWidget-body-month', this.displayLayer === 'month' ) .toggleClass( 'mw-widget-calendarWidget-body-year', this.displayLayer === 'year' ) diff --git a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js index 8d952e5a76..6b7f860aac 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js @@ -231,7 +231,7 @@ setTimeout( function () { var $focussed = $( ':focus' ); // Deactivate unless the focus moved to something else inside this widget - if ( !OO.ui.contains( widget.$element[ 0 ], $focussed[0], true ) ) { + if ( !OO.ui.contains( widget.$element[ 0 ], $focussed[ 0 ], true ) ) { widget.deactivate(); } }, 0 ); diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js index cf4d7886ed..167b318ad2 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js @@ -125,9 +125,9 @@ widget.interwikiPrefixes.indexOf( interwiki ) !== -1 ) { return $.Deferred().resolve( { query: { - pages: [{ + pages: [ { title: widget.value - }] + } ] } } ).promise( promiseAbortObject ); } else { params = { @@ -190,15 +190,15 @@ if ( data.redirects ) { for ( i = 0, len = data.redirects.length; i < len; i++ ) { - redirect = data.redirects[i]; - redirectsTo[redirect.to] = redirectsTo[redirect.to] || []; - redirectsTo[redirect.to].push( redirect.from ); + redirect = data.redirects[ i ]; + redirectsTo[ redirect.to ] = redirectsTo[ redirect.to ] || []; + redirectsTo[ redirect.to ].push( redirect.from ); } } for ( index in data.pages ) { - suggestionPage = data.pages[index]; - pageData[suggestionPage.title] = { + suggestionPage = data.pages[ index ]; + pageData[ suggestionPage.title ] = { missing: suggestionPage.missing !== undefined, redirect: suggestionPage.redirect !== undefined, disambiguation: OO.getProp( suggestionPage, 'pageprops', 'disambiguation' ) !== undefined, @@ -212,15 +212,15 @@ titles.push( suggestionPage.title ); } - redirects = redirectsTo[suggestionPage.title] || []; + redirects = redirectsTo[ suggestionPage.title ] || []; for ( i = 0, len = redirects.length; i < len; i++ ) { - pageData[redirects[i]] = { + pageData[ redirects[ i ] ] = { missing: false, redirect: true, disambiguation: false, description: mw.msg( 'mw-widgets-titleinput-description-redirect', suggestionPage.title ) }; - titles.push( redirects[i] ); + titles.push( redirects[ i ] ); } } @@ -233,7 +233,7 @@ ); if ( !pageExists ) { - pageData[this.value] = { + pageData[ this.value ] = { missing: true, redirect: false, disambiguation: false, description: mw.msg( 'mw-widgets-titleinput-description-new-page' ) }; @@ -252,8 +252,8 @@ titles.push( this.value ); } for ( i = 0, len = titles.length; i < len; i++ ) { - page = pageData[titles[i]] || {}; - items.push( new mw.widgets.TitleOptionWidget( this.getOptionWidgetData( titles[i], page ) ) ); + page = pageData[ titles[ i ] ] || {}; + items.push( new mw.widgets.TitleOptionWidget( this.getOptionWidgetData( titles[ i ], page ) ) ); } return items; diff --git a/resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js index d540877a0b..0d0fb735fa 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js @@ -80,7 +80,7 @@ list: 'allusers', // Prefix of list=allusers is case sensitive. Normalise first // character to uppercase so that "fo" may yield "Foo". - auprefix: inputValue[0].toUpperCase() + inputValue.slice( 1 ), + auprefix: inputValue[ 0 ].toUpperCase() + inputValue.slice( 1 ), aulimit: this.limit } ); }; @@ -106,7 +106,7 @@ items = []; for ( i = 0, len = data.length; i < len; i++ ) { - user = data[i] || {}; + user = data[ i ] || {}; items.push( new OO.ui.MenuOptionWidget( { label: user.name, data: user.name diff --git a/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js b/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js index be639367f8..0c06a83b18 100644 --- a/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js +++ b/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js @@ -34,7 +34,7 @@ var i, category; for ( i = 0; i < categories.length; i++ ) { - category = categories[i]; + category = categories[ i ]; this.categories.push( category ); } }; @@ -116,7 +116,7 @@ var i, desc, templateCalls = []; for ( i = 0; i < this.descriptions.length; i++ ) { - desc = this.descriptions[i]; + desc = this.descriptions[ i ]; templateCalls.push( '{{' + desc.language + '|' + desc.text + '}}' ); } @@ -133,7 +133,7 @@ var i, cat, categoryLinks = []; for ( i = 0; i < this.categories.length; i++ ) { - cat = this.categories[i]; + cat = this.categories[ i ]; categoryLinks.push( '[[Category:' + cat + ']]' ); } diff --git a/resources/src/mediawiki/mediawiki.Title.js b/resources/src/mediawiki/mediawiki.Title.js index e9d07eda43..d1c5bb571a 100644 --- a/resources/src/mediawiki/mediawiki.Title.js +++ b/resources/src/mediawiki/mediawiki.Title.js @@ -109,7 +109,7 @@ return false; } ns = ns.toLowerCase(); - id = mw.config.get( 'wgNamespaceIds' )[ns]; + id = mw.config.get( 'wgNamespaceIds' )[ ns ]; if ( id === undefined ) { return false; } @@ -235,7 +235,7 @@ .replace( rUnderscoreTrim, '' ); // Process initial colon - if ( title !== '' && title[0] === ':' ) { + if ( title !== '' && title[ 0 ] === ':' ) { // Initial colon means main namespace instead of specified default namespace = NS_MAIN; title = title @@ -252,16 +252,16 @@ // Process namespace prefix (if any) m = title.match( rSplit ); if ( m ) { - id = getNsIdByName( m[1] ); + id = getNsIdByName( m[ 1 ] ); if ( id !== false ) { // Ordinary namespace namespace = id; - title = m[2]; + title = m[ 2 ]; // For Talk:X pages, make sure X has no "namespace" prefix if ( namespace === NS_TALK && ( m = title.match( rSplit ) ) ) { // Disallow titles like Talk:File:x (subject should roundtrip: talk:file:x -> file:x -> file_talk:x) - if ( getNsIdByName( m[1] ) !== false ) { + if ( getNsIdByName( m[ 1 ] ) !== false ) { return false; } } @@ -326,7 +326,7 @@ } // Any remaining initial :s are illegal. - if ( title[0] === ':' ) { + if ( title[ 0 ] === ':' ) { return false; } @@ -381,9 +381,9 @@ rules = sanitationRules; for ( i = 0, ruleLength = rules.length; i < ruleLength; ++i ) { - rule = rules[i]; + rule = rules[ i ]; for ( m = 0, filterLength = filter.length; m < filterLength; ++m ) { - if ( rule[filter[m]] ) { + if ( rule[ filter[ m ] ] ) { s = s.replace( rule.pattern, rule.replace ); } } @@ -519,7 +519,7 @@ title = $.trim( title.replace( rWhitespace, ' ' ) ); // Process initial colon - if ( title !== '' && title[0] === ':' ) { + if ( title !== '' && title[ 0 ] === ':' ) { // Initial colon means main namespace instead of specified default namespace = NS_MAIN; title = title @@ -532,11 +532,11 @@ // Process namespace prefix (if any) m = title.match( rSplit ); if ( m ) { - id = getNsIdByName( m[1] ); + id = getNsIdByName( m[ 1 ] ); if ( id !== false ) { // Ordinary namespace namespace = id; - title = m[2]; + title = m[ 2 ]; } } @@ -656,7 +656,7 @@ recount = regexes.length; - src = img.jquery ? img[0].src : img.src; + src = img.jquery ? img[ 0 ].src : img.src; matches = src.match( thumbPhpRegex ); @@ -667,11 +667,11 @@ decodedSrc = decodeURIComponent( src ); for ( i = 0; i < recount; i++ ) { - regex = regexes[i]; + regex = regexes[ i ]; matches = decodedSrc.match( regex ); - if ( matches && matches[1] ) { - return mw.Title.newFromText( 'File:' + matches[1] ); + if ( matches && matches[ 1 ] ) { + return mw.Title.newFromText( 'File:' + matches[ 1 ] ); } } @@ -691,9 +691,9 @@ obj = Title.exist.pages; if ( type === 'string' ) { - match = obj[title]; + match = obj[ title ]; } else if ( type === 'object' && title instanceof Title ) { - match = obj[title.toString()]; + match = obj[ title.toString() ]; } else { throw new Error( 'mw.Title.exists: title must be a string or an instance of Title' ); } @@ -730,14 +730,14 @@ pages: {}, set: function ( titles, state ) { - titles = $.isArray( titles ) ? titles : [titles]; + titles = $.isArray( titles ) ? titles : [ titles ]; state = state === undefined ? true : !!state; var i, pages = this.pages, len = titles.length; for ( i = 0; i < len; i++ ) { - pages[ titles[i] ] = state; + pages[ titles[ i ] ] = state; } return true; } @@ -789,7 +789,7 @@ ) { return this.title; } - return this.title[0].toUpperCase() + this.title.slice( 1 ); + return this.title[ 0 ].toUpperCase() + this.title.slice( 1 ); }, /** diff --git a/resources/src/mediawiki/mediawiki.Uri.js b/resources/src/mediawiki/mediawiki.Uri.js index 7563ae4572..29b224ee6a 100644 --- a/resources/src/mediawiki/mediawiki.Uri.js +++ b/resources/src/mediawiki/mediawiki.Uri.js @@ -195,10 +195,10 @@ // Only copy direct properties, not inherited ones if ( uri.hasOwnProperty( prop ) ) { // Deep copy object properties - if ( $.isArray( uri[prop] ) || $.isPlainObject( uri[prop] ) ) { - this[prop] = $.extend( true, {}, uri[prop] ); + if ( $.isArray( uri[ prop ] ) || $.isPlainObject( uri[ prop ] ) ) { + this[ prop ] = $.extend( true, {}, uri[ prop ] ); } else { - this[prop] = uri[prop]; + this[ prop ] = uri[ prop ]; } } } @@ -223,7 +223,7 @@ this.port = defaultUri.port; } } - if ( this.path && this.path[0] !== '/' ) { + if ( this.path && this.path[ 0 ] !== '/' ) { // A real relative URL, relative to defaultUri.path. We can't really handle that since we cannot // figure out whether the last path component of defaultUri.path is a directory or a file. throw new Error( 'Bad constructor arguments' ); diff --git a/resources/src/mediawiki/mediawiki.debug.js b/resources/src/mediawiki/mediawiki.debug.js index bdff99f7a1..f721009537 100644 --- a/resources/src/mediawiki/mediawiki.debug.js +++ b/resources/src/mediawiki/mediawiki.debug.js @@ -222,7 +222,7 @@ className: 'mw-debug-pane', id: 'mw-debug-pane-' + id } ) - .append( panes[id] ) + .append( panes[ id ] ) .appendTo( $container ); } @@ -255,7 +255,7 @@ }; for ( i = 0, length = this.data.log.length; i < length; i += 1 ) { - entry = this.data.log[i]; + entry = this.data.log[ i ]; entry.typeText = entryTypeText( entry.type ); $( '
  • ' ) @@ -289,13 +289,13 @@ .appendTo( $table ); for ( i = 0, length = this.data.queries.length; i < length; i += 1 ) { - query = this.data.queries[i]; + query = this.data.queries[ i ]; $( '' ) .append( $( '' ) .append( $( '
    ' ).text( i + 1 ) ) .append( $( '' ).text( query.sql ) ) .append( $( '' ).text( ( query.time * 1000 ).toFixed( 4 ) + 'ms' ) ) - .append( $( '' ).text( query['function'] ) ) + .append( $( '' ).text( query[ 'function' ] ) ) .appendTo( $table ); } @@ -312,7 +312,7 @@ $list = $( '
      ' ); for ( i = 0, length = this.data.debugLog.length; i < length; i += 1 ) { - line = this.data.debugLog[i]; + line = this.data.debugLog[ i ]; $( '
    • ' ) .html( mw.html.escape( line ).replace( /\n/g, '
      \n' ) ) .appendTo( $list ); @@ -346,7 +346,7 @@ $( '
    ' ).text( key ) ) - .append( $( '' ).text( data[key] ) ) + .append( $( '' ).text( data[ key ] ) ) .appendTo( $table ); } @@ -370,7 +370,7 @@ $table = $( '' ); for ( i = 0, length = this.data.includes.length; i < length; i += 1 ) { - file = this.data.includes[i]; + file = this.data.includes[ i ]; $( '' ) .append( $( '' ); - $.each( data[i], function ( j, str ) { + $.each( data[ i ], function ( j, str ) { var $td = $( '
    ' ).text( file.name ) ) .append( $( '' ).text( file.size ) ) diff --git a/resources/src/mediawiki/mediawiki.experiments.js b/resources/src/mediawiki/mediawiki.experiments.js index 930bfec5ee..75b1f80de4 100644 --- a/resources/src/mediawiki/mediawiki.experiments.js +++ b/resources/src/mediawiki/mediawiki.experiments.js @@ -91,14 +91,14 @@ } for ( key in buckets ) { - range += buckets[key]; + range += buckets[ key ]; } hash = hashString( experiment.name + ':' + token ); max = ( hash / MAX_INT32_UNSIGNED ) * range; for ( key in buckets ) { - acc += buckets[key]; + acc += buckets[ key ]; if ( max <= acc ) { return key; diff --git a/resources/src/mediawiki/mediawiki.htmlform.js b/resources/src/mediawiki/mediawiki.htmlform.js index 7fdaa6ec3d..adc0b0767e 100644 --- a/resources/src/mediawiki/mediawiki.htmlform.js +++ b/resources/src/mediawiki/mediawiki.htmlform.js @@ -53,7 +53,7 @@ function hideIfParse( $el, spec ) { var op, i, l, v, $field, $fields, fields, func, funcs, getVal; - op = spec[0]; + op = spec[ 0 ]; l = spec.length; switch ( op ) { case 'AND': @@ -63,12 +63,12 @@ funcs = []; fields = []; for ( i = 1; i < l; i++ ) { - if ( !$.isArray( spec[i] ) ) { + if ( !$.isArray( spec[ i ] ) ) { throw new Error( op + ' parameters must be arrays' ); } - v = hideIfParse( $el, spec[i] ); - fields = fields.concat( v[0].toArray() ); - funcs.push( v[1] ); + v = hideIfParse( $el, spec[ i ] ); + fields = fields.concat( v[ 0 ].toArray() ); + funcs.push( v[ 1 ] ); } $fields = $( fields ); @@ -78,7 +78,7 @@ func = function () { var i; for ( i = 0; i < l; i++ ) { - if ( !funcs[i]() ) { + if ( !funcs[ i ]() ) { return false; } } @@ -90,7 +90,7 @@ func = function () { var i; for ( i = 0; i < l; i++ ) { - if ( funcs[i]() ) { + if ( funcs[ i ]() ) { return true; } } @@ -102,7 +102,7 @@ func = function () { var i; for ( i = 0; i < l; i++ ) { - if ( !funcs[i]() ) { + if ( !funcs[ i ]() ) { return true; } } @@ -114,7 +114,7 @@ func = function () { var i; for ( i = 0; i < l; i++ ) { - if ( funcs[i]() ) { + if ( funcs[ i ]() ) { return false; } } @@ -129,12 +129,12 @@ if ( l !== 2 ) { throw new Error( 'NOT takes exactly one parameter' ); } - if ( !$.isArray( spec[1] ) ) { + if ( !$.isArray( spec[ 1 ] ) ) { throw new Error( 'NOT parameters must be arrays' ); } - v = hideIfParse( $el, spec[1] ); - $fields = v[0]; - func = v[1]; + v = hideIfParse( $el, spec[ 1 ] ); + $fields = v[ 0 ]; + func = v[ 1 ]; return [ $fields, function () { return !func(); } ]; @@ -144,13 +144,13 @@ if ( l !== 3 ) { throw new Error( op + ' takes exactly two parameters' ); } - $field = hideIfGetField( $el, spec[1] ); + $field = hideIfGetField( $el, spec[ 1 ] ); if ( !$field ) { return [ $(), function () { return false; } ]; } - v = spec[2]; + v = spec[ 2 ]; if ( $field.first().prop( 'type' ) === 'radio' || $field.first().prop( 'type' ) === 'checkbox' @@ -304,8 +304,8 @@ } v = hideIfParse( $el, spec ); - $fields = v[0]; - test = v[1]; + $fields = v[ 0 ]; + test = v[ 1 ]; func = function () { if ( test() ) { $el.hide(); diff --git a/resources/src/mediawiki/mediawiki.inspect.js b/resources/src/mediawiki/mediawiki.inspect.js index 31cd6c46d3..9a18c721a8 100644 --- a/resources/src/mediawiki/mediawiki.inspect.js +++ b/resources/src/mediawiki/mediawiki.inspect.js @@ -13,7 +13,7 @@ function sortByProperty( array, prop, descending ) { var order = descending ? -1 : 1; return array.sort( function ( a, b ) { - return a[prop] > b[prop] ? order : a[prop] < b[prop] ? -order : 0; + return a[ prop ] > b[ prop ] ? order : a[ prop ] < b[ prop ] ? -order : 0; } ); } @@ -25,7 +25,7 @@ for ( ; bytes >= 1024; bytes /= 1024 ) { i++; } // Maintain one decimal for kB and above, but don't // add ".0" for bytes. - return bytes.toFixed( i > 0 ? 1 : 0 ) + units[i]; + return bytes.toFixed( i > 0 ? 1 : 0 ) + units[ i ]; } /** @@ -45,18 +45,18 @@ graph = {}; $.each( modules, function ( moduleIndex, moduleName ) { - var dependencies = mw.loader.moduleRegistry[moduleName].dependencies || []; + var dependencies = mw.loader.moduleRegistry[ moduleName ].dependencies || []; if ( !hasOwn.call( graph, moduleName ) ) { - graph[moduleName] = { requiredBy: [] }; + graph[ moduleName ] = { requiredBy: [] }; } - graph[moduleName].requires = dependencies; + graph[ moduleName ].requires = dependencies; $.each( dependencies, function ( depIndex, depName ) { if ( !hasOwn.call( graph, depName ) ) { - graph[depName] = { requiredBy: [] }; + graph[ depName ] = { requiredBy: [] }; } - graph[depName].requiredBy.push( moduleName ); + graph[ depName ].requiredBy.push( moduleName ); } ); } ); return graph; @@ -173,7 +173,7 @@ $.map( inspect.reports, function ( v, k ) { return k; } ); $.each( reports, function ( index, name ) { - inspect.dumpTable( inspect.reports[name]() ); + inspect.dumpTable( inspect.reports[ name ]() ); } ); }, @@ -214,7 +214,7 @@ var modules = []; $.each( inspect.getLoadedModules(), function ( index, name ) { - var css, stats, module = mw.loader.moduleRegistry[name]; + var css, stats, module = mw.loader.moduleRegistry[ name ]; try { css = module.style.css.join(); @@ -247,7 +247,7 @@ stats.totalSize = humanSize( $.byteLength( raw ) ); } catch ( e ) {} } - return [stats]; + return [ stats ]; } }, @@ -265,7 +265,7 @@ } return $.grep( inspect.getLoadedModules(), function ( moduleName ) { - var module = mw.loader.moduleRegistry[moduleName]; + var module = mw.loader.moduleRegistry[ moduleName ]; // Grep module's JavaScript if ( $.isFunction( module.script ) && pattern.test( module.script.toString() ) ) { diff --git a/resources/src/mediawiki/mediawiki.jqueryMsg.js b/resources/src/mediawiki/mediawiki.jqueryMsg.js index 343d516e75..bd9ad026d8 100644 --- a/resources/src/mediawiki/mediawiki.jqueryMsg.js +++ b/resources/src/mediawiki/mediawiki.jqueryMsg.js @@ -71,12 +71,12 @@ var i, len; if ( !$.isArray( children ) ) { - children = [children]; + children = [ children ]; } for ( i = 0, len = children.length; i < len; i++ ) { - if ( typeof children[i] !== 'object' ) { - children[i] = document.createTextNode( children[i] ); + if ( typeof children[ i ] !== 'object' ) { + children[ i ] = document.createTextNode( children[ i ] ); } } @@ -116,8 +116,8 @@ return function ( args ) { var fallback, - key = args[0], - argsArray = $.isArray( args[1] ) ? args[1] : slice.call( args, 1 ); + key = args[ 0 ], + argsArray = $.isArray( args[ 1 ] ) ? args[ 1 ] : slice.call( args, 1 ); try { return parser.parse( key, argsArray ); } catch ( e ) { @@ -282,7 +282,7 @@ */ getAst: function ( key ) { var wikiText, - cacheKey = [key, this.settings.onlyCurlyBraceTransform].join( ':' ); + cacheKey = [ key, this.settings.onlyCurlyBraceTransform ].join( ':' ); if ( this.astCache[ cacheKey ] === undefined ) { wikiText = this.settings.messages.get( key ); @@ -335,7 +335,7 @@ return function () { var i, result; for ( i = 0; i < ps.length; i++ ) { - result = ps[i](); + result = ps[ i ](); if ( result !== null ) { return result; } @@ -356,7 +356,7 @@ originalPos = pos, result = []; for ( i = 0; i < ps.length; i++ ) { - res = ps[i](); + res = ps[ i ](); if ( res === null ) { pos = originalPos; return null; @@ -443,8 +443,8 @@ if ( matches === null ) { return null; } - pos += matches[0].length; - return matches[0]; + pos += matches[ 0 ].length; + return matches[ 0 ]; }; } @@ -484,7 +484,7 @@ backslash, anyCharacter ] ); - return result === null ? null : result[1]; + return result === null ? null : result[ 1 ]; } escapedOrLiteralWithoutSpace = choice( [ escapedLiteral, @@ -543,7 +543,7 @@ if ( result === null ) { return null; } - return [ 'REPLACE', parseInt( result[1], 10 ) - 1 ]; + return [ 'REPLACE', parseInt( result[ 1 ], 10 ) - 1 ]; } openExtlink = makeStringParser( '[' ); closeExtlink = makeStringParser( ']' ); @@ -559,13 +559,13 @@ closeExtlink ] ); if ( parsedResult !== null ) { - result = [ 'EXTLINK', parsedResult[1] ]; + result = [ 'EXTLINK', parsedResult[ 1 ] ]; // TODO (mattflaschen, 2013-03-22): Clean this up if possible. // It's avoiding CONCAT for single nodes, so they at least doesn't get the htmlEmitter span. - if ( parsedResult[3].length === 1 ) { - result.push( parsedResult[3][0] ); + if ( parsedResult[ 3 ].length === 1 ) { + result.push( parsedResult[ 3 ][ 0 ] ); } else { - result.push( ['CONCAT'].concat( parsedResult[3] ) ); + result.push( [ 'CONCAT' ].concat( parsedResult[ 3 ] ) ); } } return result; @@ -583,7 +583,7 @@ if ( result === null ) { return null; } - return [ 'EXTLINKPARAM', parseInt( result[2], 10 ) - 1, result[4] ]; + return [ 'EXTLINKPARAM', parseInt( result[ 2 ], 10 ) - 1, result[ 4 ] ]; } openWikilink = makeStringParser( '[[' ); closeWikilink = makeStringParser( ']]' ); @@ -595,7 +595,7 @@ templateContents, closeTemplate ] ); - return result === null ? null : result[1]; + return result === null ? null : result[ 1 ]; } wikilinkPage = choice( [ @@ -609,7 +609,7 @@ pipe, expression ] ); - return result === null ? null : [ result[0], result[2] ]; + return result === null ? null : [ result[ 0 ], result[ 2 ] ]; } wikilinkContents = choice( [ @@ -627,7 +627,7 @@ closeWikilink ] ); if ( parsedResult !== null ) { - parsedLinkContents = parsedResult[1]; + parsedLinkContents = parsedResult[ 1 ]; result = [ 'WIKILINK' ].concat( parsedLinkContents ); } return result; @@ -640,7 +640,7 @@ htmlDoubleQuoteAttributeValue, doubleQuote ] ); - return parsedResult === null ? null : parsedResult[1]; + return parsedResult === null ? null : parsedResult[ 1 ]; } function singleQuotedHtmlAttributeValue() { @@ -649,7 +649,7 @@ htmlSingleQuoteAttributeValue, singleQuote ] ); - return parsedResult === null ? null : parsedResult[1]; + return parsedResult === null ? null : parsedResult[ 1 ]; } function htmlAttribute() { @@ -662,7 +662,7 @@ singleQuotedHtmlAttributeValue ] ) ] ); - return parsedResult === null ? null : [parsedResult[1], parsedResult[3]]; + return parsedResult === null ? null : [ parsedResult[ 1 ], parsedResult[ 3 ] ]; } /** @@ -684,9 +684,9 @@ } for ( i = 0, len = attributes.length; i < len; i += 2 ) { - attributeName = attributes[i]; + attributeName = attributes[ i ]; if ( $.inArray( attributeName, settings.allowedHtmlCommonAttributes ) === -1 && - $.inArray( attributeName, settings.allowedHtmlAttributesByElement[startTagName] || [] ) === -1 ) { + $.inArray( attributeName, settings.allowedHtmlAttributesByElement[ startTagName ] || [] ) === -1 ) { return false; } } @@ -697,7 +697,7 @@ function htmlAttributes() { var parsedResult = nOrMore( 0, htmlAttribute )(); // Un-nest attributes array due to structure of jQueryMsg operations (see emit). - return concat.apply( ['HTMLATTRIBUTES'], parsedResult ); + return concat.apply( [ 'HTMLATTRIBUTES' ], parsedResult ); } // Subset of allowed HTML markup. @@ -728,7 +728,7 @@ } endOpenTagPos = pos; - startTagName = parsedOpenTagResult[1]; + startTagName = parsedOpenTagResult[ 1 ]; parsedHtmlContents = nOrMore( 0, expression )(); @@ -746,8 +746,8 @@ } endCloseTagPos = pos; - endTagName = parsedCloseTagResult[1]; - wrappedAttributes = parsedOpenTagResult[2]; + endTagName = parsedCloseTagResult[ 1 ]; + wrappedAttributes = parsedOpenTagResult[ 2 ]; attributes = wrappedAttributes.slice( 1 ); if ( isAllowedHtml( startTagName, endTagName, attributes ) ) { result = [ 'HTMLELEMENT', startTagName, wrappedAttributes ] @@ -787,9 +787,9 @@ if ( result === null ) { return null; } - expr = result[1]; + expr = result[ 1 ]; // use a CONCAT operator if there are multiple nodes, otherwise return the first node, raw. - return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[0]; + return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[ 0 ]; } function templateWithReplacement() { @@ -798,7 +798,7 @@ colon, replacement ] ); - return result === null ? null : [ result[0], result[2] ]; + return result === null ? null : [ result[ 0 ], result[ 2 ] ]; } function templateWithOutReplacement() { var result = sequence( [ @@ -806,14 +806,14 @@ colon, paramExpression ] ); - return result === null ? null : [ result[0], result[2] ]; + return result === null ? null : [ result[ 0 ], result[ 2 ] ]; } function templateWithOutFirstParameter() { var result = sequence( [ templateName, colon ] ); - return result === null ? null : [ result[0], '' ]; + return result === null ? null : [ result[ 0 ], '' ]; } colon = makeStringParser( ':' ); templateContents = choice( [ @@ -824,7 +824,7 @@ choice( [ templateWithReplacement, templateWithOutReplacement, templateWithOutFirstParameter ] ), nOrMore( 0, templateParam ) ] ); - return res === null ? null : res[0].concat( res[1] ); + return res === null ? null : res[ 0 ].concat( res[ 1 ] ); }, function () { var res = sequence( [ @@ -834,7 +834,7 @@ if ( res === null ) { return null; } - return [ res[0] ].concat( res[1] ); + return [ res[ 0 ] ].concat( res[ 1 ] ); } ] ); openTemplate = makeStringParser( '{{' ); @@ -939,8 +939,8 @@ subnodes = $.map( node.slice( 1 ), function ( n ) { return jmsg.emit( n, replacements ); } ); - operation = node[0].toLowerCase(); - if ( typeof jmsg[operation] === 'function' ) { + operation = node[ 0 ].toLowerCase(); + if ( typeof jmsg[ operation ] === 'function' ) { ret = jmsg[ operation ]( subnodes, replacements ); } else { throw new Error( 'Unknown operation "' + operation + '"' ); @@ -1002,10 +1002,10 @@ * @return {String} replacement */ replace: function ( nodes, replacements ) { - var index = parseInt( nodes[0], 10 ); + var index = parseInt( nodes[ 0 ], 10 ); if ( index < replacements.length ) { - return replacements[index]; + return replacements[ index ]; } else { // index not found, fallback to displaying variable return '$' + ( index + 1 ); @@ -1029,7 +1029,7 @@ wikilink: function ( nodes ) { var page, anchor, url; - page = nodes[0]; + page = nodes[ 0 ]; url = mw.util.getUrl( page ); if ( nodes.length === 1 ) { @@ -1037,7 +1037,7 @@ anchor = page; } else { // [[Some Page|anchor text]] or [[Namespace:Some Page|anchor]] - anchor = nodes[1]; + anchor = nodes[ 1 ]; } return $( '' ).attr( { @@ -1056,7 +1056,7 @@ htmlattributes: function ( nodes ) { var i, len, mapping = {}; for ( i = 0, len = nodes.length; i < len; i += 2 ) { - mapping[nodes[i]] = decodePrimaryHtmlEntities( nodes[i + 1] ); + mapping[ nodes[ i ] ] = decodePrimaryHtmlEntities( nodes[ i + 1 ] ); } return mapping; }, @@ -1091,8 +1091,8 @@ */ extlink: function ( nodes ) { var $el, - arg = nodes[0], - contents = nodes[1]; + arg = nodes[ 0 ], + contents = nodes[ 1 ]; if ( arg instanceof jQuery ) { $el = arg; } else { @@ -1124,13 +1124,13 @@ */ extlinkparam: function ( nodes, replacements ) { var replacement, - index = parseInt( nodes[0], 10 ); + index = parseInt( nodes[ 0 ], 10 ); if ( index < replacements.length ) { - replacement = replacements[index]; + replacement = replacements[ index ]; } else { replacement = '$' + ( index + 1 ); } - return this.extlink( [ replacement, nodes[1] ] ); + return this.extlink( [ replacement, nodes[ 1 ] ] ); }, /** @@ -1144,10 +1144,10 @@ var forms, firstChild, firstChildText, explicitPluralFormNumber, formIndex, form, count, explicitPluralForms = {}; - count = parseFloat( this.language.convertNumber( nodes[0], true ) ); + count = parseFloat( this.language.convertNumber( nodes[ 0 ], true ) ); forms = nodes.slice( 1 ); for ( formIndex = 0; formIndex < forms.length; formIndex++ ) { - form = forms[formIndex]; + form = forms[ formIndex ]; if ( form.jquery && form.hasClass( 'mediaWiki_htmlEmitter' ) ) { // This is a nested node, may be an explicit plural form like 5=[$2 linktext] @@ -1155,19 +1155,19 @@ if ( firstChild && firstChild.nodeType === Node.TEXT_NODE ) { firstChildText = firstChild.textContent; if ( /^\d+=/.test( firstChildText ) ) { - explicitPluralFormNumber = parseInt( firstChildText.split( /=/ )[0], 10 ); + explicitPluralFormNumber = parseInt( firstChildText.split( /=/ )[ 0 ], 10 ); // Use the digit part as key and rest of first text node and // rest of child nodes as value. firstChild.textContent = firstChildText.slice( firstChildText.indexOf( '=' ) + 1 ); - explicitPluralForms[explicitPluralFormNumber] = form; - forms[formIndex] = undefined; + explicitPluralForms[ explicitPluralFormNumber ] = form; + forms[ formIndex ] = undefined; } } } else if ( /^\d+=/.test( form ) ) { // Simple explicit plural forms like 12=a dozen - explicitPluralFormNumber = parseInt( form.split( /=/ )[0], 10 ); - explicitPluralForms[explicitPluralFormNumber] = form.slice( form.indexOf( '=' ) + 1 ); - forms[formIndex] = undefined; + explicitPluralFormNumber = parseInt( form.split( /=/ )[ 0 ], 10 ); + explicitPluralForms[ explicitPluralFormNumber ] = form.slice( form.indexOf( '=' ) + 1 ); + forms[ formIndex ] = undefined; } } @@ -1194,7 +1194,7 @@ */ gender: function ( nodes ) { var gender, - maybeUser = nodes[0], + maybeUser = nodes[ 0 ], forms = nodes.slice( 1 ); if ( maybeUser === '' ) { @@ -1219,8 +1219,8 @@ * @return {string} selected grammatical form according to current language */ grammar: function ( nodes ) { - var form = nodes[0], - word = nodes[1]; + var form = nodes[ 0 ], + word = nodes[ 1 ]; return word && form && this.language.convertGrammar( word, form ); }, @@ -1231,7 +1231,7 @@ * @return {string} Other message */ 'int': function ( nodes ) { - var msg = nodes[0]; + var msg = nodes[ 0 ]; return mw.jqueryMsg.getMessageFunction()( msg.charAt( 0 ).toLowerCase() + msg.slice( 1 ) ); }, @@ -1243,8 +1243,8 @@ * @return {number|string} Formatted number */ formatnum: function ( nodes ) { - var isInteger = ( nodes[1] && nodes[1] === 'R' ) ? true : false, - number = nodes[0]; + var isInteger = ( nodes[ 1 ] && nodes[ 1 ] === 'R' ) ? true : false, + number = nodes[ 0 ]; return this.language.convertNumber( number, isInteger ); } diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index e110f90bed..ef6080bb4e 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -69,7 +69,7 @@ if ( $.isPlainObject( selection ) ) { for ( s in selection ) { - setGlobalMapValue( this, s, selection[s] ); + setGlobalMapValue( this, s, selection[ s ] ); } return true; } @@ -96,7 +96,7 @@ * @param {Mixed} value */ function setGlobalMapValue( map, key, value ) { - map.values[key] = value; + map.values[ key ] = value; mw.log.deprecate( window, key, @@ -129,7 +129,7 @@ selection = slice.call( selection ); results = {}; for ( i = 0; i < selection.length; i++ ) { - results[selection[i]] = this.get( selection[i], fallback ); + results[ selection[ i ] ] = this.get( selection[ i ], fallback ); } return results; } @@ -138,7 +138,7 @@ if ( !hasOwn.call( this.values, selection ) ) { return fallback; } - return this.values[selection]; + return this.values[ selection ]; } if ( selection === undefined ) { @@ -161,12 +161,12 @@ if ( $.isPlainObject( selection ) ) { for ( s in selection ) { - this.values[s] = selection[s]; + this.values[ s ] = selection[ s ]; } return true; } if ( typeof selection === 'string' && arguments.length > 1 ) { - this.values[selection] = value; + this.values[ selection ] = value; return true; } return false; @@ -183,7 +183,7 @@ if ( $.isArray( selection ) ) { for ( s = 0; s < selection.length; s++ ) { - if ( typeof selection[s] !== 'string' || !hasOwn.call( this.values, selection[s] ) ) { + if ( typeof selection[ s ] !== 'string' || !hasOwn.call( this.values, selection[ s ] ) ) { return false; } } @@ -285,7 +285,7 @@ params: function ( parameters ) { var i; for ( i = 0; i < parameters.length; i += 1 ) { - this.parameters.push( parameters[i] ); + this.parameters.push( parameters[ i ] ); } return this; }, @@ -423,7 +423,7 @@ var parameters = slice.call( arguments, 1 ); return formatString.replace( /\$(\d+)/g, function ( str, match ) { var index = parseInt( match, 10 ) - 1; - return parameters[index] !== undefined ? parameters[index] : '$' + match; + return parameters[ index ] !== undefined ? parameters[ index ] : '$' + match; } ); }, @@ -486,8 +486,8 @@ */ trackUnsubscribe: function ( callback ) { trackHandlers = $.grep( trackHandlers, function ( fns ) { - if ( fns[1] === callback ) { - trackCallbacks.remove( fns[0] ); + if ( fns[ 1 ] === callback ) { + trackCallbacks.remove( fns[ 0 ] ); // Ensure the tuple is removed to avoid holding on to closures return false; } @@ -633,7 +633,7 @@ * @param {string} [msg] Optional text to include in the deprecation message */ log.deprecate = !Object.defineProperty ? function ( obj, key, val ) { - obj[key] = val; + obj[ key ] = val; } : function ( obj, key, val, msg ) { msg = 'Use of "' + key + '" is deprecated.' + ( msg ? ( ' ' + msg ) : '' ); // Support: IE8 @@ -655,7 +655,7 @@ } ); } catch ( err ) { // Fallback to creating a copy of the value to the object. - obj[key] = val; + obj[ key ] = val; } }; @@ -821,7 +821,7 @@ if ( nextnode ) { $( nextnode ).before( s ); } else { - document.getElementsByTagName( 'head' )[0].appendChild( s ); + document.getElementsByTagName( 'head' )[ 0 ].appendChild( s ); } if ( s.styleSheet ) { // Support: IE6-10 @@ -937,7 +937,7 @@ */ function getCombinedVersion( modules ) { var hashes = $.map( modules, function ( module ) { - return registry[module].version; + return registry[ module ].version; } ); // Trim for consistency with server-side ResourceLoader::makeHash. It also helps // save precious space in the limited query string. Otherwise modules are more @@ -956,7 +956,7 @@ function allReady( modules ) { var i; for ( i = 0; i < modules.length; i++ ) { - if ( mw.loader.getState( modules[i] ) !== 'ready' ) { + if ( mw.loader.getState( modules[ i ] ) !== 'ready' ) { return false; } } @@ -974,7 +974,7 @@ function anyFailed( modules ) { var i, state; for ( i = 0; i < modules.length; i++ ) { - state = mw.loader.getState( modules[i] ); + state = mw.loader.getState( modules[ i ] ); if ( state === 'error' || state === 'missing' ) { return true; } @@ -996,16 +996,16 @@ function handlePending( module ) { var j, job, hasErrors, m, stateChange; - if ( registry[module].state === 'error' || registry[module].state === 'missing' ) { + if ( registry[ module ].state === 'error' || registry[ module ].state === 'missing' ) { // If the current module failed, mark all dependent modules also as failed. // Iterate until steady-state to propagate the error state upwards in the // dependency tree. do { stateChange = false; for ( m in registry ) { - if ( registry[m].state !== 'error' && registry[m].state !== 'missing' ) { - if ( anyFailed( registry[m].dependencies ) ) { - registry[m].state = 'error'; + if ( registry[ m ].state !== 'error' && registry[ m ].state !== 'missing' ) { + if ( anyFailed( registry[ m ].dependencies ) ) { + registry[ m ].state = 'error'; stateChange = true; } } @@ -1015,16 +1015,16 @@ // Execute all jobs whose dependencies are either all satisfied or contain at least one failed module. for ( j = 0; j < jobs.length; j += 1 ) { - hasErrors = anyFailed( jobs[j].dependencies ); - if ( hasErrors || allReady( jobs[j].dependencies ) ) { + hasErrors = anyFailed( jobs[ j ].dependencies ); + if ( hasErrors || allReady( jobs[ j ].dependencies ) ) { // All dependencies satisfied, or some have errors - job = jobs[j]; + job = jobs[ j ]; jobs.splice( j, 1 ); j -= 1; try { if ( hasErrors ) { if ( $.isFunction( job.error ) ) { - job.error( new Error( 'Module ' + module + ' has failed dependencies' ), [module] ); + job.error( new Error( 'Module ' + module + ' has failed dependencies' ), [ module ] ); } } else { if ( $.isFunction( job.ready ) ) { @@ -1039,12 +1039,12 @@ } } - if ( registry[module].state === 'ready' ) { + if ( registry[ module ].state === 'ready' ) { // The current module became 'ready'. Set it in the module store, and recursively execute all // dependent modules that are loaded and now have all dependencies satisfied. - mw.loader.store.set( module, registry[module] ); + mw.loader.store.set( module, registry[ module ] ); for ( m in registry ) { - if ( registry[m].state === 'loaded' && allReady( registry[m].dependencies ) ) { + if ( registry[ m ].state === 'loaded' && allReady( registry[ m ].dependencies ) ) { execute( m ); } } @@ -1072,25 +1072,25 @@ throw new Error( 'Unknown dependency: ' + module ); } - if ( registry[module].skip !== null ) { + if ( registry[ module ].skip !== null ) { /*jshint evil:true */ - skip = new Function( registry[module].skip ); - registry[module].skip = null; + skip = new Function( registry[ module ].skip ); + registry[ module ].skip = null; if ( skip() ) { - registry[module].skipped = true; - registry[module].dependencies = []; - registry[module].state = 'ready'; + registry[ module ].skipped = true; + registry[ module ].dependencies = []; + registry[ module ].state = 'ready'; handlePending( module ); return; } } // Resolves dynamic loader function and replaces it with its own results - if ( $.isFunction( registry[module].dependencies ) ) { - registry[module].dependencies = registry[module].dependencies(); + if ( $.isFunction( registry[ module ].dependencies ) ) { + registry[ module ].dependencies = registry[ module ].dependencies(); // Ensures the module's dependencies are always in an array - if ( typeof registry[module].dependencies !== 'object' ) { - registry[module].dependencies = [registry[module].dependencies]; + if ( typeof registry[ module ].dependencies !== 'object' ) { + registry[ module ].dependencies = [ registry[ module ].dependencies ]; } } if ( $.inArray( module, resolved ) !== -1 ) { @@ -1102,24 +1102,24 @@ unresolved = {}; } // Tracks down dependencies - deps = registry[module].dependencies; + deps = registry[ module ].dependencies; len = deps.length; for ( n = 0; n < len; n += 1 ) { - if ( $.inArray( deps[n], resolved ) === -1 ) { - if ( unresolved[deps[n]] ) { + if ( $.inArray( deps[ n ], resolved ) === -1 ) { + if ( unresolved[ deps[ n ] ] ) { throw new Error( 'Circular reference detected: ' + module + - ' -> ' + deps[n] + ' -> ' + deps[ n ] ); } // Add to unresolved - unresolved[module] = true; - sortDependencies( deps[n], resolved, unresolved ); - delete unresolved[module]; + unresolved[ module ] = true; + sortDependencies( deps[ n ], resolved, unresolved ); + delete unresolved[ module ]; } } - resolved[resolved.length] = module; + resolved[ resolved.length ] = module; } /** @@ -1172,13 +1172,13 @@ if ( !hasOwn.call( registry, module ) ) { throw new Error( 'Module has not been registered yet: ' + module ); } - if ( registry[module].state === 'registered' ) { + if ( registry[ module ].state === 'registered' ) { throw new Error( 'Module has not been requested from the server yet: ' + module ); } - if ( registry[module].state === 'loading' ) { + if ( registry[ module ].state === 'loading' ) { throw new Error( 'Module has not completed loading yet: ' + module ); } - if ( registry[module].state === 'ready' ) { + if ( registry[ module ].state === 'ready' ) { throw new Error( 'Module has already been executed: ' + module ); } @@ -1207,9 +1207,9 @@ // and their dependencies from the legacyWait (to prevent a circular dependency). legacyModules = resolve( mw.config.get( 'wgResourceLoaderLegacyModules', [] ) ); try { - script = registry[module].script; + script = registry[ module ].script; markModuleReady = function () { - registry[module].state = 'ready'; + registry[ module ].state = 'ready'; handlePending( module ); }; nestedAddScript = function ( arr, callback, i ) { @@ -1221,7 +1221,7 @@ return; } - addScript( arr[i], function () { + addScript( arr[ i ], function () { nestedAddScript( arr, callback, i + 1 ); } ); }; @@ -1258,7 +1258,7 @@ } catch ( e ) { // This needs to NOT use mw.log because these errors are common in production mode // and not in debug mode, such as when a symbol that should be global isn't exported - registry[module].state = 'error'; + registry[ module ].state = 'error'; mw.track( 'resourceloader.exception', { exception: e, module: module, source: 'module-execute' } ); handlePending( module ); } @@ -1268,16 +1268,16 @@ // (after CSS is loaded) we need to set it here right away. It is crucial that // when execute() is called this is set synchronously, otherwise modules will get // executed multiple times as the registry will state that it isn't loading yet. - registry[module].state = 'loading'; + registry[ module ].state = 'loading'; // Add localizations to message system - if ( registry[module].messages ) { - mw.messages.set( registry[module].messages ); + if ( registry[ module ].messages ) { + mw.messages.set( registry[ module ].messages ); } // Initialise templates - if ( registry[module].templates ) { - mw.templates.set( module, registry[module].templates ); + if ( registry[ module ].templates ) { + mw.templates.set( module, registry[ module ].templates ); } // Make sure we don't run the scripts until all stylesheet insertions have completed. @@ -1309,9 +1309,9 @@ // * back-compat: { : [url, ..] } // * { "css": [css, ..] } // * { "url": { : [url, ..] } } - if ( registry[module].style ) { - for ( key in registry[module].style ) { - value = registry[module].style[key]; + if ( registry[ module ].style ) { + for ( key in registry[ module ].style ) { + value = registry[ module ].style[ key ]; media = undefined; if ( key !== 'url' && key !== 'css' ) { @@ -1336,10 +1336,10 @@ for ( i = 0; i < value.length; i += 1 ) { if ( key === 'bc-url' ) { // back-compat: { : [url, ..] } - addLink( media, value[i] ); + addLink( media, value[ i ] ); } else if ( key === 'css' ) { // { "css": [css, ..] } - addEmbeddedCSS( value[i], cssHandle() ); + addEmbeddedCSS( value[ i ], cssHandle() ); } } // Not an array, but a regular object @@ -1347,9 +1347,9 @@ } else if ( typeof value === 'object' ) { // { "url": { : [url, ..] } } for ( media in value ) { - urls = value[media]; + urls = value[ media ]; for ( i = 0; i < urls.length; i += 1 ) { - addLink( media, urls[i] ); + addLink( media, urls[ i ] ); } } } @@ -1373,12 +1373,12 @@ function request( dependencies, ready, error ) { // Allow calling by single module name if ( typeof dependencies === 'string' ) { - dependencies = [dependencies]; + dependencies = [ dependencies ]; } // Add ready and error callbacks if they were given if ( ready !== undefined || error !== undefined ) { - jobs[jobs.length] = { + jobs[ jobs.length ] = { dependencies: $.grep( dependencies, function ( module ) { var state = mw.loader.getState( module ); return state === 'registered' || state === 'loaded' || state === 'loading'; @@ -1395,8 +1395,8 @@ if ( state === 'registered' && $.inArray( module, queue ) === -1 ) { // Private modules must be embedded in the page. Don't bother queuing // these as the server will deny them anyway (T101806). - if ( registry[module].group === 'private' ) { - registry[module].state = 'error'; + if ( registry[ module ].group === 'private' ) { + registry[ module ].state = 'error'; handlePending( module ); return; } @@ -1419,7 +1419,7 @@ } a.sort(); for ( key = 0; key < a.length; key += 1 ) { - sorted[a[key]] = o[a[key]]; + sorted[ a[ key ] ] = o[ a[ key ] ]; } return sorted; } @@ -1435,7 +1435,7 @@ for ( prefix in moduleMap ) { p = prefix === '' ? '' : prefix + '.'; - arr.push( p + moduleMap[prefix].join( ',' ) ); + arr.push( p + moduleMap[ prefix ].join( ',' ) ); } return arr.join( '|' ); } @@ -1469,9 +1469,9 @@ */ function resolveIndexedDependencies( modules ) { $.each( modules, function ( idx, module ) { - if ( module[2] ) { - module[2] = $.map( module[2], function ( dep ) { - return typeof dep === 'number' ? modules[dep][0] : dep; + if ( module[ 2 ] ) { + module[ 2 ] = $.map( module[ 2 ], function ( dep ) { + return typeof dep === 'number' ? modules[ dep ][ 0 ] : dep; } ); } } ); @@ -1517,12 +1517,12 @@ // Appends a list of modules from the queue to the batch for ( q = 0; q < queue.length; q += 1 ) { // Only request modules which are registered - if ( hasOwn.call( registry, queue[q] ) && registry[queue[q]].state === 'registered' ) { + if ( hasOwn.call( registry, queue[ q ] ) && registry[ queue[ q ] ].state === 'registered' ) { // Prevent duplicate entries - if ( $.inArray( queue[q], batch ) === -1 ) { - batch[batch.length] = queue[q]; + if ( $.inArray( queue[ q ], batch ) === -1 ) { + batch[ batch.length ] = queue[ q ]; // Mark registered modules as loading - registry[queue[q]].state = 'loading'; + registry[ queue[ q ] ].state = 'loading'; } } } @@ -1558,7 +1558,7 @@ // the error) instead of all of them. mw.track( 'resourceloader.exception', { exception: err, source: 'store-eval' } ); origBatch = $.grep( origBatch, function ( module ) { - return registry[module].state === 'loading'; + return registry[ module ].state === 'loading'; } ); batch = batch.concat( origBatch ); } @@ -1578,16 +1578,16 @@ // Split batch by source and by group. for ( b = 0; b < batch.length; b += 1 ) { - bSource = registry[batch[b]].source; - bGroup = registry[batch[b]].group; + bSource = registry[ batch[ b ] ].source; + bGroup = registry[ batch[ b ] ].group; if ( !hasOwn.call( splits, bSource ) ) { - splits[bSource] = {}; + splits[ bSource ] = {}; } - if ( !hasOwn.call( splits[bSource], bGroup ) ) { - splits[bSource][bGroup] = []; + if ( !hasOwn.call( splits[ bSource ], bGroup ) ) { + splits[ bSource ][ bGroup ] = []; } - bSourceGroup = splits[bSource][bGroup]; - bSourceGroup[bSourceGroup.length] = batch[b]; + bSourceGroup = splits[ bSource ][ bGroup ]; + bSourceGroup[ bSourceGroup.length ] = batch[ b ]; } // Clear the batch - this MUST happen before we append any @@ -1599,13 +1599,13 @@ for ( source in splits ) { - sourceLoadScript = sources[source]; + sourceLoadScript = sources[ source ]; - for ( group in splits[source] ) { + for ( group in splits[ source ] ) { // Cache access to currently selected list of // modules for this group from this source. - modules = splits[source][group]; + modules = splits[ source ][ group ]; currReqBase = $.extend( { version: getCombinedVersion( modules ) @@ -1623,15 +1623,15 @@ for ( i = 0; i < modules.length; i += 1 ) { // Determine how many bytes this module would add to the query string - lastDotIndex = modules[i].lastIndexOf( '.' ); + lastDotIndex = modules[ i ].lastIndexOf( '.' ); // If lastDotIndex is -1, substr() returns an empty string - prefix = modules[i].substr( 0, lastDotIndex ); - suffix = modules[i].slice( lastDotIndex + 1 ); + prefix = modules[ i ].substr( 0, lastDotIndex ); + suffix = modules[ i ].slice( lastDotIndex + 1 ); bytesAdded = hasOwn.call( moduleMap, prefix ) ? suffix.length + 3 // '%2C'.length == 3 - : modules[i].length + 3; // '%7C'.length == 3 + : modules[ i ].length + 3; // '%7C'.length == 3 // If the request would become too long, create a new one, // but don't create empty requests @@ -1644,9 +1644,9 @@ mw.track( 'resourceloader.splitRequest', { maxQueryLength: maxQueryLength } ); } if ( !hasOwn.call( moduleMap, prefix ) ) { - moduleMap[prefix] = []; + moduleMap[ prefix ] = []; } - moduleMap[prefix].push( suffix ); + moduleMap[ prefix ].push( suffix ); l += bytesAdded; } // If there's anything left in moduleMap, request that too @@ -1674,7 +1674,7 @@ // Allow multiple additions if ( typeof id === 'object' ) { for ( source in id ) { - mw.loader.addSource( source, id[source] ); + mw.loader.addSource( source, id[ source ] ); } return true; } @@ -1687,7 +1687,7 @@ loadUrl = loadUrl.loadScript; } - sources[id] = loadUrl; + sources[ id ] = loadUrl; return true; }, @@ -1718,11 +1718,11 @@ resolveIndexedDependencies( module ); for ( i = 0, len = module.length; i < len; i++ ) { // module is an array of module names - if ( typeof module[i] === 'string' ) { - mw.loader.register( module[i] ); + if ( typeof module[ i ] === 'string' ) { + mw.loader.register( module[ i ] ); // module is an array of arrays - } else if ( typeof module[i] === 'object' ) { - mw.loader.register.apply( mw.loader, module[i] ); + } else if ( typeof module[ i ] === 'object' ) { + mw.loader.register.apply( mw.loader, module[ i ] ); } } return; @@ -1735,7 +1735,7 @@ throw new Error( 'module already registered: ' + module ); } // List the module as registered - registry[module] = { + registry[ module ] = { version: version !== undefined ? String( version ) : '', dependencies: [], group: typeof group === 'string' ? group : null, @@ -1745,11 +1745,11 @@ }; if ( typeof dependencies === 'string' ) { // Allow dependencies to be given as a single module name - registry[module].dependencies = [ dependencies ]; + registry[ module ].dependencies = [ dependencies ]; } else if ( typeof dependencies === 'object' || $.isFunction( dependencies ) ) { // Allow dependencies to be given as an array of module names // or a function which returns an array - registry[module].dependencies = dependencies; + registry[ module ].dependencies = dependencies; } }, @@ -1802,18 +1802,18 @@ mw.loader.register( module ); } // Check for duplicate implementation - if ( hasOwn.call( registry, module ) && registry[module].script !== undefined ) { + if ( hasOwn.call( registry, module ) && registry[ module ].script !== undefined ) { throw new Error( 'module already implemented: ' + module ); } // Attach components - registry[module].script = script || []; - registry[module].style = style || {}; - registry[module].messages = messages || {}; - registry[module].templates = templates || {}; + registry[ module ].script = script || []; + registry[ module ].style = style || {}; + registry[ module ].messages = messages || {}; + registry[ module ].templates = templates || {}; // The module may already have been marked as erroneous - if ( $.inArray( registry[module].state, ['error', 'missing'] ) === -1 ) { - registry[module].state = 'loaded'; - if ( allReady( registry[module].dependencies ) ) { + if ( $.inArray( registry[ module ].state, [ 'error', 'missing' ] ) === -1 ) { + registry[ module ].state = 'loaded'; + if ( allReady( registry[ module ].dependencies ) ) { execute( module ); } } @@ -1947,21 +1947,21 @@ if ( typeof module === 'object' ) { for ( m in module ) { - mw.loader.state( m, module[m] ); + mw.loader.state( m, module[ m ] ); } return; } if ( !hasOwn.call( registry, module ) ) { mw.loader.register( module ); } - if ( $.inArray( state, ['ready', 'error', 'missing'] ) !== -1 - && registry[module].state !== state ) { + if ( $.inArray( state, [ 'ready', 'error', 'missing' ] ) !== -1 + && registry[ module ].state !== state ) { // Make sure pending modules depending on this one get executed if their // dependencies are now fulfilled! - registry[module].state = state; + registry[ module ].state = state; handlePending( module ); } else { - registry[module].state = state; + registry[ module ].state = state; } }, @@ -1973,10 +1973,10 @@ * in the registry. */ getVersion: function ( module ) { - if ( !hasOwn.call( registry, module ) || registry[module].version === undefined ) { + if ( !hasOwn.call( registry, module ) || registry[ module ].version === undefined ) { return null; } - return registry[module].version; + return registry[ module ].version; }, /** @@ -1987,10 +1987,10 @@ * in the registry. */ getState: function ( module ) { - if ( !hasOwn.call( registry, module ) || registry[module].state === undefined ) { + if ( !hasOwn.call( registry, module ) || registry[ module ].state === undefined ) { return null; } - return registry[module].state; + return registry[ module ].state; }, /** @@ -2078,7 +2078,7 @@ */ getModuleKey: function ( module ) { return hasOwn.call( registry, module ) ? - ( module + '@' + registry[module].version ) : null; + ( module + '@' + registry[ module ].version ) : null; }, /** @@ -2150,7 +2150,7 @@ key = mw.loader.store.getModuleKey( module ); if ( key in mw.loader.store.items ) { mw.loader.store.stats.hits++; - return mw.loader.store.items[key]; + return mw.loader.store.items[ key ]; } mw.loader.store.stats.misses++; return false; @@ -2198,8 +2198,8 @@ ]; // Attempted workaround for a possible Opera bug (bug T59567). // This regex should never match under sane conditions. - if ( /^\s*\(/.test( args[1] ) ) { - args[1] = 'function' + args[1]; + if ( /^\s*\(/.test( args[ 1 ] ) ) { + args[ 1 ] = 'function' + args[ 1 ]; mw.track( 'resourceloader.assert', { source: 'bug-T59567' } ); } } catch ( e ) { @@ -2211,7 +2211,7 @@ if ( src.length > mw.loader.store.MODULE_SIZE_MAX ) { return false; } - mw.loader.store.items[key] = src; + mw.loader.store.items[ key ] = src; mw.loader.store.update(); }, @@ -2230,10 +2230,10 @@ module = key.slice( 0, key.indexOf( '@' ) ); if ( mw.loader.store.getModuleKey( module ) !== key ) { mw.loader.store.stats.expired++; - delete mw.loader.store.items[key]; - } else if ( mw.loader.store.items[key].length > mw.loader.store.MODULE_SIZE_MAX ) { + delete mw.loader.store.items[ key ]; + } else if ( mw.loader.store.items[ key ].length > mw.loader.store.MODULE_SIZE_MAX ) { // This value predates the enforcement of a size limit on cached modules. - delete mw.loader.store.items[key]; + delete mw.loader.store.items[ key ]; } } }, @@ -2362,7 +2362,7 @@ var v, attrName, s = '<' + name; for ( attrName in attrs ) { - v = attrs[attrName]; + v = attrs[ attrName ]; // Convert name=true, to name=name if ( v === true ) { v = attrName; @@ -2483,8 +2483,8 @@ */ return function ( name ) { var list = hasOwn.call( lists, name ) ? - lists[name] : - lists[name] = $.Callbacks( 'memory' ); + lists[ name ] : + lists[ name ] = $.Callbacks( 'memory' ); return { /** diff --git a/resources/src/mediawiki/mediawiki.notification.js b/resources/src/mediawiki/mediawiki.notification.js index 004e71086a..b5e8dae5e8 100644 --- a/resources/src/mediawiki/mediawiki.notification.js +++ b/resources/src/mediawiki/mediawiki.notification.js @@ -362,7 +362,7 @@ $notifications.each( function () { var notif = $( this ).data( 'mw.notification' ); if ( notif ) { - notif[fn](); + notif[ fn ](); } } ); } diff --git a/resources/src/mediawiki/mediawiki.searchSuggest.js b/resources/src/mediawiki/mediawiki.searchSuggest.js index a20d7f077d..3c4f32ebd2 100644 --- a/resources/src/mediawiki/mediawiki.searchSuggest.js +++ b/resources/src/mediawiki/mediawiki.searchSuggest.js @@ -32,14 +32,14 @@ // Compatibility map map = { // SimpleSearch is broken in Opera < 9.6 - opera: [['>=', 9.6]], + opera: [ [ '>=', 9.6 ] ], // Older Konquerors are unable to position the suggestions correctly (bug 50805) - konqueror: [['>=', '4.11']], + konqueror: [ [ '>=', '4.11' ] ], docomo: false, blackberry: false, // Support for iOS 6 or higher. It has not been tested on iOS 5 or lower - ipod: [['>=', 6]], - iphone: [['>=', 6]] + ipod: [ [ '>=', 6 ] ], + iphone: [ [ '>=', 6 ] ] }; if ( !$.client.test( map ) ) { @@ -182,14 +182,14 @@ $( searchboxesSelectors.join( ', ' ) ) .suggestions( { fetch: function ( query, response, maxRows ) { - var node = this[0]; + var node = this[ 0 ]; api = api || new mw.Api(); $.data( node, 'request', mw.searchSuggest.request( api, query, response, maxRows ) ); }, cancel: function () { - var node = this[0], + var node = this[ 0 ], request = $.data( node, 'request' ); if ( request ) { diff --git a/resources/src/mediawiki/mediawiki.template.js b/resources/src/mediawiki/mediawiki.template.js index 61bbb0d7bf..c3db69e6f4 100644 --- a/resources/src/mediawiki/mediawiki.template.js +++ b/resources/src/mediawiki/mediawiki.template.js @@ -17,7 +17,7 @@ if ( !compiler.compile ) { throw new Error( 'Compiler must implement compile method.' ); } - compilers[name] = compiler; + compilers[ name ] = compiler; }, /** @@ -63,12 +63,12 @@ var compiledTemplate, compilerName = this.getCompilerName( templateName ); - if ( !compiledTemplates[moduleName] ) { - compiledTemplates[moduleName] = {}; + if ( !compiledTemplates[ moduleName ] ) { + compiledTemplates[ moduleName ] = {}; } compiledTemplate = this.compile( templateBody, compilerName ); - compiledTemplates[moduleName][ templateName ] = compiledTemplate; + compiledTemplates[ moduleName ][ templateName ] = compiledTemplate; return compiledTemplate; }, diff --git a/resources/src/mediawiki/mediawiki.user.js b/resources/src/mediawiki/mediawiki.user.js index ec34ce6cca..b4baa66caa 100644 --- a/resources/src/mediawiki/mediawiki.user.js +++ b/resources/src/mediawiki/mediawiki.user.js @@ -16,7 +16,7 @@ */ function getUserInfo( info ) { var api; - if ( !deferreds[info] ) { + if ( !deferreds[ info ] ) { deferreds.rights = $.Deferred(); deferreds.groups = $.Deferred(); @@ -38,13 +38,13 @@ } - return deferreds[info].promise(); + return deferreds[ info ].promise(); } // Map from numbers 0-255 to a hex string (with padding) for ( i = 0; i < 256; i++ ) { // Padding: Add a full byte (0x100, 256) and strip the extra character - byteToHex[i] = ( i + 256 ).toString( 16 ).slice( 1 ); + byteToHex[ i ] = ( i + 256 ).toString( 16 ).slice( 1 ); } // mw.user with the properties options and tokens gets defined in mediawiki.js. @@ -89,12 +89,12 @@ if ( ( i & 3 ) === 0 ) { r = Math.random() * 0x100000000; } - rnds[i] = r >>> ( ( i & 3 ) << 3 ) & 255; + rnds[ i ] = r >>> ( ( i & 3 ) << 3 ) & 255; } } // Convert from number to hex for ( i = 0; i < 8; i++ ) { - hexRnds[i] = byteToHex[rnds[i]]; + hexRnds[ i ] = byteToHex[ rnds[ i ] ]; } // Concatenation of two random integers with entrophy n and m @@ -213,9 +213,9 @@ // Bucket information is stored as 2 integers, together as version:bucket like: "1:2" if ( typeof cookie === 'string' && cookie.length > 2 && cookie.indexOf( ':' ) !== -1 ) { parts = cookie.split( ':' ); - if ( parts.length > 1 && Number( parts[0] ) === options.version ) { - version = Number( parts[0] ); - bucket = String( parts[1] ); + if ( parts.length > 1 && Number( parts[ 0 ] ) === options.version ) { + version = Number( parts[ 0 ] ); + bucket = String( parts[ 1 ] ); } } @@ -229,7 +229,7 @@ // Find range range = 0; for ( k in options.buckets ) { - range += options.buckets[k]; + range += options.buckets[ k ]; } // Select random value within range @@ -239,7 +239,7 @@ total = 0; for ( k in options.buckets ) { bucket = k; - total += options.buckets[k]; + total += options.buckets[ k ]; if ( total >= rand ) { break; } diff --git a/resources/src/mediawiki/mediawiki.userSuggest.js b/resources/src/mediawiki/mediawiki.userSuggest.js index df1020445c..02a90fc341 100644 --- a/resources/src/mediawiki/mediawiki.userSuggest.js +++ b/resources/src/mediawiki/mediawiki.userSuggest.js @@ -6,7 +6,7 @@ config = { fetch: function ( userInput, response, maxRows ) { - var node = this[0]; + var node = this[ 0 ]; api = api || new mw.Api(); @@ -15,7 +15,7 @@ list: 'allusers', // Prefix of list=allusers is case sensitive. Normalise first // character to uppercase so that "fo" may yield "Foo". - auprefix: userInput[0].toUpperCase() + userInput.slice( 1 ), + auprefix: userInput[ 0 ].toUpperCase() + userInput.slice( 1 ), aulimit: maxRows } ).done( function ( data ) { var users = $.map( data.query.allusers, function ( userObj ) { @@ -25,7 +25,7 @@ } ) ); }, cancel: function () { - var node = this[0], + var node = this[ 0 ], request = $.data( node, 'request' ); if ( request ) { diff --git a/resources/src/mediawiki/mediawiki.util.js b/resources/src/mediawiki/mediawiki.util.js index 93a1b3bfbc..2a3542ceaa 100644 --- a/resources/src/mediawiki/mediawiki.util.js +++ b/resources/src/mediawiki/mediawiki.util.js @@ -33,7 +33,7 @@ ]; for ( i = 0, l = selectors.length; i < l; i++ ) { - $node = $( selectors[i] ); + $node = $( selectors[ i ] ); if ( $node.length ) { return $node.first(); } @@ -165,7 +165,7 @@ if ( m ) { // Beware that decodeURIComponent is not required to understand '+' // by spec, as encodeURIComponent does not produce it. - return decodeURIComponent( m[1].replace( /\+/g, '%20' ) ); + return decodeURIComponent( m[ 1 ].replace( /\+/g, '%20' ) ); } return null; }, @@ -299,7 +299,7 @@ // Error: Invalid nextnode nextnode = undefined; } - if ( nextnode && ( nextnode.length !== 1 || nextnode[0].parentNode !== $ul[0] ) ) { + if ( nextnode && ( nextnode.length !== 1 || nextnode[ 0 ].parentNode !== $ul[ 0 ] ) ) { // Error: nextnode must resolve to a single node // Error: nextnode must have the associated
      as its parent nextnode = undefined; @@ -318,7 +318,7 @@ // to get a localized access key label (bug 67946). $link.updateTooltipAccessKeys(); - return $item[0]; + return $item[ 0 ]; }, /** diff --git a/resources/src/startup.js b/resources/src/startup.js index 1d1455c43d..97b4fce258 100644 --- a/resources/src/startup.js +++ b/resources/src/startup.js @@ -35,18 +35,18 @@ function isCompatible( ua ) { // Browsers with outdated or limited JavaScript engines get the no-JS experience return !( // Internet Explorer < 8 - ( ua.indexOf( 'MSIE' ) !== -1 && parseFloat( ua.split( 'MSIE' )[1] ) < 8 ) || + ( ua.indexOf( 'MSIE' ) !== -1 && parseFloat( ua.split( 'MSIE' )[ 1 ] ) < 8 ) || // Firefox < 3 - ( ua.indexOf( 'Firefox/' ) !== -1 && parseFloat( ua.split( 'Firefox/' )[1] ) < 3 ) || + ( ua.indexOf( 'Firefox/' ) !== -1 && parseFloat( ua.split( 'Firefox/' )[ 1 ] ) < 3 ) || // Opera < 12 ( ua.indexOf( 'Opera/' ) !== -1 && ( ua.indexOf( 'Version/' ) === -1 ? // "Opera/x.y" - parseFloat( ua.split( 'Opera/' )[1] ) < 10 : + parseFloat( ua.split( 'Opera/' )[ 1 ] ) < 10 : // "Opera/9.80 ... Version/x.y" - parseFloat( ua.split( 'Version/' )[1] ) < 12 + parseFloat( ua.split( 'Version/' )[ 1 ] ) < 12 ) ) || // "Mozilla/0.0 ... Opera x.y" - ( ua.indexOf( 'Opera ' ) !== -1 && parseFloat( ua.split( ' Opera ' )[1] ) < 10 ) || + ( ua.indexOf( 'Opera ' ) !== -1 && parseFloat( ua.split( ' Opera ' )[ 1 ] ) < 10 ) || // BlackBerry < 6 ua.match( /BlackBerry[^\/]*\/[1-5]\./ ) || // Open WebOS < 1.5 @@ -112,5 +112,5 @@ function isCompatible( ua ) { startUp(); } }; - document.getElementsByTagName( 'head' )[0].appendChild( script ); + document.getElementsByTagName( 'head' )[ 0 ].appendChild( script ); }() ); diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js index ab5229ec40..fb4667a714 100644 --- a/tests/qunit/data/testrunner.js +++ b/tests/qunit/data/testrunner.js @@ -66,7 +66,7 @@ sinon.config = { injectIntoThis: true, injectInto: null, - properties: ['spy', 'stub', 'mock', 'sandbox'], + properties: [ 'spy', 'stub', 'mock', 'sandbox' ], // Don't fake timers by default useFakeTimers: false, useFakeServer: false @@ -333,7 +333,7 @@ children = $node.contents(); processedChildren = []; for ( i = 0, len = children.length; i < len; i++ ) { - el = children[i]; + el = children[ i ]; if ( el.nodeType === Node.ELEMENT_NODE || el.nodeType === Node.TEXT_NODE ) { processedChildren.push( getDomStructure( el ) ); } @@ -356,7 +356,7 @@ * @param {string} html HTML markup for one or more nodes. */ function getHtmlStructure( html ) { - var el = $( '
      ' ).append( html )[0]; + var el = $( '
      ' ).append( html )[ 0 ]; return getDomStructure( el ); } @@ -488,11 +488,11 @@ missing = []; for ( i = 0, len = modules.length; i < len; i++ ) { - state = mw.loader.getState( modules[i] ); + state = mw.loader.getState( modules[ i ] ); if ( state === 'error' ) { - error.push( modules[i] ); + error.push( modules[ i ] ); } else if ( state === 'missing' ) { - missing.push( modules[i] ); + missing.push( modules[ i ] ); } } diff --git a/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js b/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js index 4484467d0b..bd622d90e7 100644 --- a/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js @@ -9,23 +9,23 @@ var getAccessKeyPrefixTestData = [ // ua string, platform string, expected prefix // Internet Explorer - ['Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', 'Win32', 'alt-'], - ['Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)', 'Win32', 'alt-'], - ['Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; rv:11.0) like Gecko', 'Win64', 'alt-'], + [ 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', 'Win32', 'alt-' ], + [ 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)', 'Win32', 'alt-' ], + [ 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; rv:11.0) like Gecko', 'Win64', 'alt-' ], // Firefox - ['Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19', 'MacIntel', 'ctrl-'], - ['Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/10.10 (maverick) Firefox/3.6.17', 'Linux i686', 'alt-shift-'], - ['Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1', 'Win32', 'alt-shift-'], + [ 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19', 'MacIntel', 'ctrl-' ], + [ 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/10.10 (maverick) Firefox/3.6.17', 'Linux i686', 'alt-shift-' ], + [ 'Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1', 'Win32', 'alt-shift-' ], // Safari / Konqueror - ['Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; nl-nl) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7', 'MacIntel', 'ctrl-alt-'], - ['Mozilla/5.0 (Windows; U; Windows NT 6.0; cs-CZ) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7', 'Win32', 'alt-'], - ['Mozilla/5.0 (X11; Linux i686) KHTML/4.9.1 (like Gecko) Konqueror/4.9', 'Linux i686', 'ctrl-'], + [ 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; nl-nl) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7', 'MacIntel', 'ctrl-alt-' ], + [ 'Mozilla/5.0 (Windows; U; Windows NT 6.0; cs-CZ) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7', 'Win32', 'alt-' ], + [ 'Mozilla/5.0 (X11; Linux i686) KHTML/4.9.1 (like Gecko) Konqueror/4.9', 'Linux i686', 'ctrl-' ], // Opera - ['Opera/9.80 (Windows NT 5.1)', 'Win32', 'shift-esc-'], - ['Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.130', 'Win32', 'shift-esc-'], + [ 'Opera/9.80 (Windows NT 5.1)', 'Win32', 'shift-esc-' ], + [ 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.130', 'Win32', 'shift-esc-' ], // Chrome - ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30', 'MacIntel', 'ctrl-option-'], - ['Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.68 Safari/534.30', 'Linux i686', 'alt-shift-'] + [ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30', 'MacIntel', 'ctrl-option-' ], + [ 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.68 Safari/534.30', 'Linux i686', 'alt-shift-' ] ], // strings appended to title to make sure updateTooltipAccessKeys handles them correctly updateTooltipAccessKeysTestData = [ '', ' [a]', ' [test-a]', ' [alt-b]' ]; @@ -39,9 +39,9 @@ var i; for ( i = 0; i < getAccessKeyPrefixTestData.length; i++ ) { assert.equal( $.fn.updateTooltipAccessKeys.getAccessKeyPrefix( { - userAgent: getAccessKeyPrefixTestData[i][0], - platform: getAccessKeyPrefixTestData[i][1] - } ), getAccessKeyPrefixTestData[i][2], 'Correct prefix for ' + getAccessKeyPrefixTestData[i][0] ); + userAgent: getAccessKeyPrefixTestData[ i ][ 0 ], + platform: getAccessKeyPrefixTestData[ i ][ 1 ] + } ), getAccessKeyPrefixTestData[ i ][ 2 ], 'Correct prefix for ' + getAccessKeyPrefixTestData[ i ][ 0 ] ); } } ); @@ -52,13 +52,13 @@ // (no browser is known using such a short prefix, though) or "Alt+Umschalt+" in German Firefox. result = /^Title \[(.+)[aA]\]$/.exec( title ); assert.ok( result, 'title should match expected structure.' ); - assert.notEqual( result[1], 'test-', 'Prefix used for testing shouldn\'t be used in production.' ); + assert.notEqual( result[ 1 ], 'test-', 'Prefix used for testing shouldn\'t be used in production.' ); } ); QUnit.test( 'updateTooltipAccessKeys - no access key', updateTooltipAccessKeysTestData.length, function ( assert ) { var i, oldTitle, $input, newTitle; for ( i = 0; i < updateTooltipAccessKeysTestData.length; i++ ) { - oldTitle = 'Title' + updateTooltipAccessKeysTestData[i]; + oldTitle = 'Title' + updateTooltipAccessKeysTestData[ i ]; $input = $( makeInput( oldTitle ) ); $( '#qunit-fixture' ).append( $input ); newTitle = $input.updateTooltipAccessKeys().prop( 'title' ); @@ -70,7 +70,7 @@ $.fn.updateTooltipAccessKeys.setTestMode( true ); var i, oldTitle, $input, newTitle; for ( i = 0; i < updateTooltipAccessKeysTestData.length; i++ ) { - oldTitle = 'Title' + updateTooltipAccessKeysTestData[i]; + oldTitle = 'Title' + updateTooltipAccessKeysTestData[ i ]; $input = $( makeInput( oldTitle, 'a' ) ); $( '#qunit-fixture' ).append( $input ); newTitle = $input.updateTooltipAccessKeys().prop( 'title' ); diff --git a/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.test.js b/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.test.js index e8c5121429..a1b2e5c3db 100644 --- a/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.test.js @@ -11,7 +11,7 @@ function findDivergenceIndex( a, b ) { var i = 0; - while ( i < a.length && i < b.length && a[i] === b[i] ) { + while ( i < a.length && i < b.length && a[ i ] === b[ i ] ) { i++; } return i; @@ -41,7 +41,7 @@ // Add two characters using scary black magic spanText = $span.text(); d = findDivergenceIndex( origText, spanText ); - spanTextNew = spanText.slice( 0, d ) + origText[d] + origText[d] + '...'; + spanTextNew = spanText.slice( 0, d ) + origText[ d ] + origText[ d ] + '...'; assert.gt( spanTextNew.length, spanText.length, 'Verify that the new span-length is indeed greater' ); diff --git a/tests/qunit/suites/resources/jquery/jquery.color.test.js b/tests/qunit/suites/resources/jquery/jquery.color.test.js index c8e8ac70e0..9afd793e5b 100644 --- a/tests/qunit/suites/resources/jquery/jquery.color.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.color.test.js @@ -10,7 +10,7 @@ $canvas.animate( { backgroundColor: '#000' }, 10 ).promise().then( function () { var endColors = $.colorUtil.getRGB( $canvas.css( 'background-color' ) ); - assert.deepEqual( endColors, [0, 0, 0], 'end state' ); + assert.deepEqual( endColors, [ 0, 0, 0 ], 'end state' ); } ); this.clock.tick( 20 ); diff --git a/tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js b/tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js index 39ae363c61..00de895dad 100644 --- a/tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js @@ -4,25 +4,25 @@ QUnit.test( 'getRGB', 18, function ( assert ) { assert.strictEqual( $.colorUtil.getRGB(), undefined, 'No arguments' ); assert.strictEqual( $.colorUtil.getRGB( '' ), undefined, 'Empty string' ); - assert.deepEqual( $.colorUtil.getRGB( [0, 100, 255] ), [0, 100, 255], 'Parse array of rgb values' ); - assert.deepEqual( $.colorUtil.getRGB( 'rgb(0,100,255)' ), [0, 100, 255], 'Parse simple rgb string' ); - assert.deepEqual( $.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [0, 100, 255], 'Parse simple rgb string with spaces' ); - assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [0, 51, 102], 'Parse rgb string with percentages' ); - assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [0, 51, 102], 'Parse rgb string with percentages and spaces' ); - assert.deepEqual( $.colorUtil.getRGB( '#f2ddee' ), [242, 221, 238], 'Hex string: 6 char lowercase' ); - assert.deepEqual( $.colorUtil.getRGB( '#f2DDEE' ), [242, 221, 238], 'Hex string: 6 char uppercase' ); - assert.deepEqual( $.colorUtil.getRGB( '#f2DdEe' ), [242, 221, 238], 'Hex string: 6 char mixed' ); - assert.deepEqual( $.colorUtil.getRGB( '#eee' ), [238, 238, 238], 'Hex string: 3 char lowercase' ); - assert.deepEqual( $.colorUtil.getRGB( '#EEE' ), [238, 238, 238], 'Hex string: 3 char uppercase' ); - assert.deepEqual( $.colorUtil.getRGB( '#eEe' ), [238, 238, 238], 'Hex string: 3 char mixed' ); - assert.deepEqual( $.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [255, 255, 255], 'Zero rgba for Safari 3; Transparent (whitespace)' ); + assert.deepEqual( $.colorUtil.getRGB( [ 0, 100, 255 ] ), [ 0, 100, 255 ], 'Parse array of rgb values' ); + assert.deepEqual( $.colorUtil.getRGB( 'rgb(0,100,255)' ), [ 0, 100, 255 ], 'Parse simple rgb string' ); + assert.deepEqual( $.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [ 0, 100, 255 ], 'Parse simple rgb string with spaces' ); + assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [ 0, 51, 102 ], 'Parse rgb string with percentages' ); + assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [ 0, 51, 102 ], 'Parse rgb string with percentages and spaces' ); + assert.deepEqual( $.colorUtil.getRGB( '#f2ddee' ), [ 242, 221, 238 ], 'Hex string: 6 char lowercase' ); + assert.deepEqual( $.colorUtil.getRGB( '#f2DDEE' ), [ 242, 221, 238 ], 'Hex string: 6 char uppercase' ); + assert.deepEqual( $.colorUtil.getRGB( '#f2DdEe' ), [ 242, 221, 238 ], 'Hex string: 6 char mixed' ); + assert.deepEqual( $.colorUtil.getRGB( '#eee' ), [ 238, 238, 238 ], 'Hex string: 3 char lowercase' ); + assert.deepEqual( $.colorUtil.getRGB( '#EEE' ), [ 238, 238, 238 ], 'Hex string: 3 char uppercase' ); + assert.deepEqual( $.colorUtil.getRGB( '#eEe' ), [ 238, 238, 238 ], 'Hex string: 3 char mixed' ); + assert.deepEqual( $.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [ 255, 255, 255 ], 'Zero rgba for Safari 3; Transparent (whitespace)' ); // Perhaps this is a bug in colorUtil, but it is the current behavior so, let's keep // track of it, so we will know in case it would ever change. assert.strictEqual( $.colorUtil.getRGB( 'rgba(0,0,0,0)' ), undefined, 'Zero rgba without whitespace' ); - assert.deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' ); - assert.deepEqual( $.colorUtil.getRGB( 'transparent' ), [255, 255, 255], 'Color names (transparent)' ); + assert.deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [ 144, 238, 144 ], 'Color names (lightGreen)' ); + assert.deepEqual( $.colorUtil.getRGB( 'transparent' ), [ 255, 255, 255 ], 'Color names (transparent)' ); assert.strictEqual( $.colorUtil.getRGB( 'mediaWiki' ), undefined, 'Inexisting color name' ); } ); @@ -37,9 +37,9 @@ // Re-create the rgbToHsl return array items, limited to two decimals. hsl = $.colorUtil.rgbToHsl( 144, 238, 144 ); - ret = [ dualDecimals( hsl[0] ), dualDecimals( hsl[1] ), dualDecimals( hsl[2] ) ]; + ret = [ dualDecimals( hsl[ 0 ] ), dualDecimals( hsl[ 1 ] ), dualDecimals( hsl[ 2 ] ) ]; - assert.deepEqual( ret, [0.33, 0.73, 0.75], 'rgb(144, 238, 144): hsl(0.33, 0.73, 0.75)' ); + assert.deepEqual( ret, [ 0.33, 0.73, 0.75 ], 'rgb(144, 238, 144): hsl(0.33, 0.73, 0.75)' ); } ); QUnit.test( 'hslToRgb', 1, function ( assert ) { @@ -47,9 +47,9 @@ rgb = $.colorUtil.hslToRgb( 0.3, 0.7, 0.8 ); // Re-create the hslToRgb return array items, rounded to whole numbers. - ret = [ Math.round( rgb[0] ), Math.round( rgb[1] ), Math.round( rgb[2] ) ]; + ret = [ Math.round( rgb[ 0 ] ), Math.round( rgb[ 1 ] ), Math.round( rgb[ 2 ] ) ]; - assert.deepEqual( ret, [183, 240, 168], 'hsl(0.3, 0.7, 0.8): rgb(183, 240, 168)' ); + assert.deepEqual( ret, [ 183, 240, 168 ], 'hsl(0.3, 0.7, 0.8): rgb(183, 240, 168)' ); } ); QUnit.test( 'getColorBrightness', 2, function ( assert ) { diff --git a/tests/qunit/suites/resources/jquery/jquery.localize.test.js b/tests/qunit/suites/resources/jquery/jquery.localize.test.js index 3ef27903ba..786b9f6841 100644 --- a/tests/qunit/suites/resources/jquery/jquery.localize.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.localize.test.js @@ -88,7 +88,7 @@ html = '
      '; $lc = $( html ).localize( { params: { - 'foo-welcome': [sitename, 'yesterday'] + 'foo-welcome': [ sitename, 'yesterday' ] } } ).find( 'span' ); @@ -104,8 +104,8 @@ 'label': x + '-label' }, params: { - 'title': [sitename, '3 minutes ago'], - 'label': [sitename, '3 minutes ago'] + 'title': [ sitename, '3 minutes ago' ], + 'label': [ sitename, '3 minutes ago' ] } } ).find( 'span' ); diff --git a/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js b/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js index 1be8e0c8f1..029edd5587 100644 --- a/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js @@ -52,9 +52,9 @@ } ); QUnit.test( 'Comparison functions', 5, function ( assert ) { - assert.ok( $.compareArray( [0, 'a', [], [2, 'b'] ], [0, 'a', [], [2, 'b'] ] ), + assert.ok( $.compareArray( [ 0, 'a', [], [ 2, 'b' ] ], [ 0, 'a', [], [ 2, 'b' ] ] ), 'compareArray: Two deep arrays that are excactly the same' ); - assert.ok( !$.compareArray( [1], [2] ), 'compareArray: Two different arrays (false)' ); + assert.ok( !$.compareArray( [ 1 ], [ 2 ] ), 'compareArray: Two different arrays (false)' ); assert.ok( $.compareObject( {}, {} ), 'compareObject: Two empty objects' ); assert.ok( $.compareObject( { foo: 1 }, { foo: 1 } ), 'compareObject: Two the same objects' ); diff --git a/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js b/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js index 23ad9d989c..5d0ddebb98 100644 --- a/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js @@ -22,7 +22,7 @@ '', testElement = function ( $el, assert ) { - var el = $el[0], + var el = $el[ 0 ], placeholder = el.getAttribute( 'placeholder' ); assert.strictEqual( $el.placeholder(), $el, 'should be chainable' ); @@ -97,14 +97,14 @@ var selector = '#input-type-password', $el = $( selector ), - el = $el[0], + el = $el[ 0 ], placeholder = el.getAttribute( 'placeholder' ); assert.strictEqual( $el.placeholder(), $el, 'should be chainable' ); // Re-select the element, as it gets replaced by another one in some browsers $el = $( selector ); - el = $el[0]; + el = $el[ 0 ]; assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); @@ -116,7 +116,7 @@ // Re-select the element, as it gets replaced by another one in some browsers $el = $( selector ); - el = $el[0]; + el = $el[ 0 ]; assert.strictEqual( el.value, '', '`value` should be the empty string on focus' ); assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); @@ -128,7 +128,7 @@ // Re-select the element, as it gets replaced by another one in some browsers $el = $( selector ); - el = $el[0]; + el = $el[ 0 ]; assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js index cc1e6df8a7..c0da824bbf 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js @@ -13,19 +13,19 @@ this.liveMonths = mw.language.months; mw.language.months = { 'keys': { - 'names': ['january', 'february', 'march', 'april', 'may_long', 'june', - 'july', 'august', 'september', 'october', 'november', 'december'], - 'genitive': ['january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen', - 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen'], - 'abbrev': ['jan', 'feb', 'mar', 'apr', 'may', 'jun', - 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'] + 'names': [ 'january', 'february', 'march', 'april', 'may_long', 'june', + 'july', 'august', 'september', 'october', 'november', 'december' ], + 'genitive': [ 'january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen', + 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen' ], + 'abbrev': [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', + 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ] }, - 'names': ['January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December'], - 'genitive': ['January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December'], - 'abbrev': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] + 'names': [ 'January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December' ], + 'genitive': [ 'January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December' ], + 'abbrev': [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] }; }, teardown: function () { @@ -36,8 +36,8 @@ /* default date format of the content language */ wgDefaultDateFormat: 'dmy', /* These two are important for numeric interpretations */ - wgSeparatorTransformTable: ['', ''], - wgDigitTransformTable: ['', ''] + wgSeparatorTransformTable: [ '', '' ], + wgDigitTransformTable: [ '', '' ] } } ) ); @@ -63,11 +63,11 @@ parser = $.tablesorter.getParser( parserId ); $.each( data, function ( index, testcase ) { - extractedR = parser.is( testcase[0] ); - extractedF = parser.format( testcase[0] ); + extractedR = parser.is( testcase[ 0 ] ); + extractedF = parser.format( testcase[ 0 ] ); - assert.strictEqual( extractedR, testcase[1], 'Detect: ' + testcase[3] ); - assert.strictEqual( extractedF, testcase[2], 'Sortkey: ' + testcase[3] ); + assert.strictEqual( extractedR, testcase[ 1 ], 'Detect: ' + testcase[ 3 ] ); + assert.strictEqual( extractedF, testcase[ 2 ], 'Sortkey: ' + testcase[ 3 ] ); } ); } ); @@ -82,37 +82,37 @@ ipv4 = [ // Some randomly generated fake IPs - ['0.0.0.0', true, 0, 'An IP address' ], - ['255.255.255.255', true, 255255255255, 'An IP address' ], - ['45.238.27.109', true, 45238027109, 'An IP address' ], - ['1.238.27.1', true, 1238027001, 'An IP address with small numbers' ], - ['238.27.1', false, 238027001, 'A malformed IP Address' ], - ['1', false, 1, 'A super malformed IP Address' ], - ['Just text', false, 0, 'A line with just text' ], - ['45.238.27.109Postfix', false, 45238027109, 'An IP address with a connected postfix' ], - ['45.238.27.109 postfix', false, 45238027109, 'An IP address with a seperated postfix' ] + [ '0.0.0.0', true, 0, 'An IP address' ], + [ '255.255.255.255', true, 255255255255, 'An IP address' ], + [ '45.238.27.109', true, 45238027109, 'An IP address' ], + [ '1.238.27.1', true, 1238027001, 'An IP address with small numbers' ], + [ '238.27.1', false, 238027001, 'A malformed IP Address' ], + [ '1', false, 1, 'A super malformed IP Address' ], + [ 'Just text', false, 0, 'A line with just text' ], + [ '45.238.27.109Postfix', false, 45238027109, 'An IP address with a connected postfix' ], + [ '45.238.27.109 postfix', false, 45238027109, 'An IP address with a seperated postfix' ] ]; parserTest( 'IPv4', 'IPAddress', ipv4 ); simpleMDYDatesInMDY = [ - ['January 17, 2010', true, 20100117, 'Long middle endian date'], - ['Jan 17, 2010', true, 20100117, 'Short middle endian date'], - ['1/17/2010', true, 20100117, 'Numeric middle endian date'], - ['01/17/2010', true, 20100117, 'Numeric middle endian date with padding on month'], - ['01/07/2010', true, 20100107, 'Numeric middle endian date with padding on day'], - ['01/07/0010', true, 20100107, 'Numeric middle endian date with padding on year'], - ['5.12.1990', true, 19900512, 'Numeric middle endian date with . separator'] + [ 'January 17, 2010', true, 20100117, 'Long middle endian date' ], + [ 'Jan 17, 2010', true, 20100117, 'Short middle endian date' ], + [ '1/17/2010', true, 20100117, 'Numeric middle endian date' ], + [ '01/17/2010', true, 20100117, 'Numeric middle endian date with padding on month' ], + [ '01/07/2010', true, 20100107, 'Numeric middle endian date with padding on day' ], + [ '01/07/0010', true, 20100107, 'Numeric middle endian date with padding on year' ], + [ '5.12.1990', true, 19900512, 'Numeric middle endian date with . separator' ] ]; parserTest( 'MDY Dates using mdy content language', 'date', simpleMDYDatesInMDY ); simpleMDYDatesInDMY = [ - ['January 17, 2010', true, 20100117, 'Long middle endian date'], - ['Jan 17, 2010', true, 20100117, 'Short middle endian date'], - ['1/17/2010', true, 20101701, 'Numeric middle endian date'], - ['01/17/2010', true, 20101701, 'Numeric middle endian date with padding on month'], - ['01/07/2010', true, 20100701, 'Numeric middle endian date with padding on day'], - ['01/07/0010', true, 20100701, 'Numeric middle endian date with padding on year'], - ['5.12.1990', true, 19901205, 'Numeric middle endian date with . separator'] + [ 'January 17, 2010', true, 20100117, 'Long middle endian date' ], + [ 'Jan 17, 2010', true, 20100117, 'Short middle endian date' ], + [ '1/17/2010', true, 20101701, 'Numeric middle endian date' ], + [ '01/17/2010', true, 20101701, 'Numeric middle endian date with padding on month' ], + [ '01/07/2010', true, 20100701, 'Numeric middle endian date with padding on day' ], + [ '01/07/0010', true, 20100701, 'Numeric middle endian date with padding on year' ], + [ '5.12.1990', true, 19901205, 'Numeric middle endian date with . separator' ] ]; parserTest( 'MDY Dates using dmy content language', 'date', simpleMDYDatesInDMY, function () { mw.config.set( { @@ -122,99 +122,99 @@ } ); oldMDYDates = [ - ['January 19, 1400 BC', false, '99999999', 'BC'], - ['January 19, 1400BC', false, '99999999', 'Connected BC'], - ['January, 19 1400 B.C.', false, '99999999', 'B.C.'], - ['January 19, 1400 AD', false, '99999999', 'AD'], - ['January, 19 10', true, 20100119, 'AD'], - ['January, 19 1', false, '99999999', 'AD'] + [ 'January 19, 1400 BC', false, '99999999', 'BC' ], + [ 'January 19, 1400BC', false, '99999999', 'Connected BC' ], + [ 'January, 19 1400 B.C.', false, '99999999', 'B.C.' ], + [ 'January 19, 1400 AD', false, '99999999', 'AD' ], + [ 'January, 19 10', true, 20100119, 'AD' ], + [ 'January, 19 1', false, '99999999', 'AD' ] ]; parserTest( 'Very old MDY dates', 'date', oldMDYDates ); complexMDYDates = [ - ['January, 19 2010', true, 20100119, 'Comma after month'], - ['January 19, 2010', true, 20100119, 'Comma after day'], - ['January/19/2010', true, 20100119, 'Forward slash separator'], - ['04 22 1991', true, 19910422, 'Month with 0 padding'], - ['April 21 1991', true, 19910421, 'Space separation'], - ['04 22 1991', true, 19910422, 'Month with 0 padding'], - ['December 12 \'10', true, 20101212, ''], - ['Dec 12 \'10', true, 20101212, ''], - ['Dec. 12 \'10', true, 20101212, ''] + [ 'January, 19 2010', true, 20100119, 'Comma after month' ], + [ 'January 19, 2010', true, 20100119, 'Comma after day' ], + [ 'January/19/2010', true, 20100119, 'Forward slash separator' ], + [ '04 22 1991', true, 19910422, 'Month with 0 padding' ], + [ 'April 21 1991', true, 19910421, 'Space separation' ], + [ '04 22 1991', true, 19910422, 'Month with 0 padding' ], + [ 'December 12 \'10', true, 20101212, '' ], + [ 'Dec 12 \'10', true, 20101212, '' ], + [ 'Dec. 12 \'10', true, 20101212, '' ] ]; parserTest( 'MDY Dates', 'date', complexMDYDates ); clobberedDates = [ - ['January, 19 2010 - January, 20 2010', false, '99999999', 'Date range with hyphen'], - ['January, 19 2010 — January, 20 2010', false, '99999999', 'Date range with mdash'], - ['prefixJanuary, 19 2010', false, '99999999', 'Connected prefix'], - ['prefix January, 19 2010', false, '99999999', 'Prefix'], - ['December 12 2010postfix', false, '99999999', 'ConnectedPostfix'], - ['December 12 2010 postfix', false, '99999999', 'Postfix'], - ['A simple text', false, '99999999', 'Plain text in date sort'], - ['04l22l1991', false, '99999999', 'l char as separator'], - ['January\\19\\2010', false, '99999999', 'backslash as date separator'] + [ 'January, 19 2010 - January, 20 2010', false, '99999999', 'Date range with hyphen' ], + [ 'January, 19 2010 — January, 20 2010', false, '99999999', 'Date range with mdash' ], + [ 'prefixJanuary, 19 2010', false, '99999999', 'Connected prefix' ], + [ 'prefix January, 19 2010', false, '99999999', 'Prefix' ], + [ 'December 12 2010postfix', false, '99999999', 'ConnectedPostfix' ], + [ 'December 12 2010 postfix', false, '99999999', 'Postfix' ], + [ 'A simple text', false, '99999999', 'Plain text in date sort' ], + [ '04l22l1991', false, '99999999', 'l char as separator' ], + [ 'January\\19\\2010', false, '99999999', 'backslash as date separator' ] ]; parserTest( 'Clobbered Dates', 'date', clobberedDates ); MYDates = [ - ['December 2010', false, '99999999', 'Plain month year'], - ['Dec 2010', false, '99999999', 'Abreviated month year'], - ['12 2010', false, '99999999', 'Numeric month year'] + [ 'December 2010', false, '99999999', 'Plain month year' ], + [ 'Dec 2010', false, '99999999', 'Abreviated month year' ], + [ '12 2010', false, '99999999', 'Numeric month year' ] ]; parserTest( 'MY Dates', 'date', MYDates ); YDates = [ - ['2010', false, '99999999', 'Plain 4-digit year'], - ['876', false, '99999999', '3-digit year'], - ['76', false, '99999999', '2-digit year'], - ['\'76', false, '99999999', '2-digit millenium bug year'], - ['2010 BC', false, '99999999', '4-digit year BC'] + [ '2010', false, '99999999', 'Plain 4-digit year' ], + [ '876', false, '99999999', '3-digit year' ], + [ '76', false, '99999999', '2-digit year' ], + [ '\'76', false, '99999999', '2-digit millenium bug year' ], + [ '2010 BC', false, '99999999', '4-digit year BC' ] ]; parserTest( 'Y Dates', 'date', YDates ); currencyData = [ - ['1.02 $', true, 1.02, ''], - ['$ 3.00', true, 3, ''], - ['€ 2,99', true, 299, ''], - ['$ 1.00', true, 1, ''], - ['$3.50', true, 3.50, ''], - ['$ 1.50', true, 1.50, ''], - ['€ 0.99', true, 0.99, ''], - ['$ 299.99', true, 299.99, ''], - ['$ 2,299.99', true, 2299.99, ''], - ['$ 2,989', true, 2989, ''], - ['$ 2 299.99', true, 2299.99, ''], - ['$ 2 989', true, 2989, ''], - ['$ 2.989', true, 2.989, ''] + [ '1.02 $', true, 1.02, '' ], + [ '$ 3.00', true, 3, '' ], + [ '€ 2,99', true, 299, '' ], + [ '$ 1.00', true, 1, '' ], + [ '$3.50', true, 3.50, '' ], + [ '$ 1.50', true, 1.50, '' ], + [ '€ 0.99', true, 0.99, '' ], + [ '$ 299.99', true, 299.99, '' ], + [ '$ 2,299.99', true, 2299.99, '' ], + [ '$ 2,989', true, 2989, '' ], + [ '$ 2 299.99', true, 2299.99, '' ], + [ '$ 2 989', true, 2989, '' ], + [ '$ 2.989', true, 2.989, '' ] ]; parserTest( 'Currency', 'currency', currencyData ); transformedCurrencyData = [ - ['1.02 $', true, 102, ''], - ['$ 3.00', true, 300, ''], - ['€ 2,99', true, 2.99, ''], - ['$ 1.00', true, 100, ''], - ['$3.50', true, 350, ''], - ['$ 1.50', true, 150, ''], - ['€ 0.99', true, 99, ''], - ['$ 299.99', true, 29999, ''], - ['$ 2\'299,99', true, 2299.99, ''], - ['$ 2,989', true, 2.989, ''], - ['$ 2 299.99', true, 229999, ''], - ['2 989 $', true, 2989, ''], - ['299.99 $', true, 29999, ''], - ['2\'299,99 $', true, 2299.99, ''], - ['2,989 $', true, 2.989, ''], - ['2 299.99 $', true, 229999, ''], - ['2 989 $', true, 2989, ''] + [ '1.02 $', true, 102, '' ], + [ '$ 3.00', true, 300, '' ], + [ '€ 2,99', true, 2.99, '' ], + [ '$ 1.00', true, 100, '' ], + [ '$3.50', true, 350, '' ], + [ '$ 1.50', true, 150, '' ], + [ '€ 0.99', true, 99, '' ], + [ '$ 299.99', true, 29999, '' ], + [ '$ 2\'299,99', true, 2299.99, '' ], + [ '$ 2,989', true, 2.989, '' ], + [ '$ 2 299.99', true, 229999, '' ], + [ '2 989 $', true, 2989, '' ], + [ '299.99 $', true, 29999, '' ], + [ '2\'299,99 $', true, 2299.99, '' ], + [ '2,989 $', true, 2.989, '' ], + [ '2 299.99 $', true, 229999, '' ], + [ '2 989 $', true, 2989, '' ] ]; parserTest( 'Currency with european separators', 'currency', transformedCurrencyData, function () { mw.config.set( { // We expect 22'234.444,22 // Map from ascii separators => localized separators - wgSeparatorTransformTable: [', . ,', '\' , .'], - wgDigitTransformTable: ['', ''] + wgSeparatorTransformTable: [ ', . ,', '\' , .' ], + wgDigitTransformTable: [ '', '' ] } ); } ); diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js index 480e12723c..e9ae8c0c68 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js @@ -8,9 +8,9 @@ b1 = [ 'B', '1' ], b2 = [ 'B', '2' ], b3 = [ 'B', '3' ], - simple = [a2, b3, a1, a3, b2, b1], - simpleAsc = [a1, a2, a3, b1, b2, b3], - simpleDescasc = [b1, b2, b3, a1, a2, a3], + simple = [ a2, b3, a1, a3, b2, b1 ], + simpleAsc = [ a1, a2, a3, b1, b2, b3 ], + simpleDescasc = [ b1, b2, b3, a1, a2, a3 ], // Data set "colspan" aaa1 = [ 'A', 'A', 'A', '1' ], @@ -27,9 +27,9 @@ mars = [ 'Mars', '3390.0' ], jupiter = [ 'Jupiter', '69911' ], saturn = [ 'Saturn', '58232' ], - planets = [mercury, venus, earth, mars, jupiter, saturn], - planetsAscName = [earth, jupiter, mars, mercury, saturn, venus], - planetsAscRadius = [mercury, mars, venus, earth, saturn, jupiter], + planets = [ mercury, venus, earth, mars, jupiter, saturn ], + planetsAscName = [ earth, jupiter, mars, mercury, saturn, venus ], + planetsAscRadius = [ mercury, mars, venus, earth, saturn, jupiter ], planetsRowspan, planetsRowspanII, planetsAscNameLegacy, @@ -37,122 +37,122 @@ // Data set "ipv4" ipv4 = [ // Some randomly generated fake IPs - ['45.238.27.109'], - ['44.172.9.22'], - ['247.240.82.209'], - ['204.204.132.158'], - ['170.38.91.162'], - ['197.219.164.9'], - ['45.68.154.72'], - ['182.195.149.80'] + [ '45.238.27.109' ], + [ '44.172.9.22' ], + [ '247.240.82.209' ], + [ '204.204.132.158' ], + [ '170.38.91.162' ], + [ '197.219.164.9' ], + [ '45.68.154.72' ], + [ '182.195.149.80' ] ], ipv4Sorted = [ // Sort order should go octet by octet - ['44.172.9.22'], - ['45.68.154.72'], - ['45.238.27.109'], - ['170.38.91.162'], - ['182.195.149.80'], - ['197.219.164.9'], - ['204.204.132.158'], - ['247.240.82.209'] + [ '44.172.9.22' ], + [ '45.68.154.72' ], + [ '45.238.27.109' ], + [ '170.38.91.162' ], + [ '182.195.149.80' ], + [ '197.219.164.9' ], + [ '204.204.132.158' ], + [ '247.240.82.209' ] ], // Data set "umlaut" umlautWords = [ - ['Günther'], - ['Peter'], - ['Björn'], - ['Bjorn'], - ['Apfel'], - ['Äpfel'], - ['Strasse'], - ['Sträßschen'] + [ 'Günther' ], + [ 'Peter' ], + [ 'Björn' ], + [ 'Bjorn' ], + [ 'Apfel' ], + [ 'Äpfel' ], + [ 'Strasse' ], + [ 'Sträßschen' ] ], umlautWordsSorted = [ - ['Äpfel'], - ['Apfel'], - ['Björn'], - ['Bjorn'], - ['Günther'], - ['Peter'], - ['Sträßschen'], - ['Strasse'] + [ 'Äpfel' ], + [ 'Apfel' ], + [ 'Björn' ], + [ 'Bjorn' ], + [ 'Günther' ], + [ 'Peter' ], + [ 'Sträßschen' ], + [ 'Strasse' ] ], complexMDYDates = [ - ['January, 19 2010'], - ['April 21 1991'], - ['04 22 1991'], - ['5.12.1990'], - ['December 12 \'10'] + [ 'January, 19 2010' ], + [ 'April 21 1991' ], + [ '04 22 1991' ], + [ '5.12.1990' ], + [ 'December 12 \'10' ] ], complexMDYSorted = [ - ['5.12.1990'], - ['April 21 1991'], - ['04 22 1991'], - ['January, 19 2010'], - ['December 12 \'10'] + [ '5.12.1990' ], + [ 'April 21 1991' ], + [ '04 22 1991' ], + [ 'January, 19 2010' ], + [ 'December 12 \'10' ] ], currencyUnsorted = [ - ['1.02 $'], - ['$ 3.00'], - ['€ 2,99'], - ['$ 1.00'], - ['$3.50'], - ['$ 1.50'], - ['€ 0.99'] + [ '1.02 $' ], + [ '$ 3.00' ], + [ '€ 2,99' ], + [ '$ 1.00' ], + [ '$3.50' ], + [ '$ 1.50' ], + [ '€ 0.99' ] ], currencySorted = [ - ['€ 0.99'], - ['$ 1.00'], - ['1.02 $'], - ['$ 1.50'], - ['$ 3.00'], - ['$3.50'], + [ '€ 0.99' ], + [ '$ 1.00' ], + [ '1.02 $' ], + [ '$ 1.50' ], + [ '$ 3.00' ], + [ '$3.50' ], // Comma's sort after dots // Not intentional but test to detect changes - ['€ 2,99'] + [ '€ 2,99' ] ], numbers = [ - [ '12' ], - [ '7' ], - [ '13,000'], - [ '9' ], - [ '14' ], - [ '8.0' ] + [ '12' ], + [ '7' ], + [ '13,000' ], + [ '9' ], + [ '14' ], + [ '8.0' ] ], numbersAsc = [ - [ '7' ], - [ '8.0' ], - [ '9' ], - [ '12' ], - [ '14' ], - [ '13,000'] + [ '7' ], + [ '8.0' ], + [ '9' ], + [ '12' ], + [ '14' ], + [ '13,000' ] ], correctDateSorting1 = [ - ['01 January 2010'], - ['05 February 2010'], - ['16 January 2010'] + [ '01 January 2010' ], + [ '05 February 2010' ], + [ '16 January 2010' ] ], correctDateSortingSorted1 = [ - ['01 January 2010'], - ['16 January 2010'], - ['05 February 2010'] + [ '01 January 2010' ], + [ '16 January 2010' ], + [ '05 February 2010' ] ], correctDateSorting2 = [ - ['January 01 2010'], - ['February 05 2010'], - ['January 16 2010'] + [ 'January 01 2010' ], + [ 'February 05 2010' ], + [ 'January 16 2010' ] ], correctDateSortingSorted2 = [ - ['January 01 2010'], - ['January 16 2010'], - ['February 05 2010'] + [ 'January 01 2010' ], + [ 'January 16 2010' ], + [ 'February 05 2010' ] ]; QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment( { @@ -160,19 +160,19 @@ this.liveMonths = mw.language.months; mw.language.months = { 'keys': { - 'names': ['january', 'february', 'march', 'april', 'may_long', 'june', - 'july', 'august', 'september', 'october', 'november', 'december'], - 'genitive': ['january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen', - 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen'], - 'abbrev': ['jan', 'feb', 'mar', 'apr', 'may', 'jun', - 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'] + 'names': [ 'january', 'february', 'march', 'april', 'may_long', 'june', + 'july', 'august', 'september', 'october', 'november', 'december' ], + 'genitive': [ 'january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen', + 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen' ], + 'abbrev': [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', + 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ] }, - 'names': ['January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December'], - 'genitive': ['January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December'], - 'abbrev': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] + 'names': [ 'January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December' ], + 'genitive': [ 'January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December' ], + 'abbrev': [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] }; }, teardown: function () { @@ -180,8 +180,8 @@ }, config: { wgDefaultDateFormat: 'dmy', - wgSeparatorTransformTable: ['', ''], - wgDigitTransformTable: ['', ''], + wgSeparatorTransformTable: [ '', '' ], + wgDigitTransformTable: [ '', '' ], wgPageContentLanguage: 'en' } } ) ); @@ -210,7 +210,7 @@ for ( i = 0; i < data.length; i++ ) { /*jshint loopfunc: true */ $tr = $( '
    ' ); $td.text( str ).appendTo( $tr ); } ); @@ -302,7 +302,7 @@ } // Sample data set using planets named and their radius - header = [ 'Planet', 'Radius (km)']; + header = [ 'Planet', 'Radius (km)' ]; tableTest( 'Basic planet table: sorting initially - ascending by name', @@ -466,7 +466,7 @@ // Pretend to click while pressing the multi-sort key var event = $.Event( 'click' ); - event[$table.data( 'tablesorter' ).config.sortMultiSortKey] = true; + event[ $table.data( 'tablesorter' ).config.sortMultiSortKey ] = true; $table.find( '.headerSort:eq(1)' ).trigger( event ); } ); @@ -573,22 +573,22 @@ // Regression tests! tableTest( 'Bug 28775: German-style (dmy) short numeric dates', - ['Date'], + [ 'Date' ], [ // German-style dates are day-month-year - ['11.11.2011'], - ['01.11.2011'], - ['02.10.2011'], - ['03.08.2011'], - ['09.11.2011'] + [ '11.11.2011' ], + [ '01.11.2011' ], + [ '02.10.2011' ], + [ '03.08.2011' ], + [ '09.11.2011' ] ], [ // Sorted by ascending date - ['03.08.2011'], - ['02.10.2011'], - ['01.11.2011'], - ['09.11.2011'], - ['11.11.2011'] + [ '03.08.2011' ], + [ '02.10.2011' ], + [ '01.11.2011' ], + [ '09.11.2011' ], + [ '11.11.2011' ] ], function ( $table ) { mw.config.set( 'wgDefaultDateFormat', 'dmy' ); @@ -601,22 +601,22 @@ tableTest( 'Bug 28775: American-style (mdy) short numeric dates', - ['Date'], + [ 'Date' ], [ // American-style dates are month-day-year - ['11.11.2011'], - ['01.11.2011'], - ['02.10.2011'], - ['03.08.2011'], - ['09.11.2011'] + [ '11.11.2011' ], + [ '01.11.2011' ], + [ '02.10.2011' ], + [ '03.08.2011' ], + [ '09.11.2011' ] ], [ // Sorted by ascending date - ['01.11.2011'], - ['02.10.2011'], - ['03.08.2011'], - ['09.11.2011'], - ['11.11.2011'] + [ '01.11.2011' ], + [ '02.10.2011' ], + [ '03.08.2011' ], + [ '09.11.2011' ], + [ '11.11.2011' ] ], function ( $table ) { mw.config.set( 'wgDefaultDateFormat', 'mdy' ); @@ -628,7 +628,7 @@ tableTest( 'Bug 17141: IPv4 address sorting', - ['IP'], + [ 'IP' ], ipv4, ipv4Sorted, function ( $table ) { @@ -638,7 +638,7 @@ ); tableTest( 'Bug 17141: IPv4 address sorting (reverse)', - ['IP'], + [ 'IP' ], ipv4, reversed( ipv4Sorted ), function ( $table ) { @@ -649,7 +649,7 @@ tableTest( 'Accented Characters with custom collation', - ['Name'], + [ 'Name' ], umlautWords, umlautWordsSorted, function ( $table ) { @@ -749,7 +749,7 @@ tableTest( 'Complex date parsing I', - ['date'], + [ 'date' ], complexMDYDates, complexMDYSorted, function ( $table ) { @@ -762,7 +762,7 @@ tableTest( 'Currency parsing I', - ['currency'], + [ 'currency' ], currencyUnsorted, currencySorted, function ( $table ) { @@ -772,7 +772,7 @@ ); planetsAscNameLegacy = planetsAscName.slice( 0 ); - planetsAscNameLegacy[4] = planetsAscNameLegacy[5]; + planetsAscNameLegacy[ 4 ] = planetsAscNameLegacy[ 5 ]; planetsAscNameLegacy.pop(); tableTest( @@ -801,7 +801,7 @@ $table.find( '.headerSort:eq(0)' ).click(); assert.equal( - $table.data( 'tablesorter' ).config.parsers[0].id, + $table.data( 'tablesorter' ).config.parsers[ 0 ].id, 'number', 'Correctly detected column content skipping sortbottom' ); @@ -989,7 +989,7 @@ } ); tableTest( 'bug 8115: sort numbers with commas (ascending)', - ['Numbers'], numbers, numbersAsc, + [ 'Numbers' ], numbers, numbersAsc, function ( $table ) { $table.tablesorter(); $table.find( '.headerSort:eq(0)' ).click(); @@ -997,7 +997,7 @@ ); tableTest( 'bug 8115: sort numbers with commas (descending)', - ['Numbers'], numbers, reversed( numbersAsc ), + [ 'Numbers' ], numbers, reversed( numbersAsc ), function ( $table ) { $table.tablesorter(); $table.find( '.headerSort:eq(0)' ).click().click(); @@ -1032,7 +1032,7 @@ tableTest( 'Correct date sorting I', - ['date'], + [ 'date' ], correctDateSorting1, correctDateSortingSorted1, function ( $table ) { @@ -1045,7 +1045,7 @@ tableTest( 'Correct date sorting II', - ['date'], + [ 'date' ], correctDateSorting2, correctDateSortingSorted2, function ( $table ) { diff --git a/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js b/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js index 4bf44b079c..ad229acff8 100644 --- a/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js @@ -237,8 +237,8 @@ } pos = $textarea.textSelection( 'getCaretPosition', { startAndEnd: true } ); - among( pos[0], options.start, 'Caret start should be where we set it.' ); - among( pos[1], options.end, 'Caret end should be where we set it.' ); + among( pos[ 0 ], options.start, 'Caret start should be where we set it.' ); + among( pos[ 1 ], options.end, 'Caret end should be where we set it.' ); } ); } diff --git a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js index 26b6f570e6..803345835e 100644 --- a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js +++ b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js @@ -14,7 +14,7 @@ function sequence( responses ) { var i = 0; return function ( request ) { - var response = responses[i]; + var response = responses[ i ]; if ( response ) { i++; request.respond.apply( request, response ); @@ -24,7 +24,7 @@ function sequenceBodies( status, headers, bodies ) { jQuery.each( bodies, function ( i, body ) { - bodies[i] = [ status, headers, body ]; + bodies[ i ] = [ status, headers, body ]; } ); return sequence( bodies ); } @@ -268,7 +268,7 @@ } ); assert.equal( this.server.requests.length, 2, 'Request made' ); - assert.equal( this.server.requests[0].requestHeaders['X-Foo'], 'Bar', 'Header sent' ); + assert.equal( this.server.requests[ 0 ].requestHeaders[ 'X-Foo' ], 'Bar', 'Header sent' ); } ); QUnit.test( 'postWithToken() - badtoken', function ( assert ) { diff --git a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.upload.test.js b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.upload.test.js index 1afbd35e85..030e703e7b 100644 --- a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.upload.test.js +++ b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.upload.test.js @@ -18,7 +18,7 @@ return $.Deferred().promise(); } ); - api.uploadWithIframe( $( '' )[0], { filename: 'Testing API upload.jpg' } ); + api.uploadWithIframe( $( '' )[ 0 ], { filename: 'Testing API upload.jpg' } ); $iframe = $( 'iframe' ); $form = $( 'form.mw-api-upload-form' ); diff --git a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.watch.test.js b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.watch.test.js index 5965ab7b4f..64a5184711 100644 --- a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.watch.test.js +++ b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.watch.test.js @@ -17,12 +17,12 @@ } ); api.watch( [ 'Foo' ] ).done( function ( items ) { - assert.equal( items[0].title, 'Foo' ); + assert.equal( items[ 0 ].title, 'Foo' ); } ); api.watch( [ 'Foo', 'Bar' ] ).done( function ( items ) { - assert.equal( items[0].title, 'Foo' ); - assert.equal( items[1].title, 'Bar' ); + assert.equal( items[ 0 ].title, 'Foo' ); + assert.equal( items[ 1 ].title, 'Bar' ); } ); // Requests are POST, match requestBody instead of url diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js index 253ac39bb5..225b5f10de 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js @@ -134,14 +134,14 @@ QUnit.test( 'constructor', cases.invalid.length, function ( assert ) { var i, title; for ( i = 0; i < cases.valid.length; i++ ) { - title = new mw.Title( cases.valid[i] ); + title = new mw.Title( cases.valid[ i ] ); } for ( i = 0; i < cases.invalid.length; i++ ) { /*jshint loopfunc:true */ - title = cases.invalid[i]; + title = cases.invalid[ i ]; assert.throws( function () { return new mw.Title( title ); - }, cases.invalid[i] ); + }, cases.invalid[ i ] ); } } ); @@ -149,16 +149,16 @@ var i; for ( i = 0; i < cases.valid.length; i++ ) { assert.equal( - $.type( mw.Title.newFromText( cases.valid[i] ) ), + $.type( mw.Title.newFromText( cases.valid[ i ] ) ), 'object', - cases.valid[i] + cases.valid[ i ] ); } for ( i = 0; i < cases.invalid.length; i++ ) { assert.equal( - $.type( mw.Title.newFromText( cases.invalid[i] ) ), + $.type( mw.Title.newFromText( cases.invalid[ i ] ) ), 'null', - cases.invalid[i] + cases.invalid[ i ] ); } } ); @@ -277,7 +277,7 @@ assert.equal( title.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' ); // $wgCapitalLinks = false; - mw.config.set( 'wgCaseSensitiveNamespaces', [0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15] ); + mw.config.set( 'wgCaseSensitiveNamespaces', [ 0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15 ] ); title = new mw.Title( 'article' ); assert.equal( title.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' ); @@ -320,8 +320,8 @@ assert.strictEqual( title.exists(), null, 'Return null with empty existance registry' ); // Basic registry, checks default to boolean - mw.Title.exist.set( ['Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules'], true ); - mw.Title.exist.set( ['Does_not_exist', 'User:John', 'Foobar'], false ); + mw.Title.exist.set( [ 'Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules' ], true ); + mw.Title.exist.set( [ 'Does_not_exist', 'User:John', 'Foobar' ], false ); title = new mw.Title( 'Project:Sandbox rules' ); assert.assertTrue( title.exists(), 'Return true for page titles marked as existing' ); @@ -431,7 +431,7 @@ ]; for ( i = 0; i < cases.length; i++ ) { - thisCase = cases[i]; + thisCase = cases[ i ]; title = mw.Title.newFromImg( { src: thisCase.url } ); if ( thisCase.nameText !== undefined ) { @@ -478,7 +478,7 @@ ]; for ( i = 0; i < cases.length; i++ ) { - thisCase = cases[i]; + thisCase = cases[ i ]; title = mw.Title.newFromText( thisCase.text ); assert.equal( title.getRelativeText( thisCase.relativeTo ), thisCase.expectedResult ); @@ -521,7 +521,7 @@ ]; for ( i = 0; i < cases.length; i++ ) { - thisCase = cases[i]; + thisCase = cases[ i ]; title = mw.Title.newFromUserInput( thisCase.title, thisCase.defaultNamespace, thisCase.options ); if ( thisCase.expected !== undefined ) { @@ -643,7 +643,7 @@ ]; for ( i = 0; i < cases.length; i++ ) { - thisCase = cases[i]; + thisCase = cases[ i ]; title = mw.Title.newFromFileName( thisCase.fileName, thisCase.extensionDesired ); if ( thisCase.nameText !== undefined ) { diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js index ba36655382..aa66907903 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js @@ -11,7 +11,7 @@ } } ) ); - $.each( [true, false], function ( i, strictMode ) { + $.each( [ true, false ], function ( i, strictMode ) { QUnit.test( 'Basic construction and properties (' + ( strictMode ? '' : 'non-' ) + 'strict mode)', 2, function ( assert ) { var uriString, uri; uriString = 'http://www.ietf.org/rfc/rfc2396.txt'; @@ -76,8 +76,8 @@ } ); assert.strictEqual( uri.query.n, '1', 'Simple parameter with overrideKeys:false' ); - assert.strictEqual( uri.query.m[0], 'foo', 'Order of multi-value parameters with overrideKeys:true' ); - assert.strictEqual( uri.query.m[1], 'bar', 'Order of multi-value parameters with overrideKeys:true' ); + assert.strictEqual( uri.query.m[ 0 ], 'foo', 'Order of multi-value parameters with overrideKeys:true' ); + assert.strictEqual( uri.query.m[ 1 ], 'bar', 'Order of multi-value parameters with overrideKeys:true' ); assert.strictEqual( uri.query.m.length, 2, 'Number of mult-value field is correct' ); uri = new mw.Uri( 'ftp://usr:pwd@192.0.2.16/' ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.cldr.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.cldr.test.js index 779a0ed48d..399db91430 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.cldr.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.cldr.test.js @@ -65,9 +65,9 @@ QUnit.test( 'Plural Test for ' + langCode, tests.length, function ( assert ) { for ( var i = 0; i < tests.length; i++ ) { assert.equal( - mw.language.convertPlural( tests[i][0], tests[i][1] ), - tests[i][2], - tests[i][3] + mw.language.convertPlural( tests[ i ][ 0 ], tests[ i ][ 1 ] ), + tests[ i ][ 2 ], + tests[ i ][ 3 ] ); } } ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.cookie.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.cookie.test.js index f5f199ea9c..7a13f0f7f2 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.cookie.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.cookie.test.js @@ -102,7 +102,7 @@ } ); call = $.cookie.lastCall.args; - assert.strictEqual( call[0], 'myPrefixfoo' ); + assert.strictEqual( call[ 0 ], 'myPrefixfoo' ); assert.deepEqual( call[ 2 ], { expires: expiryDate, domain: 'myDomain', @@ -122,7 +122,7 @@ } ); call = $.cookie.lastCall.args; - assert.strictEqual( call[0], 'myPrefixfoo' ); + assert.strictEqual( call[ 0 ], 'myPrefixfoo' ); assert.deepEqual( call[ 2 ], { expires: date, domain: 'myDomain', diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js index 778836068c..a10502249e 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js @@ -70,7 +70,7 @@ */ function getMwLanguage( langCode ) { if ( !hasOwn.call( mwLanguageCache, langCode ) ) { - mwLanguageCache[langCode] = $.ajax( { + mwLanguageCache[ langCode ] = $.ajax( { url: mw.util.wikiScript( 'load' ), data: { skin: mw.config.get( 'skin' ), @@ -88,7 +88,7 @@ return mw.language; } ); } - return mwLanguageCache[langCode]; + return mwLanguageCache[ langCode ]; } /** @@ -402,14 +402,14 @@ QUnit.test( 'Curly brace transformation', 16, function ( assert ) { var oldUserLang = mw.config.get( 'wgUserLanguage' ); - assertBothModes( assert, ['gender-msg', 'Bob', 'male'], 'Bob: blue', 'gender is resolved' ); + assertBothModes( assert, [ 'gender-msg', 'Bob', 'male' ], 'Bob: blue', 'gender is resolved' ); - assertBothModes( assert, ['plural-msg', 5], 'Found 5 items', 'plural is resolved' ); + assertBothModes( assert, [ 'plural-msg', 5 ], 'Found 5 items', 'plural is resolved' ); - assertBothModes( assert, ['grammar-msg'], 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'grammar is resolved' ); + assertBothModes( assert, [ 'grammar-msg' ], 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'grammar is resolved' ); mw.config.set( 'wgUserLanguage', 'en' ); - assertBothModes( assert, ['formatnum-msg', '987654321.654321'], '987,654,321.654', 'formatnum is resolved' ); + assertBothModes( assert, [ 'formatnum-msg', '987654321.654321' ], '987,654,321.654', 'formatnum is resolved' ); // Test non-{{ wikitext, where behavior differs @@ -530,7 +530,7 @@ outerCalled = false; innerCalled = false; message = mw.message( key ); - message[format](); + message[ format ](); assert.strictEqual( outerCalled, shouldCall, 'Outer function called for ' + key ); assert.strictEqual( innerCalled, shouldCall, 'Inner function called for ' + key ); } @@ -682,16 +682,16 @@ QUnit.test( 'HTML', 26, function ( assert ) { mw.messages.set( 'jquerymsg-italics-msg', 'Very important' ); - assertBothModes( assert, ['jquerymsg-italics-msg'], mw.messages.get( 'jquerymsg-italics-msg' ), 'Simple italics unchanged' ); + assertBothModes( assert, [ 'jquerymsg-italics-msg' ], mw.messages.get( 'jquerymsg-italics-msg' ), 'Simple italics unchanged' ); mw.messages.set( 'jquerymsg-bold-msg', 'Strong speaker' ); - assertBothModes( assert, ['jquerymsg-bold-msg'], mw.messages.get( 'jquerymsg-bold-msg' ), 'Simple bold unchanged' ); + assertBothModes( assert, [ 'jquerymsg-bold-msg' ], mw.messages.get( 'jquerymsg-bold-msg' ), 'Simple bold unchanged' ); mw.messages.set( 'jquerymsg-bold-italics-msg', 'It is key' ); - assertBothModes( assert, ['jquerymsg-bold-italics-msg'], mw.messages.get( 'jquerymsg-bold-italics-msg' ), 'Bold and italics nesting order preserved' ); + assertBothModes( assert, [ 'jquerymsg-bold-italics-msg' ], mw.messages.get( 'jquerymsg-bold-italics-msg' ), 'Bold and italics nesting order preserved' ); mw.messages.set( 'jquerymsg-italics-bold-msg', 'It is vital' ); - assertBothModes( assert, ['jquerymsg-italics-bold-msg'], mw.messages.get( 'jquerymsg-italics-bold-msg' ), 'Italics and bold nesting order preserved' ); + assertBothModes( assert, [ 'jquerymsg-italics-bold-msg' ], mw.messages.get( 'jquerymsg-italics-bold-msg' ), 'Italics and bold nesting order preserved' ); mw.messages.set( 'jquerymsg-italics-with-link', 'An italicized [[link|wiki-link]]' ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js index 670914ebac..6615bfa78a 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js @@ -51,9 +51,9 @@ for ( var i = 0; i < test.length; i++ ) { assert.equal( - mw.language.convertGrammar( test[i].word, test[i].grammarForm ), - test[i].expected, - test[i].description + mw.language.convertGrammar( test[ i ].word, test[ i ].grammarForm ), + test[ i ].expected, + test[ i ].description ); } } ); @@ -481,8 +481,8 @@ QUnit.test( 'List to text test', 4, function ( assert ) { assert.equal( mw.language.listToText( [] ), '', 'Blank list' ); - assert.equal( mw.language.listToText( ['a'] ), 'a', 'Single item' ); - assert.equal( mw.language.listToText( ['a', 'b'] ), 'a and b', 'Two items' ); - assert.equal( mw.language.listToText( ['a', 'b', 'c'] ), 'a, b and c', 'More than two items' ); + assert.equal( mw.language.listToText( [ 'a' ] ), 'a', 'Single item' ); + assert.equal( mw.language.listToText( [ 'a', 'b' ] ), 'a and b', 'Two items' ); + assert.equal( mw.language.listToText( [ 'a', 'b', 'c' ] ), 'a, b and c', 'More than two items' ); } ); }( mediaWiki, jQuery ) ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.messagePoster.factory.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.messagePoster.factory.test.js index 61bab03f69..288b527b64 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.messagePoster.factory.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.messagePoster.factory.test.js @@ -12,7 +12,7 @@ mw.messagePoster.factory.register( TEST_MODEL, testMessagePosterConstructor ); assert.strictEqual( - mw.messagePoster.factory.contentModelToClass[TEST_MODEL], + mw.messagePoster.factory.contentModelToClass[ TEST_MODEL ], testMessagePosterConstructor, 'Constructor is registered' ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js index 25db28aed5..fd3f99073a 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js @@ -113,14 +113,14 @@ 'MediaWiki': true }; assert.strictEqual( conf.set( someValues ), true, 'Map.set returns boolean true if multiple values were set by passing an object' ); - assert.deepEqual( conf.get( ['foo', 'lorem'] ), { + assert.deepEqual( conf.get( [ 'foo', 'lorem' ] ), { 'foo': 'bar', 'lorem': 'ipsum' }, 'Map.get returns multiple values correctly as an object' ); assert.deepEqual( conf, new mw.Map( conf.values ), 'new mw.Map maps over existing values-bearing object' ); - assert.deepEqual( conf.get( ['foo', 'notExist'] ), { + assert.deepEqual( conf.get( [ 'foo', 'notExist' ] ), { 'foo': 'bar', 'notExist': null }, 'Map.get return includes keys that were not found as null values' ); @@ -175,8 +175,8 @@ len = formats.length; for ( i = 0; i < len; i++ ) { - format = formats[i]; - assert.equal( mw.message.apply( null, messageArguments )[format](), expectedResult, assertMessage + ' when format is ' + format ); + format = formats[ i ]; + assert.equal( mw.message.apply( null, messageArguments )[ format ](), expectedResult, assertMessage + ' when format is ' + format ); } } @@ -203,21 +203,21 @@ assert.equal( hello.format, 'escaped', 'Message.escaped correctly updated the "format" property' ); assert.ok( mw.messages.set( 'multiple-curly-brace', '"{{SITENAME}}" is the home of {{int:other-message}}' ), 'mw.messages.set: Register' ); - assertMultipleFormats( ['multiple-curly-brace'], ['text', 'parse'], '"' + siteName + '" is the home of Other Message', 'Curly brace format works correctly' ); + assertMultipleFormats( [ 'multiple-curly-brace' ], [ 'text', 'parse' ], '"' + siteName + '" is the home of Other Message', 'Curly brace format works correctly' ); assert.equal( mw.message( 'multiple-curly-brace' ).plain(), mw.messages.get( 'multiple-curly-brace' ), 'Plain format works correctly for curly brace message' ); assert.equal( mw.message( 'multiple-curly-brace' ).escaped(), mw.html.escape( '"' + siteName + '" is the home of Other Message' ), 'Escaped format works correctly for curly brace message' ); assert.ok( mw.messages.set( 'multiple-square-brackets-and-ampersand', 'Visit the [[Project:Community portal|community portal]] & [[Project:Help desk|help desk]]' ), 'mw.messages.set: Register' ); - assertMultipleFormats( ['multiple-square-brackets-and-ampersand'], ['plain', 'text'], mw.messages.get( 'multiple-square-brackets-and-ampersand' ), 'Square bracket message is not processed' ); + assertMultipleFormats( [ 'multiple-square-brackets-and-ampersand' ], [ 'plain', 'text' ], mw.messages.get( 'multiple-square-brackets-and-ampersand' ), 'Square bracket message is not processed' ); assert.equal( mw.message( 'multiple-square-brackets-and-ampersand' ).escaped(), 'Visit the [[Project:Community portal|community portal]] & [[Project:Help desk|help desk]]', 'Escaped format works correctly for square bracket message' ); assert.htmlEqual( mw.message( 'multiple-square-brackets-and-ampersand' ).parse(), 'Visit the ' + 'community portal' + ' & help desk', 'Internal links work with parse' ); - assertMultipleFormats( ['mediawiki-test-version-entrypoints-index-php'], ['plain', 'text', 'escaped'], mw.messages.get( 'mediawiki-test-version-entrypoints-index-php' ), 'External link markup is unprocessed' ); + assertMultipleFormats( [ 'mediawiki-test-version-entrypoints-index-php' ], [ 'plain', 'text', 'escaped' ], mw.messages.get( 'mediawiki-test-version-entrypoints-index-php' ), 'External link markup is unprocessed' ); assert.htmlEqual( mw.message( 'mediawiki-test-version-entrypoints-index-php' ).parse(), 'index.php', 'External link works correctly in parse mode' ); - assertMultipleFormats( ['external-link-replace', 'http://example.org/?x=y&z'], ['plain', 'text'], 'Foo [http://example.org/?x=y&z bar]', 'Parameters are substituted but external link is not processed' ); + assertMultipleFormats( [ 'external-link-replace', 'http://example.org/?x=y&z' ], [ 'plain', 'text' ], 'Foo [http://example.org/?x=y&z bar]', 'Parameters are substituted but external link is not processed' ); assert.equal( mw.message( 'external-link-replace', 'http://example.org/?x=y&z' ).escaped(), 'Foo [http://example.org/?x=y&z bar]', 'In escaped mode, parameters are substituted and ampersand is escaped, but external link is not processed' ); assert.htmlEqual( mw.message( 'external-link-replace', 'http://example.org/?x=y&z' ).parse(), 'Foo bar', 'External link with replacement works in parse mode without double-escaping' ); @@ -235,26 +235,26 @@ goodbye = mw.message( 'goodbye' ); assert.strictEqual( goodbye.exists(), false, 'Message.exists returns false for nonexistent messages' ); - assertMultipleFormats( ['goodbye'], ['plain', 'text'], '', 'Message.toString returns if key does not exist' ); + assertMultipleFormats( [ 'goodbye' ], [ 'plain', 'text' ], '', 'Message.toString returns if key does not exist' ); // bug 30684 - assertMultipleFormats( ['goodbye'], ['parse', 'escaped'], '<goodbye>', 'Message.toString returns properly escaped <key> if key does not exist' ); + assertMultipleFormats( [ 'goodbye' ], [ 'parse', 'escaped' ], '<goodbye>', 'Message.toString returns properly escaped <key> if key does not exist' ); assert.ok( mw.messages.set( 'plural-test-msg', 'There {{PLURAL:$1|is|are}} $1 {{PLURAL:$1|result|results}}' ), 'mw.messages.set: Register' ); - assertMultipleFormats( ['plural-test-msg', 6], ['text', 'parse', 'escaped'], 'There are 6 results', 'plural get resolved' ); + assertMultipleFormats( [ 'plural-test-msg', 6 ], [ 'text', 'parse', 'escaped' ], 'There are 6 results', 'plural get resolved' ); assert.equal( mw.message( 'plural-test-msg', 6 ).plain(), 'There {{PLURAL:6|is|are}} 6 {{PLURAL:6|result|results}}', 'Parameter is substituted but plural is not resolved in plain' ); assert.ok( mw.messages.set( 'plural-test-msg-explicit', 'There {{plural:$1|is one car|are $1 cars|0=are no cars|12=are a dozen cars}}' ), 'mw.messages.set: Register message with explicit plural forms' ); - assertMultipleFormats( ['plural-test-msg-explicit', 12], ['text', 'parse', 'escaped'], 'There are a dozen cars', 'explicit plural get resolved' ); + assertMultipleFormats( [ 'plural-test-msg-explicit', 12 ], [ 'text', 'parse', 'escaped' ], 'There are a dozen cars', 'explicit plural get resolved' ); assert.ok( mw.messages.set( 'plural-test-msg-explicit-beginning', 'Basket has {{plural:$1|0=no eggs|12=a dozen eggs|6=half a dozen eggs|one egg|$1 eggs}}' ), 'mw.messages.set: Register message with explicit plural forms' ); - assertMultipleFormats( ['plural-test-msg-explicit-beginning', 1], ['text', 'parse', 'escaped'], 'Basket has one egg', 'explicit plural given at beginning get resolved for singular' ); - assertMultipleFormats( ['plural-test-msg-explicit-beginning', 4], ['text', 'parse', 'escaped'], 'Basket has 4 eggs', 'explicit plural given at beginning get resolved for plural' ); - assertMultipleFormats( ['plural-test-msg-explicit-beginning', 6], ['text', 'parse', 'escaped'], 'Basket has half a dozen eggs', 'explicit plural given at beginning get resolved for 6' ); - assertMultipleFormats( ['plural-test-msg-explicit-beginning', 0], ['text', 'parse', 'escaped'], 'Basket has no eggs', 'explicit plural given at beginning get resolved for 0' ); + assertMultipleFormats( [ 'plural-test-msg-explicit-beginning', 1 ], [ 'text', 'parse', 'escaped' ], 'Basket has one egg', 'explicit plural given at beginning get resolved for singular' ); + assertMultipleFormats( [ 'plural-test-msg-explicit-beginning', 4 ], [ 'text', 'parse', 'escaped' ], 'Basket has 4 eggs', 'explicit plural given at beginning get resolved for plural' ); + assertMultipleFormats( [ 'plural-test-msg-explicit-beginning', 6 ], [ 'text', 'parse', 'escaped' ], 'Basket has half a dozen eggs', 'explicit plural given at beginning get resolved for 6' ); + assertMultipleFormats( [ 'plural-test-msg-explicit-beginning', 0 ], [ 'text', 'parse', 'escaped' ], 'Basket has no eggs', 'explicit plural given at beginning get resolved for 0' ); - assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary'], ['plain', 'text'], mw.messages.get( 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ), 'Double square brackets with no parameters unchanged' ); + assertMultipleFormats( [ 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ], [ 'plain', 'text' ], mw.messages.get( 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ), 'Double square brackets with no parameters unchanged' ); - assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName], ['plain', 'text'], 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets with one parameter' ); + assertMultipleFormats( [ 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ], [ 'plain', 'text' ], 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets with one parameter' ); assert.equal( mw.message( 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ).escaped(), 'Notifying author of deletion nomination for [[' + mw.html.escape( specialCharactersPageName ) + ']]', 'Double square brackets with one parameter, when escaped' ); @@ -264,21 +264,21 @@ assert.ok( mw.messages.set( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result', 'Username (talk)' ), 'mw.messages.set: Register' ); assert.equal( mw.message( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result' ).plain(), mw.messages.get( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result' ), 'HTML message with curly braces is not changed in plain mode' ); - assertMultipleFormats( ['gender-plural-msg', 'male', 1], ['text', 'parse', 'escaped'], 'he is awesome', 'Gender and plural are resolved' ); + assertMultipleFormats( [ 'gender-plural-msg', 'male', 1 ], [ 'text', 'parse', 'escaped' ], 'he is awesome', 'Gender and plural are resolved' ); assert.equal( mw.message( 'gender-plural-msg', 'male', 1 ).plain(), '{{GENDER:male|he|she|they}} {{PLURAL:1|is|are}} awesome', 'Parameters are substituted, but gender and plural are not resolved in plain mode' ); assert.equal( mw.message( 'grammar-msg' ).plain(), mw.messages.get( 'grammar-msg' ), 'Grammar is not resolved in plain mode' ); - assertMultipleFormats( ['grammar-msg'], ['text', 'parse'], 'Przeszukaj ' + siteName, 'Grammar is resolved' ); + assertMultipleFormats( [ 'grammar-msg' ], [ 'text', 'parse' ], 'Przeszukaj ' + siteName, 'Grammar is resolved' ); assert.equal( mw.message( 'grammar-msg' ).escaped(), 'Przeszukaj ' + siteName, 'Grammar is resolved in escaped mode' ); - assertMultipleFormats( ['formatnum-msg', '987654321.654321'], ['text', 'parse', 'escaped'], '987,654,321.654', 'formatnum is resolved' ); + assertMultipleFormats( [ 'formatnum-msg', '987654321.654321' ], [ 'text', 'parse', 'escaped' ], '987,654,321.654', 'formatnum is resolved' ); assert.equal( mw.message( 'formatnum-msg' ).plain(), mw.messages.get( 'formatnum-msg' ), 'formatnum is not resolved in plain mode' ); - assertMultipleFormats( ['int-msg'], ['text', 'parse', 'escaped'], 'Some Other Message', 'int is resolved' ); + assertMultipleFormats( [ 'int-msg' ], [ 'text', 'parse', 'escaped' ], 'Some Other Message', 'int is resolved' ); assert.equal( mw.message( 'int-msg' ).plain(), mw.messages.get( 'int-msg' ), 'int is not resolved in plain mode' ); assert.ok( mw.messages.set( 'mediawiki-italics-msg', 'Very important' ), 'mw.messages.set: Register' ); - assertMultipleFormats( ['mediawiki-italics-msg'], ['plain', 'text', 'parse'], mw.messages.get( 'mediawiki-italics-msg' ), 'Simple italics unchanged' ); + assertMultipleFormats( [ 'mediawiki-italics-msg' ], [ 'plain', 'text', 'parse' ], mw.messages.get( 'mediawiki-italics-msg' ), 'Simple italics unchanged' ); assert.htmlEqual( mw.message( 'mediawiki-italics-msg' ).escaped(), '<i>Very</i> important', @@ -286,7 +286,7 @@ ); assert.ok( mw.messages.set( 'mediawiki-italics-with-link', 'An italicized [[link|wiki-link]]' ), 'mw.messages.set: Register' ); - assertMultipleFormats( ['mediawiki-italics-with-link'], ['plain', 'text'], mw.messages.get( 'mediawiki-italics-with-link' ), 'Italics with link unchanged' ); + assertMultipleFormats( [ 'mediawiki-italics-with-link' ], [ 'plain', 'text' ], mw.messages.get( 'mediawiki-italics-with-link' ), 'Italics with link unchanged' ); assert.htmlEqual( mw.message( 'mediawiki-italics-with-link' ).escaped(), 'An <i>italicized [[link|wiki-link]]</i>', @@ -299,7 +299,7 @@ ); assert.ok( mw.messages.set( 'mediawiki-script-msg', '' ), 'mw.messages.set: Register' ); - assertMultipleFormats( ['mediawiki-script-msg'], ['plain', 'text'], mw.messages.get( 'mediawiki-script-msg' ), 'Script unchanged' ); + assertMultipleFormats( [ 'mediawiki-script-msg' ], [ 'plain', 'text' ], mw.messages.get( 'mediawiki-script-msg' ), 'Script unchanged' ); assert.htmlEqual( mw.message( 'mediawiki-script-msg' ).escaped(), '<script >alert( "Who put this script here?" );</script>', @@ -406,7 +406,7 @@ isAwesomeDone = true; }; - mw.loader.implement( 'test.callback', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )] ); + mw.loader.implement( 'test.callback', [ QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' ) ] ); mw.loader.using( 'test.callback', function () { @@ -430,7 +430,7 @@ isAwesomeDone = true; }; - mw.loader.implement( 'hasOwnProperty', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )], {}, {} ); + mw.loader.implement( 'hasOwnProperty', [ QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' ) ], {}, {} ); mw.loader.using( 'hasOwnProperty', function () { @@ -454,7 +454,7 @@ isAwesomeDone = true; }; - mw.loader.implement( 'test.promise', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )] ); + mw.loader.implement( 'test.promise', [ QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' ) ] ); mw.loader.using( 'test.promise' ) .done( function () { @@ -547,7 +547,7 @@ }, { 'url': { - 'print': [urlStyleTest( '.mw-test-implement-b1', 'text-align', 'center' )], + 'print': [ urlStyleTest( '.mw-test-implement-b1', 'text-align', 'center' ) ], 'screen': [ // bug 40834: Make sure it actually works with more than 1 stylesheet reference urlStyleTest( '.mw-test-implement-b2', 'float', 'left' ), @@ -619,8 +619,8 @@ } ); }, { - 'all': [urlStyleTest( '.mw-test-implement-d', 'float', 'right' )], - 'print': [urlStyleTest( '.mw-test-implement-d2', 'text-align', 'center' )] + 'all': [ urlStyleTest( '.mw-test-implement-d', 'float', 'right' ) ], + 'print': [ urlStyleTest( '.mw-test-implement-d2', 'text-align', 'center' ) ] } ); @@ -688,7 +688,7 @@ ); mw.loader.register( [ - [ 'test.implement.e', '0', ['test.implement.e2']], + [ 'test.implement.e', '0', [ 'test.implement.e2' ] ], [ 'test.implement.e2', '0' ] ] ); @@ -749,9 +749,9 @@ this.sandbox.stub( mw, 'track' ); mw.loader.register( [ - ['test.module1', '0'], - ['test.module2', '0', ['test.module1']], - ['test.module3', '0', ['test.module2']] + [ 'test.module1', '0' ], + [ 'test.module2', '0', [ 'test.module1' ] ], + [ 'test.module3', '0', [ 'test.module2' ] ] ] ); mw.loader.implement( 'test.module1', function () { throw new Error( 'expected' ); @@ -765,9 +765,9 @@ QUnit.test( 'mw.loader out-of-order implementation', 9, function ( assert ) { mw.loader.register( [ - ['test.module4', '0'], - ['test.module5', '0', ['test.module4']], - ['test.module6', '0', ['test.module5']] + [ 'test.module4', '0' ], + [ 'test.module5', '0', [ 'test.module4' ] ], + [ 'test.module6', '0', [ 'test.module5' ] ] ] ); mw.loader.implement( 'test.module4', function () {} ); assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' ); @@ -785,9 +785,9 @@ QUnit.test( 'mw.loader missing dependency', 13, function ( assert ) { mw.loader.register( [ - ['test.module7', '0'], - ['test.module8', '0', ['test.module7']], - ['test.module9', '0', ['test.module8']] + [ 'test.module7', '0' ], + [ 'test.module8', '0', [ 'test.module7' ] ], + [ 'test.module9', '0', [ 'test.module8' ] ] ] ); mw.loader.implement( 'test.module8', function () {} ); assert.strictEqual( mw.loader.getState( 'test.module7' ), 'registered', 'Expected "registered" state for test.module7' ); @@ -802,18 +802,18 @@ assert.strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' ); assert.strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' ); mw.loader.using( - ['test.module7'], + [ 'test.module7' ], function () { assert.ok( false, 'Success fired despite missing dependency' ); assert.ok( true, 'QUnit expected() count dummy' ); }, function ( e, dependencies ) { assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' ); - assert.deepEqual( dependencies, ['test.module7'], 'Error callback called with module test.module7' ); + assert.deepEqual( dependencies, [ 'test.module7' ], 'Error callback called with module test.module7' ); } ); mw.loader.using( - ['test.module9'], + [ 'test.module9' ], function () { assert.ok( false, 'Success fired despite missing dependency' ); assert.ok( true, 'QUnit expected() count dummy' ); @@ -823,7 +823,7 @@ dependencies.sort(); assert.deepEqual( dependencies, - ['test.module7', 'test.module8', 'test.module9'], + [ 'test.module7', 'test.module8', 'test.module9' ], 'Error callback called with all three modules as dependencies' ); } @@ -833,9 +833,9 @@ QUnit.asyncTest( 'mw.loader dependency handling', 5, function ( assert ) { mw.loader.register( [ // [module, version, dependencies, group, source] - ['testMissing', '1', [], null, 'testloader'], - ['testUsesMissing', '1', ['testMissing'], null, 'testloader'], - ['testUsesNestedMissing', '1', ['testUsesMissing'], null, 'testloader'] + [ 'testMissing', '1', [], null, 'testloader' ], + [ 'testUsesMissing', '1', [ 'testMissing' ], null, 'testloader' ], + [ 'testUsesNestedMissing', '1', [ 'testUsesMissing' ], null, 'testloader' ] ] ); function verifyModuleStates() { @@ -844,7 +844,7 @@ assert.equal( mw.loader.getState( 'testUsesNestedMissing' ), 'error', 'Module with indirect missing dependency must have state "error"' ); } - mw.loader.using( ['testUsesNestedMissing'], + mw.loader.using( [ 'testUsesNestedMissing' ], function () { assert.ok( false, 'Error handler should be invoked.' ); assert.ok( true ); // Dummy to reach QUnit expect() @@ -858,7 +858,7 @@ // As soon as server spits out state('testMissing', 'missing'); // it will bubble up and trigger the error callback. // Therefor the badmodules array is not testUsesMissing or testUsesNestedMissing. - assert.deepEqual( badmodules, ['testMissing'], 'Bad modules as expected.' ); + assert.deepEqual( badmodules, [ 'testMissing' ], 'Bad modules as expected.' ); verifyModuleStates(); @@ -870,9 +870,9 @@ QUnit.asyncTest( 'mw.loader skin-function handling', 5, function ( assert ) { mw.loader.register( [ // [module, version, dependencies, group, source, skip] - ['testSkipped', '1', [], null, 'testloader', 'return true;'], - ['testNotSkipped', '1', [], null, 'testloader', 'return false;'], - ['testUsesSkippable', '1', ['testSkipped', 'testNotSkipped'], null, 'testloader'] + [ 'testSkipped', '1', [], null, 'testloader', 'return true;' ], + [ 'testNotSkipped', '1', [], null, 'testloader', 'return false;' ], + [ 'testUsesSkippable', '1', [ 'testSkipped', 'testNotSkipped' ], null, 'testloader' ] ] ); function verifyModuleStates() { @@ -881,7 +881,7 @@ assert.equal( mw.loader.getState( 'testUsesSkippable' ), 'ready', 'Module is ready when skippable dependencies are ready' ); } - mw.loader.using( ['testUsesSkippable'], + mw.loader.using( [ 'testUsesSkippable' ], function () { assert.ok( true, 'Success handler should be invoked.' ); assert.ok( true ); // Dummy to match error handler and reach QUnit expect() @@ -1015,9 +1015,9 @@ mw.hook( 'test.hook.data' ).add( function ( data1, data2 ) { assert.equal( data1, 'example', 'Fire with data (string param)' ); - assert.deepEqual( data2, ['two'], 'Fire with data (array param)' ); + assert.deepEqual( data2, [ 'two' ], 'Fire with data (array param)' ); } ); - mw.hook( 'test.hook.data' ).fire( 'example', ['two'] ); + mw.hook( 'test.hook.data' ).fire( 'example', [ 'two' ] ); hook = mw.hook( 'test.hook.chainable' ); assert.strictEqual( hook.add(), hook, 'hook.add is chainable' ); @@ -1028,7 +1028,7 @@ add = hook.add; fire = hook.fire; add( function ( x, y ) { - assert.deepEqual( [x, y], ['x', 'y'], 'Detached (contextless) with data' ); + assert.deepEqual( [ x, y ], [ 'x', 'y' ], 'Detached (contextless) with data' ); } ); fire( 'x', 'y' ); @@ -1051,7 +1051,7 @@ assert.equal( chr, 'z', 'Adding callback later invokes right away with last data' ); } ); - assert.deepEqual( chars, ['x', 'y', 'z'], 'Multiple callbacks with multiple fires' ); + assert.deepEqual( chars, [ 'x', 'y', 'z' ], 'Multiple callbacks with multiple fires' ); chars = []; callback = function ( chr ) { @@ -1080,7 +1080,7 @@ assert.deepEqual( chars, - ['x', 'x', 'x', 'x', 'y', 'z'], + [ 'x', 'x', 'x', 'x', 'y', 'z' ], '"add" and "remove" support variadic arguments. ' + '"add" does not filter unique. ' + '"remove" removes all equal by reference. ' + diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js index b73d2e39cf..450f0f5d64 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js @@ -2,54 +2,54 @@ var // Based on IPTest.php > testisIPv4 IPV4_CASES = [ - [false, false, 'Boolean false is not an IP'], - [false, true, 'Boolean true is not an IP'], - [false, '', 'Empty string is not an IP'], - [false, 'abc', '"abc" is not an IP'], - [false, ':', 'Colon is not an IP'], - [false, '124.24.52', 'IPv4 not enough quads'], - [false, '24.324.52.13', 'IPv4 out of range'], - [false, '.24.52.13', 'IPv4 starts with period'], - - [true, '124.24.52.13', '124.24.52.134 is a valid IP'], - [true, '1.24.52.13', '1.24.52.13 is a valid IP'], - [false, '74.24.52.13/20', 'IPv4 ranges are not recognized as valid IPs'] + [ false, false, 'Boolean false is not an IP' ], + [ false, true, 'Boolean true is not an IP' ], + [ false, '', 'Empty string is not an IP' ], + [ false, 'abc', '"abc" is not an IP' ], + [ false, ':', 'Colon is not an IP' ], + [ false, '124.24.52', 'IPv4 not enough quads' ], + [ false, '24.324.52.13', 'IPv4 out of range' ], + [ false, '.24.52.13', 'IPv4 starts with period' ], + + [ true, '124.24.52.13', '124.24.52.134 is a valid IP' ], + [ true, '1.24.52.13', '1.24.52.13 is a valid IP' ], + [ false, '74.24.52.13/20', 'IPv4 ranges are not recognized as valid IPs' ] ], // Based on IPTest.php > testisIPv6 IPV6_CASES = [ - [false, ':fc:100::', 'IPv6 starting with lone ":"'], - [false, 'fc:100:::', 'IPv6 ending with a ":::"'], - [false, 'fc:300', 'IPv6 with only 2 words'], - [false, 'fc:100:300', 'IPv6 with only 3 words'], - - [false, 'fc:100:a:d:1:e:ac:0::', 'IPv6 with 8 words ending with "::"'], - [false, 'fc:100:a:d:1:e:ac:0:1::', 'IPv6 with 9 words ending with "::"'], - - [false, ':::'], - [false, '::0:', 'IPv6 ending in a lone ":"'], - - [true, '::', 'IPv6 zero address'], - - [false, '::fc:100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words'], - [false, '::fc:100:a:d:1:e:ac:0:1', 'IPv6 with 9 words'], - - [false, ':fc::100', 'IPv6 starting with lone ":"'], - [false, 'fc::100:', 'IPv6 ending with lone ":"'], - [false, 'fc:::100', 'IPv6 with ":::" in the middle'], - - [true, 'fc::100', 'IPv6 with "::" and 2 words'], - [true, 'fc::100:a', 'IPv6 with "::" and 3 words'], - [true, 'fc::100:a:d', 'IPv6 with "::" and 4 words'], - [true, 'fc::100:a:d:1', 'IPv6 with "::" and 5 words'], - [true, 'fc::100:a:d:1:e', 'IPv6 with "::" and 6 words'], - [true, 'fc::100:a:d:1:e:ac', 'IPv6 with "::" and 7 words'], - [true, '2001::df', 'IPv6 with "::" and 2 words'], - [true, '2001:5c0:1400:a::df', 'IPv6 with "::" and 5 words'], - [true, '2001:5c0:1400:a::df:2', 'IPv6 with "::" and 6 words'], - - [false, 'fc::100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words'], - [false, 'fc::100:a:d:1:e:ac:0:1', 'IPv6 with 9 words'] + [ false, ':fc:100::', 'IPv6 starting with lone ":"' ], + [ false, 'fc:100:::', 'IPv6 ending with a ":::"' ], + [ false, 'fc:300', 'IPv6 with only 2 words' ], + [ false, 'fc:100:300', 'IPv6 with only 3 words' ], + + [ false, 'fc:100:a:d:1:e:ac:0::', 'IPv6 with 8 words ending with "::"' ], + [ false, 'fc:100:a:d:1:e:ac:0:1::', 'IPv6 with 9 words ending with "::"' ], + + [ false, ':::' ], + [ false, '::0:', 'IPv6 ending in a lone ":"' ], + + [ true, '::', 'IPv6 zero address' ], + + [ false, '::fc:100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words' ], + [ false, '::fc:100:a:d:1:e:ac:0:1', 'IPv6 with 9 words' ], + + [ false, ':fc::100', 'IPv6 starting with lone ":"' ], + [ false, 'fc::100:', 'IPv6 ending with lone ":"' ], + [ false, 'fc:::100', 'IPv6 with ":::" in the middle' ], + + [ true, 'fc::100', 'IPv6 with "::" and 2 words' ], + [ true, 'fc::100:a', 'IPv6 with "::" and 3 words' ], + [ true, 'fc::100:a:d', 'IPv6 with "::" and 4 words' ], + [ true, 'fc::100:a:d:1', 'IPv6 with "::" and 5 words' ], + [ true, 'fc::100:a:d:1:e', 'IPv6 with "::" and 6 words' ], + [ true, 'fc::100:a:d:1:e:ac', 'IPv6 with "::" and 7 words' ], + [ true, '2001::df', 'IPv6 with "::" and 2 words' ], + [ true, '2001:5c0:1400:a::df', 'IPv6 with "::" and 5 words' ], + [ true, '2001:5c0:1400:a::df:2', 'IPv6 with "::" and 6 words' ], + + [ false, 'fc::100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words' ], + [ false, 'fc::100:a:d:1:e:ac:0:1', 'IPv6 with 9 words' ] ]; Array.prototype.push.apply( IPV6_CASES, @@ -70,7 +70,7 @@ '::fc:100:a:d:1:e:ac', 'fc:100:a:d:1:e:ac:0' ], function ( el ) { - return [[ true, el, el + ' is a valid IP' ]]; + return [ [ true, el, el + ' is a valid IP' ] ]; } ) ); @@ -266,7 +266,7 @@ ); assert.equal( $tbMW.closest( '.portlet' ).attr( 'id' ), 'p-test-tb', 'Link was inserted within correct portlet' ); - assert.strictEqual( $tbMW.next()[0], tbRL, 'Link is in the correct position (nextnode as Node object)' ); + assert.strictEqual( $tbMW.next()[ 0 ], tbRL, 'Link is in the correct position (nextnode as Node object)' ); cuQuux = mw.util.addPortletLink( 'p-test-custom', '#', 'Quux', null, 'Example [shift-x]', 'q' ); $cuQuux = $( cuQuux ); @@ -282,7 +282,7 @@ tbRLDM = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/RL/DM', 'Default modules', 't-rldm', 'List of all default modules ', 'd', '#t-rl' ); - assert.strictEqual( $( tbRLDM ).next()[0], tbRL, 'Link is in the correct position (CSS selector as nextnode)' ); + assert.strictEqual( $( tbRLDM ).next()[ 0 ], tbRL, 'Link is in the correct position (CSS selector as nextnode)' ); caFoo = mw.util.addPortletLink( 'p-test-views', '#', 'Foo' ); @@ -290,19 +290,19 @@ assert.strictEqual( $( caFoo ).find( 'span' ).length, 1, 'A element should be added for porlets with vectorTabs class.' ); addedAfter = mw.util.addPortletLink( 'p-test-tb', '#', 'After foo', 'post-foo', 'After foo', null, $( tbRL ) ); - assert.strictEqual( $( addedAfter ).next()[0], tbRL, 'Link is in the correct position (jQuery object as nextnode)' ); + assert.strictEqual( $( addedAfter ).next()[ 0 ], tbRL, 'Link is in the correct position (jQuery object as nextnode)' ); // test case - nonexistent id as next node tbRLDMnonexistentid = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/RL/DM', 'Default modules', 't-rldm-nonexistent', 'List of all default modules ', 'd', '#t-rl-nonexistent' ); - assert.equal( tbRLDMnonexistentid, $( '#p-test-tb li:last' )[0], 'Fallback to adding at the end (nextnode non-matching CSS selector)' ); + assert.equal( tbRLDMnonexistentid, $( '#p-test-tb li:last' )[ 0 ], 'Fallback to adding at the end (nextnode non-matching CSS selector)' ); // test case - empty jquery object as next node tbRLDMemptyjquery = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/RL/DM', 'Default modules', 't-rldm-empty-jquery', 'List of all default modules ', 'd', $( '#t-rl-nonexistent' ) ); - assert.equal( tbRLDMemptyjquery, $( '#p-test-tb li:last' )[0], 'Fallback to adding at the end (nextnode as empty jQuery object)' ); + assert.equal( tbRLDMemptyjquery, $( '#p-test-tb li:last' )[ 0 ], 'Fallback to adding at the end (nextnode as empty jQuery object)' ); } ); QUnit.test( 'validateEmail', 6, function ( assert ) { @@ -320,23 +320,23 @@ QUnit.test( 'isIPv6Address', 40, function ( assert ) { $.each( IPV6_CASES, function ( i, ipCase ) { - assert.strictEqual( mw.util.isIPv6Address( ipCase[1] ), ipCase[0], ipCase[2] ); + assert.strictEqual( mw.util.isIPv6Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] ); } ); } ); QUnit.test( 'isIPv4Address', 11, function ( assert ) { $.each( IPV4_CASES, function ( i, ipCase ) { - assert.strictEqual( mw.util.isIPv4Address( ipCase[1] ), ipCase[0], ipCase[2] ); + assert.strictEqual( mw.util.isIPv4Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] ); } ); } ); QUnit.test( 'isIPAddress', 51, function ( assert ) { $.each( IPV4_CASES, function ( i, ipCase ) { - assert.strictEqual( mw.util.isIPv4Address( ipCase[1] ), ipCase[0], ipCase[2] ); + assert.strictEqual( mw.util.isIPv4Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] ); } ); $.each( IPV6_CASES, function ( i, ipCase ) { - assert.strictEqual( mw.util.isIPv6Address( ipCase[1] ), ipCase[0], ipCase[2] ); + assert.strictEqual( mw.util.isIPv6Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] ); } ); } ); }( mediaWiki, jQuery ) ); -- 2.20.1