MediaWiki:Common.js

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

/* Main page */

/**************************************************************/ /* sliders using jquery by User:Tierrie in Dragon Age Wiki */ /**************************************************************/ mw.loader.using(['jquery.ui.tabs'], function {   $(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 = 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 var tpm; if (diff < 0) { diff = -diff; tpm = 'T plus '; } else { 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 = []; // 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 // **************************************************

/* 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');    }); }

/** * 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 {   var insertTarget;

if (wgAction != 'submit' && wgNamespaceNumber != 112 && $('#va-titleicons').length > 0) { insertTarget = $('#WikiaPageHeader .tally'); $('#WikiaPageHeader .tally').html(' ').css('width', '200px'); }   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 // ============================================================