Add languages in which there is a featured article

Bug: T70071
Change-Id: I5ed2f1ece5b11b96ec6416bc1c6c2266ac6b4388
This commit is contained in:
Amire80
2016-08-04 17:05:59 +03:00
parent 9c1decf616
commit 43f62e601c

View File

@@ -233,6 +233,8 @@
this.getCommonLanguages, this.getCommonLanguages,
// Add languages that are present in the article content. // Add languages that are present in the article content.
this.filterByLangsInText, this.filterByLangsInText,
// Add languages in which there are featured articles.
this.filterByBadges,
// Some global fallbacks to avoid showing languages in the beginning of the alphabet // Some global fallbacks to avoid showing languages in the beginning of the alphabet
getExtraCommonLanguages, getExtraCommonLanguages,
// Finally add the whole languages array too. // Finally add the whole languages array too.
@@ -366,6 +368,22 @@
return languagesInText; return languagesInText;
}; };
/**
* Filter the language list by languages the page in which
* has any kind of a badge, such as "featured article".
* The "badge-*" classes are added by Wikibase.
*
* The reader doesn't necessarily know this language, but it
* appears relevant to the page.
*
* @return {Array} List of language codes in which there are articles with badges
*/
CompactInterlanguageList.prototype.filterByBadges = function () {
return $( '#p-lang' ).find( '[class*="badge"]' ).map( function ( i, el ) {
return $( el ).find( 'a' ).attr( 'lang' ); }
).toArray();
};
/** /**
* Find out the existing languages supported * Find out the existing languages supported
* by the article and fetch their href. * by the article and fetch their href.