MediaWiki:Wikia.js

/* AjaxRC */ window.ajaxPages = ["Blog:Recent_posts","Special:Chat","Special:WikiActivity","Special:RecentChanges","Special:Watchlist","Special:Log","Special:Contributions"]; window.ajaxIndicator = 'http://vignette2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif'; window.ajaxRefresh = 30000; window.AjaxRCRefreshText = 'Auto-refresh'; window.AjaxRCRefreshHoverText = 'Automatically refresh the page';

//—————————————————————————————— ! ! ! ———————————————————————————————// /* Import scripts. NOTE: Place scripts configurations above this line */

importArticles({   type: 'script',    articles: [        'u:dev:TimedSlider/code.js', //Automatically tabs through a set slides based on a user-defined timer.         'u:dev:AjaxRC/code.js',      //Automatically refreshes pages.    ] });

/** Language dropdown **/ function appendLanguageDropdown { var borderColor = $('.WikiaPageHeader .comments').css('border-top-color'); var server = wgServer.replace("http://",""); var html = '   '; flags = {}; flags['de'] = ''; flags['en'] = ''; flags['es'] = ''; flags['ja'] = ''; flags['pl'] = ''; flags['pt'] = ''; flags['pt-br'] = ''; flags['ru'] = ''; flags['tr'] = ''; $('.WikiaPageHeader .comments').after(html); languages = {}; $('.WikiaArticleInterlang ul li a').each(function {		var languageFull = $(this).text;		var href = $(this).attr('href');		var pageNameArray = href.split('/')		var pageName = pageNameArray[pageNameArray.length - 1];		switch (languageFull) {               case "Deutsch":                languages['de'] = href;                break;			case "English":				languages['en'] = href;				break;			case "Español":				languages['es'] = href;				break;			case "日本語":				languages['ja'] = href;				break;			case "Polski":				languages['pl'] = href;				break;			case "Português":				languages['pt'] = href;				break;			case "Português do Brasil":				languages['pt-br'] = href;				break;			case "Русский":				languages['ru'] = href;				break;			case "Türkçe":				languages['tr'] = href;				break;		}	}); var language = wgContentLanguage; $.each(flags, function (key, value) {		if (key === language) {			$('.WikiaPageHeader .chooselanguage').prepend(flags[key]);		} 		else {			if (languages[key]) {				$('.WikiaPageHeader .chooselanguage ul').append('' + flags[key] + '</a>');			}		}	}); $('.WikiaPageHeader .chooselanguage').on('click', function {		if ($(this).hasClass('active') === false) {			$(this).addClass('active');		} 		else {			$(this).removeClass('active');		}	}); $('.WikiaPageHeader .chooselanguage').on('mouseleave', function {		var that = this;		var timeOut = setTimeout(function  { $(that).removeClass('active'); }, 500);		$('.chooselanguage').on('mouseenter', function  { clearTimeout(timeOut); });	}); } if( $('.WikiaArticleInterlang').length > 0 ) { addOnloadHook(appendLanguageDropdown); }

/*** Click tracking ***/ jQuery( function($) {	var track = Wikia.Tracker.buildTrackingFunction({ category: 'interlanguage-nav', action: Wikia.Tracker.ACTIONS.CLICK, trackingMethod: 'ga' });	/** Wikia Interlanguage Default Link **/	var $WikiaInterlanguageDefaultLink = $('nav.WikiaArticleInterlang');	$WikiaInterlanguageDefaultLink.on( 'mousedown', 'a', function(e) { track({			browserEvent: e,			label: 'interlanguage-deafult-link'		}); } );	/** WikiaInterlanguageCustomLink **/	var $WikiaInterlanguageCustomLink = $('.WikiaPageHeader');	$WikiaInterlanguageCustomLink.on( 'mousedown', '.chooselanguage a', function(e) { track({			browserEvent: e,			label: 'interlanguage-custom-link'		}); } ); } );

/* Portable infoboxes colors */ (function{   var infobox = $('.portable-infobox');    if (infobox.length) {        var color = ,        classNames = infobox.attr('class').split(' ');        for (var i = 0; i < classNames.length; i++) {            if (classNames[i].indexOf('pi-theme-_') !== -1) {                color = classNames[i].replace('pi-theme-_', );                break;            }        }        if (color) {            infobox.css('border', '1px solid #' + color);            infobox.find('h2').css('background-color', '#' + color);        }    } });

/* Users blocked infinite */ window.addEventListener('load', function {   // Timeouts are always a terrible way to go, but UserTags has no event dispatched when it finished loading.    setTimeout(function { if (document.getElementById('UserProfileMasthead') === null) return; var blockTag = document.querySelector('.tag.usergroup-blocked.blocked-user'); if (blockTag === null) return; new mw.Api.get({          action: 'query',           list: 'blocks',           bkprop: 'expiry',           bktimestamp: new Date.getTime,           bkusers: wgTitle        }).done(function(d) {           if (d.query.blocks[0] && d.query.blocks[0].expiry == 'infinity') {               blockTag.innerHTML = 'Blocked';           }        }); }, 250); });