MediaWiki:Gadget-MainLangFirst.js

/*global mw, $ */ ( function {  'use strict';  var langMap, langs;

if ( mw.config.get( 'wgNamespaceNumber' ) !== 0 ) { return; }

langMap = { 'bho': 'bh', 'gsw': 'als', 'lzh': 'zh_classical', 'nan': 'zh_min_nan', 'nb': 'no', 'rup': 'roa_rup', 'sgs': 'bat_smg', 'vro': 'fiu_vro', 'yue': 'zh_yue', };

langs = mw.user.options.get( 'translate-editlangs' ).split( ', ' ); langs.push( mw.config.get( 'wgUserLanguage' ) ); langs = langs.map( function (lang) {   return langMap[lang] || lang;  } );

function highlightSiteLinks( $content ) { function highlightSiteLinksGroup( group, customSuffix ) { var selector, suffix = customSuffix || group, $group = $content.find( 'div[data-wb-sitelinks-group="' + group + '"]' );

// Highlight main languages selector = langs.map( function ( code ) {       return '.wikibase-sitelinkview-' + code + suffix;      } ).join( ',' ); $group.find( selector ) .prependTo( $group.find( 'ul' ).eq( 0 ) ) .addClass( 'main-lang-highlight');

// Update zebra style $group.find( '.listview-item' ).each( function ( i ) {       $( this )          .toggleClass( 'even', i % 2 === 0 )          .toggleClass( 'uneven', i % 2 === 1 );      } ); }

highlightSiteLinksGroup( 'miraheze' ); highlightSiteLinksGroup( 'famepedia' ); }

mw.hook( 'wikipage.content' ).add( highlightSiteLinks );

});