Avoid duplicate entries for WikiProjects

This commit is contained in:
theopolisme 2014-04-21 16:22:18 -05:00
parent 37c04681a9
commit cfccff6ee4
2 changed files with 20 additions and 2 deletions

View File

@ -1057,6 +1057,19 @@
return v;
},
/**
* Removes all occurences of a value from an array
* @param {array} array
* @param {mixed} value
*/
removeFromArray: function ( array, value ) {
var index = $.inArray( value, array );
while ( index !== -1 ) {
array.splice( index, 1 );
index = $.inArray( value, array );
}
},
/**
* Creates an <a> element that links to a given page
* @param {string} pagename

View File

@ -1781,13 +1781,18 @@
// Add biography banner if specified
if ( data.isBiography ) {
// Ensure we don't have duplicate biography tags
AFCH.removeFromArray( data.newWikiProjects, 'WikiProject Biography' );
talkText += ( '\n{{WikiProject Biography|living=' +
( data.lifeStatus !== 'unknown' ? ( data.lifeStatus === 'living' ? 'yes' : 'no' ) : '' ) +
'|class=' + data.newAssessment + '|listas=' + data.subjectName + '}}' );
}
if ( data.newAssessment === 'disambig' ) {
talkText += '\n{{WikiProject Disambiguation}}';
if ( data.newAssessment === 'disambig' &&
$.inArray( 'WikiProject Disambiguation', data.newWikiProjects ) === -1 )
{
data.newWikiProjects.push( 'WikiProject Disambiguation' );
}
// Add WikiProjects