MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

/* Main page */ /** Poll text **/ $(document).ready(function {	$(".ajax-poll .total").parent.addClass("pollText"); });

/**************************************************************/ /* sliders using jquery by User:Tierrie in Dragon Age Wiki */ /**************************************************************/ //wsl.loadScript("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"); //wsl.loadScript("http://dragonage.wikia.com/index.php?title=MediaWiki:Jquery-ui.min.js&action=raw&ctype=text/javascript");

mw.loader.using( ['jquery.ui.tabs'], function { $(document).ready(function { var $tabs = $("#portal_slider").tabs({ fx: {opacity:'toggle', duration:100} } ); $("[class^=portal_sliderlink]").click(function { // bind click event to link   $tabs.tabs('select', this.className.replace("portal_sliderlink_", ""));    return false;  }); $('#portal_next').click(function {   $tabs.tabs('select', ($tabs.tabs('option', 'selected') == ($tabs.tabs('length'))-1) ? 0 : $tabs.tabs('option', 'selected') + 1 ); // switch to next tab   return false;  }); $('#portal_prev').click(function { // bind click event to link   $tabs.tabs('select', ($tabs.tabs('option', 'selected') == 0) ? ($tabs.tabs('length')-1) : $tabs.tabs('option', 'selected') - 1 ); // switch to previous tab   return false;  }); }); } ); // ************************************************** // Experimental javascript countdown timer (Splarka) // Version 0.0.3 // ************************************************** // // Usage example: // //  Only January 01 2007 00:00:00 PST until New years. // //  Javascript disabled. function updatetimer(i) { var now = new Date; var then = timers[i].eventdate; var diff = count=Math.floor((then.getTime-now.getTime)/1000); // catch bad date strings if(isNaN(diff)) { timers[i].firstChild.nodeValue = '** ' + timers[i].eventdate + ' **' ; return; } // determine plus/minus if(diff<0) { diff = -diff; var tpm = 'T plus '; } else { var tpm = 'T minus '; } // calcuate the diff var left = (diff%60) + ' seconds'; diff=Math.floor(diff/60); if(diff > 0) left = (diff%60) + ' minutes ' + left; diff=Math.floor(diff/60); if(diff > 0) left = (diff%24) + ' hours ' + left; diff=Math.floor(diff/24); if(diff > 0) left = diff + ' days ' + left timers[i].firstChild.nodeValue = tpm + left; // a setInterval is more efficient, but calling setTimeout // makes errors break the script rather than infinitely recurse timeouts[i] = setTimeout('updatetimer(' + i + ')',1000); } function checktimers { //hide 'nocountdown' and show 'countdown' var nocountdowns = getElementsByClassName(document, 'span', 'nocountdown'); for(var i in nocountdowns) nocountdowns[i].style.display = 'none' var countdowns = getElementsByClassName(document, 'span', 'countdown'); for(var i in countdowns) countdowns[i].style.display = 'inline' //set up global objects timers and timeouts. timers = getElementsByClassName(document, 'span', 'countdowndate'); //global timeouts = new Array; // generic holder for the timeouts, global if(timers.length == 0) return; for(var i in timers) { timers[i].eventdate = new Date(timers[i].firstChild.nodeValue); updatetimer(i); //start it up  } } addOnloadHook(checktimers); // ************************************************** // - end -  Experimental javascript countdown timer // **************************************************

/* * ADVANCED AJAX AUTO-REFRESHING ARTICLES * Code originally by "pcj" of Wowpedia * Maintenance, cleanup, style and bug fixes by Grunny (http://community.wikia.com/wiki/User:Grunny) */ var	ajaxIndicator = 'http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif', ajaxTimer, ajaxRefresh = 60000, refreshText = ' Auto-Refresh', refreshHover = 'Enable auto-refreshing of this page', RecentChangesLocal, doRefresh = true;

if ( !window.ajaxPages ) { var ajaxPages = new Array( 'Special:RecentChanges','Special:WikiActivity' ); } if ( !window.ajaxCallAgain ) { var ajaxCallAgain = []; } if( typeof AjaxRCRefreshText == "string" ) { refreshText = AjaxRCRefreshText; } if( typeof AjaxRCRefreshHoverText == "string" ) { refreshHover = AjaxRCRefreshHoverText; }

/** * Sets the cookie * @param c_name string Name of the cookie * @param value string 'on' or 'off' * @param expiredays integer Expiry time of the cookie in days */ function setCookie( c_name, value, expiredays ) { var exdate = new Date; exdate.setDate( exdate.getDate + expiredays); document.cookie = c_name + "=" + escape(value) + ( ( expiredays === null ) ? "" : ";expires=" + exdate.toGMTString ); }

/** * Gets the cookie * @param c_name string Cookie name * @return The cookie name or empty string */ function getCookie( c_name ) { if ( document.cookie.length > 0 ) { var c_start = document.cookie.indexOf( c_name + "=" ); if ( c_start !== -1 ) { c_start = c_start + c_name.length + 1; var c_end = document.cookie.indexOf( ";", c_start ); if ( c_end === -1 ) { c_end = document.cookie.length; }			return unescape( document.cookie.substring( c_start, c_end ) ); }	}	return ""; }

/** * Main function to start the Auto-refresh process */ function preloadAJAXRL { var	ajaxRLCookie = ( getCookie( "ajaxload-" + wgPageName ) == "on" ) ? true : false, appTo = ( $( '#WikiaPageHeader' ).length ) ? $( '#WikiaPageHeader' ) : ( $( '#AdminDashboardHeader' ).length ? $( '#AdminDashboardHeader > h1' ) : $( '.firstHeading' ) ); appTo.append( ' ' + refreshText + ':   ' ); $( '#ajaxLoadProgress' ).ajaxSend( function ( event, xhr, settings ) {		if ( location.href == settings.url ) {			$( this ).show;		}	} ).ajaxComplete ( function ( event, xhr, settings ) {		var	$collapsibleElements = $( '#mw-content-text' ).find( '.mw-collapsible' );		if ( location.href == settings.url ) {			$( this ).hide;			for ( var i = 0; i < ajaxCallAgain.length; i++ ) {				ajaxCallAgain[i];			}			if ( $collapsibleElements.length ) {				$collapsibleElements.makeCollapsible;			}			if ( mw.config.get( 'wgNamespaceNumber' ) === -1 && mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Recentchanges' ) {				mw.special.recentchanges.init;                               if ( $( '.mw-recentchanges-table' ).find( '.WikiaDropdown' ).length ) {						RecentChangesLocal.init;				}			}		}	} ); $( '#ajaxToggle' ).click( toggleAjaxReload ); $( '#ajaxToggle' ).attr( 'checked', ajaxRLCookie); if ( getCookie( "ajaxload-" + wgPageName ) == "on" ) { loadPageData; } }

/** * Turn refresh on and off by toggling the checkbox */ function toggleAjaxReload { if ( $( '#ajaxToggle' ).prop( 'checked' ) === true ) { setCookie( "ajaxload-" + wgPageName, "on", 30 ); doRefresh = true; loadPageData; } else { setCookie( "ajaxload-" + wgPageName, "off", 30 ); doRefresh = false; clearTimeout( ajaxTimer ); } }

/** * Does the actual refresh */ function loadPageData { var cC = '#mw-content-text'; $( cC ).load( location.href + " " + cC + " > *", function ( data ) {		if ( doRefresh ) {			ajaxTimer = setTimeout( loadPageData, ajaxRefresh );		}	} ); }

/** * Load the script on specific pages */ $( function {	for ( var x = 0; x < ajaxPages.length; x++ ) {		if ( wgPageName == ajaxPages[x] && $( '#ajaxToggle' ).length === 0 ) {			preloadAJAXRL;		}	} } );

/**	 * Temp Hack: copy the RC filter JS since it can't be accessed * @source  */	RecentChangesLocal = { init: function { this.$table = $( '.mw-recentchanges-table' ); this.$dropdown = this.$table.find( '.WikiaDropdown' ); this.$submit = this.$table.find('input[type="submit"]'); this.$submit.on( 'click.RecentChangesDropdown', $.proxy( this.saveFilters, this ) ); this.$submit.removeAttr( 'disabled' ); //FF clean this.dropdown = new Wikia.MultiSelectDropdown( this.$dropdown ); this.dropdown.on( 'change', $.proxy( this.onChange, this ) ); },		saveFilters: function( event ) { var self = this; event.preventDefault; self.dropdown.disable; self.$submit.attr( 'disabled', 'disabled' ); if ( self.dropdown.getSelectedValues.length === 0 ) { self.dropdown.doSelectAll( true ); }			$.nirvana.sendRequest( {				controller: 'RecentChangesController',				method: 'saveFilters',				data: {					filters: self.dropdown.getSelectedValues				},				type: 'POST',				format: 'json',				callback: function ( data ) {					window.location.reload;				}			} ); }	};

//**Back to top**// importScriptPage('BackToTopButton/code.js', 'dev');

/* tabber: changing the tab displayed by default for certain pages */ /* (source: http://community.wikia.com/wiki/Forum:Extension:Tabber_-_Setting_the_default_tab_displayed) */ if (mw.config.get('wgPageName') === 'Human_Vanguard' || mw.config.get('wgPageName') === 'Human_Infiltrator' || mw.config.get('wgPageName') === 'Human_Adept') { $(window).on('load.tabberhack', function {       $('.tabberlive')[0].tabber.tabShow(1);        $(window).off('load.tabberhack');    }); };

// Written by User:Rappy_4187, Aion Wiki // Added support for Special:Contributions by Foodbandlt $(function {    var rights = {};    var majestic = " Nucl3arsnake ";    var admin = "mech-aug";    var bureaucrat = " nano-aug ";    var staff = "Staff";    var vstf = "VSTF";    // Begin list of accounts given extra user rights icons    //    // Be sure that the last line listed for modified rights is followed by a semi-colon rather than a comma.   //Administrator    rights['Someone is an admin']          = [admin],    rights['Someone else is an admin']     = [admin],   //Bureaucrat and VSTF    rights["ResistanZ"]                     = [bureaucrat, majestic],   //Bureaucrat    rights[""]                    = [bureaucrat],   //Staff    rights[""]                  = [staff];    // End list of accounts given extra user rights icons if (wgPageName.indexOf("Special:Contributions") != -1) { newTitle = fbReturnToTitle.replace("Special:Contributions/", ""); unfinishedTitle = newTitle; while (unfinishedTitle.search("_") > 0) { unfinishedTitle = unfinishedTitle.replace("_", " "); }       userName = unfinishedTitle; } else { userName = wgTitle; userName.replace("User:", ""); }   if (typeof rights[userName] != "undefined") { // remove old rights $('.UserProfileMasthead .masthead-info span.tag').remove; for (var i = 0, len = rights[userName].length; i < len; i++) { // add new rights $(' ' + rights[userName][i] +               ' ').appendTo('.masthead-info hgroup'); }   } });

/** * Helper script for the .hlist class in MediaWiki:Common.css and MediaWiki:Wikia.css * Add pseudo-selector class to last-child list items in IE8 * @source mediawiki.org/wiki/Snippets/Horizontal_lists * @revision 6 (2014-08-23) * @author User:Edokter */ ( function ( mw, $ ) {   var profile = $.client.profile;    if ( profile.name === 'msie' && profile.versionNumber === 8 ) {        mw.hook( 'wikipage.content' ).add( function ( $content ) { $content.find( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' ) .addClass( 'hlist-last-child' ); } );   } }( mediaWiki, jQuery ) );

// ============================================================ // BEGIN Template:Games // ============================================================ // Description: Add icons to article title // Credit:     User:Porter21 (modifications by User:Rappy and User:Gardimuer) $(function addTitleIcons {   if (skin == 'monobook' || skin == 'oasis') {      var insertTarget;      switch (skin) {		case 'monobook':			insertTarget = $('#firstHeading');			break;		case 'oasis':			if (wgAction != 'submit' && wgNamespaceNumber != 112 && $('#va-titleicons').length > 0) {				insertTarget = $('#WikiaPageHeader .tally');				$('#WikiaPageHeader .tally').html(' ').css('width', '200px');			}			break;      }      if (insertTarget) {		$('#va-titleicons').css('display', 'block').prependTo(insertTarget);		$('#va-titleicons-more').append('');		$('#va-titleicons').hover( function { $(this).addClass('va-titleicons-hover'); }, function { $(this).removeClass('va-titleicons-hover'); });     }   } }); // ============================================================ // END Template:Games // ============================================================