/**
* Converts sort objects [ { Integer: String }, ... ] to the internally used nested array
- * structure [ [ Integer , Integer ], ... ]
+ * structure [ [ Integer, Integer ], ... ]
*
* @param {Array} sortObjects List of sort objects.
* @return {Array} List of internal sort definitions.
*/
function convertSortList( sortObjects ) {
var sortList = [];
- $.each( sortObjects, function ( i, sortObject ) {
+ sortObjects.forEach( function ( sortObject ) {
$.each( sortObject, function ( columnIndex, order ) {
var orderIndex = ( order === 'desc' ) ? 1 : 0;
sortList.push( [ parseInt( columnIndex, 10 ), orderIndex ] );
parseRequest = api.post( postData );
parseRequest.done( function ( response ) {
- var li, newList, $displaytitle, $content, $parent, $list;
+ var newList, $displaytitle, $content, $parent, $list;
if ( response.parse.jsconfigvars ) {
mw.config.set( response.parse.jsconfigvars );
}
$( '.catlinks[data-mw="interface"]' ).replaceWith( $content );
}
if ( response.parse.templates ) {
- newList = [];
- $.each( response.parse.templates, function ( i, template ) {
- li = $( '<li>' )
+ newList = response.parse.templates.map( function ( template ) {
+ return $( '<li>' )
.append( $( '<a>' )
.attr( {
href: mw.util.getUrl( template.title ),
} )
.text( template.title )
);
- newList.push( li );
} );
$editform.find( '.templatesUsed .mw-editfooter-list' ).detach().empty().append( newList ).appendTo( '.templatesUsed' );
$( '.limitreport' ).html( response.parse.limitreporthtml );
}
if ( response.parse.langlinks && mw.config.get( 'skin' ) === 'vector' ) {
- newList = [];
- $.each( response.parse.langlinks, function ( i, langlink ) {
+ newList = response.parse.langlinks.map( function ( langlink ) {
var bcp47 = mw.language.bcp47( langlink.lang );
- li = $( '<li>' )
+ return $( '<li>' )
.addClass( 'interlanguage-link interwiki-' + langlink.lang )
.append( $( '<a>' )
.attr( {
} )
.text( langlink.autonym )
);
- newList.push( li );
} );
$list = $( '#p-lang ul' );
$parent = $list.parent();
buttons = slice.call( arguments );
}
if ( isReady ) {
- $.each( buttons, function () {
- insertButton( this );
+ buttons.forEach( function ( button ) {
+ insertButton( button );
} );
} else {
// Push each button into the queue
}, options ) ).then( function ( data ) {
var result = {};
- $.each( data.query.allmessages, function ( i, obj ) {
+ data.query.allmessages.forEach( function ( obj ) {
if ( !obj.missing ) {
result[ obj.name ] = obj.content;
}
$( '<p>' ).msg( 'filepageexists', 'File:' + warnings[ 'page-exists' ] ),
{ recoverable: false }
) );
- } else if ( warnings.duplicate !== undefined ) {
- $.each( warnings.duplicate, function ( i, filename ) {
+ } else if ( Array.isArray( warnings.duplicate ) ) {
+ warnings.duplicate.forEach( function ( filename ) {
var $a = $( '<a>' ).text( filename ),
href = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).file, filename ).getUrl( {} );