/**
* Interwiki links to featured articles
*
* Highlights interwiki links to featured articles (or equivalents) by changing
* the bullet before the interwiki link into a star.
*
* @author: [[User:R. Koot]]
* @author: [[User:Helder.wiki]]
* TODO: add support for
* - featured portals (used in frwiki)
* - localized class names (used by eswiki, frwiki, ptwiki, rowiki, etc)
* - complex language fallbacks (see [[zh:MediaWiki:Gadget-site-lib.js]])
*
* Warning! Global gadget file!
*/
/*global mw, $ */
var i18n = {
'badge-featured': {
en: 'This is a featured article in this language.',
ja: 'この記事は秀逸な記事に選ばれています。'
},
'badge-good': {
en: 'This is a good article in this language.',
ja: 'この記事は良質な記事に選ばれています。'
},
'badge-featured-list': {
en: 'This is a featured list in this language.',
ja: 'この記事は秀逸な一覧に選ばれています。'
}
};
function msg( key ){
return i18n[ key ][ mw.config.get( 'wgUserLanguage' ).split('-')[0] ] || i18n[ key ].en;
}
function linkFA() {
var $list = mw.config.get( 'skin' ) === 'cologneblue' ?
$( '#langlinks' ).find( 'span' ) :
$( '#p-lang' ).find( 'li' );
$list.each( function(){
var $this = $( this ),
lang = $this.find( '[lang]' ).attr( 'lang' ) || '',
id = 'interwiki-' + lang.toLowerCase();
if ( document.getElementById( id + '-fa' ) && !$this.hasClass( 'badge-featuredarticle' ) ) {
$this.addClass( 'FA' )
.attr( 'title', msg( 'badge-featured' ) );
} else if ( document.getElementById( id + '-ga' ) && !$this.hasClass( 'badge-goodarticle' ) ) {
$this.addClass( 'GA' )
.attr( 'title', msg( 'badge-good' ) );
} else if ( document.getElementById( id + '-fl' ) && !$this.hasClass( 'badge-featuredlist' ) ) {
$this.addClass( 'FL' )
.attr( 'title', msg( 'badge-featured-list' ) );
}
} );
}
mw.hook( 'wikipage.content' ).add( linkFA );