MediaWiki:Common.js

$(function {	$("#BtnAWK").click(function { $(".evolution").css("display", "none"); $("#TextAWK").css("display", "block"); });	$("#Btn5").click(function { $(".evolution").css("display", "none"); $("#Text5").css("display", "block"); });	$("#Btn4").click(function { $(".evolution").css("display", "none"); $("#Text4").css("display", "block"); });	$("#Btn3").click(function { $(".evolution").css("display", "none"); $("#Text3").css("display", "block"); });	$("#Btn2").click(function { $(".evolution").css("display", "none"); $("#Text2").css("display", "block"); });	$("#Btn1").click(function { $(".evolution").css("display", "none"); $("#Text1").css("display", "block"); }); });

/* Any JavaScript here will be loaded for users using the 2 column main page layout */ /***************************************** /* Front Page column height equalization * /*****************************************/ // Author: Shawn Bruckner // Date:   2015-Feb-12 // License: CC-BY 3.0 // Version: beta /* var fp = fp || { equalizeColumns : function { $( '.fpcontent' ).each( function {      fp.resetSectionBoxHeights( $( this ).find( '#fptopsection, #fpflexsection, #fpbottomsection' ) );    } ); var excludeSel = ''; if ( $( window ).width > 1539 ) { excludeSel = '.fpmaybercol'; // at this width, it's necessary to hit those boxes in a separate pass after .fpcontent }   if ( $( window ).width > 889 ) { fp.equalizeColumnsOfBlock( '.fpcontent',                                '#fptopsection, #fpbottomsection',                                 '#fpbottomsection',                                 '#fpflexsection',                                 '#fpflexsection',                                 excludeSel                               ); }   if ( $( window ).width > 1539 ) { fp.equalizeColumnsOfBlock( '.fpmaybecols',                                '.fpmaybelcol',                                 '.fpmaybelcol',                                 '.fpmaybercol',                                 '.fpmaybercol',                                 ''                               ); } },

equalizeColumnsOfBlock : function( blockSel, leftSel, leftBottomSel, rightSel, rightBottomSel, excludeSel ) { $( blockSel ).each( function ( index ) {     var tryCount = 0;      do {        var leftBottom = $( this ).find( leftBottomSel ).offset.top + $( this ).find( leftBottomSel ).height;        var rightBottom = $( this ).find( rightBottomSel ).offset.top + $( this ).find( rightBottomSel ).height;

var difference = Math.round( Math.abs( rightBottom - leftBottom ) ); if ( leftBottom < rightBottom ) { fp.adjustSectionBoxHeights( difference, $( this ).find( leftSel ).not( excludeSel ) ); } else if ( rightBottom < leftBottom ) { fp.adjustSectionBoxHeights( difference, $( this ).find( rightSel ).not( excludeSel ) ); }       ++tryCount; } while ( Math.round( leftBottom ) != Math.round( rightBottom ) && tryCount < 4 ); } ); },

resetSectionBoxHeights : function ( sections ) { sections.each( function {      $( this ).find( '.fpbox' ).each( function  { $( this ).height( 'auto' ); } );   } );  },

adjustSectionBoxHeights : function ( heightToAdd, sections ) { var boxCount = 0; sections.each( function {     boxCount += $( this ).find( '.fpbox' ).length;    } );

var avgHeightToAdd = heightToAdd / boxCount; var decimalPortion = 0.0; var boxes, heightToAdd; sections.each( function {     boxes = $( this ).find( '.fpbox' );

boxes.each( function {       heightToAdd = Math.round( decimalPortion + avgHeightToAdd );         decimalPortion += avgHeightToAdd - heightToAdd;        $( this ).height( $( this ).height + heightToAdd );      } ); } ); } };

$( document ).ready( fp.equalizeColumns ); $( window ).resize( fp.equalizeColumns ); */ /********************************************* /* End Front Page column height equalization * /*********************************************/

/************************* * JQuery Random Plugin * *************************/

/** * Adds a 'random' filter to jQuery, which selects 1 or more elements at random for the current jQuery set. * Defaults to 1 element if a amount isn't given. */

jQuery.fn.random = function(count) { var count = (typeof count !== 'undefined') ? count : 1; // Return the current set if an invalid count is asked for. if ( count < 1 || count >= this.length || ! Number.isInteger(Number(count)) ) { return jQuery(this); }

var indexes = []; var resultset = []; while ( indexes.length < count ) { // Generate a random index var index = Math.floor(Math.random * this.length); // reroll the random index if it's already present var reroll = false; for (var i = 0; i < indexes.length; i++) { if ( indexes[i] == index ) { reroll = true; }       }        if (reroll) { continue; }

// Add the index/element to the result set indexes.push(index); resultset.push(this[index]); }   return jQuery(resultset); }

/***************** * Random subset * *****************/

/** * A random subset of list elements within elements with the 'random-subset' class are show, while the rest are hidden. * The 'data-random-subset-count' attribute can be used to specify the number of elements to be displayed. */

$('.random-subset').each(function {   var count = 1;    // If the data-random-subset-count attribute is present use that count    if ($(this).attr('data-random-subset-count')) {        count = $(this).attr('data-random-subset-count');    }    var entries = $(this).find('li');    $(entries).random(entries.length - count).remove;    // show the root element in case it was hidden while waiting for JS.    $(this).show; });

/************** * Countdown *

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

/** * Countdown * * @version 2.1 * * @author Pecoes  * @author Asaba  * * Version 1 authors: * - Splarka  * - Eladkse  * * documentation and examples at: *  */ /*jshint jquery:true, browser:true, devel:true, camelcase:true, curly:false, undef:true, bitwise:true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, unused:true, regexp:true, strict:true, trailing:false */ /*global mediaWiki:true*/ 'use strict'; var translations = $.extend(true, {		// English (English)		en: {			and: 'and',			second: 'second',			seconds: 'seconds',			minute: 'minute',			minutes: 'minutes',			hour: 'hour',			hours: 'hours',			day: 'day',			days: 'days'		}	}, module.translations || {}), i18n = translations[ mw.config.get('wgContentLanguage') ] || translations.en; var countdowns = []; var NO_LEADING_ZEROS = 1, SHORT_FORMAT = 2, NO_ZEROS = 4; function output (i, diff) { /*jshint bitwise:false*/ var delta, result, parts = []; delta = diff % 60; result = ' ' + i18n[delta === 1 ? 'second' : 'seconds']; if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1); parts.unshift(delta + result); diff = Math.floor(diff / 60); delta = diff % 60; result = ' ' + i18n[delta === 1 ? 'minute' : 'minutes']; if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1); parts.unshift(delta + result); diff = Math.floor(diff / 60); delta = diff % 24; result = ' ' + i18n[delta === 1 ? 'hour'  : 'hours'  ]; if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1); parts.unshift(delta + result); diff = Math.floor(diff / 24); result = ' ' + i18n[diff === 1 ? 'day'   : 'days'   ]; if (countdowns[i].opts & SHORT_FORMAT) result = result.charAt(1); parts.unshift(diff + result); result = parts.pop; if (countdowns[i].opts & NO_LEADING_ZEROS) { while (parts.length && parts[0][0] === '0') { parts.shift; }		}		if (countdowns[i].opts & NO_ZEROS) { parts = parts.filter(function(part) {				return part[0] !== '0';			}); }		if (parts.length) { if (countdowns[i].opts & SHORT_FORMAT) { result = parts.join(' ') + ' ' + result; } else { result = parts.join(', ') + ' ' + i18n.and + ' ' + result; }		}		countdowns[i].node.text(result); }	function end(i) { var c = countdowns[i].node.parent; switch (c.attr('data-end')) { case 'remove': c.remove; return true; case 'stop': output(i, 0); return true; case 'toggle': var toggle = c.attr('data-toggle'); if (toggle && toggle == 'next') { c.next.css('display', 'inline'); c.css('display', 'none'); return true; }			if (toggle && $(toggle).length) { $(toggle).css('display', 'inline'); c.css('display', 'none'); return true; }			break; case 'callback': var callback = c.attr('data-callback'); if (callback && $.isFunction(module[callback])) { output(i, 0); module[callback].call(c); return true; }			break; }		countdowns[i].countup = true; output(i, 0); return false; }	function update { var now = Date.now; var countdownsToRemove = []; $.each(countdowns.slice(0), function (i, countdown) {			var diff = Math.floor((countdown.date - now) / 1000);			if (diff <= 0 && !countdown.countup) {				if (end(i)) countdownsToRemove.push(i);			} else {				output(i, Math.abs(diff));			}		}); var x;		while((x = countdownsToRemove.pop) !== undefined) { countdowns.splice(x, 1); }		if (countdowns.length) { window.setTimeout(function {				update;			}, 1000); }	}	function getOptions (node) { /*jshint bitwise:false*/ var text = node.parent.attr('data-options'), opts = 0; if (text) { if (/no-leading-zeros/.test(text)) { opts |= NO_LEADING_ZEROS; }			if (/short-format/.test(text)) { opts |= SHORT_FORMAT; }			if (/no-zeros/.test(text)) { opts |= NO_ZEROS; }		}		return opts; }	function init { var countdown = $('.countdown:not(.handled)'); if (!countdown.length) return; $('.nocountdown').css('display', 'none'); countdown .css('display', 'inline') .find('.countdowndate') .each(function {			var $this = $(this),				date = (new Date($this.text)).valueOf;			if (isNaN(date)) {				$this.text('BAD DATE');				return;			}			countdowns.push({ node: $this, opts: getOptions($this), date: date, });		});		countdown.addClass('handled'); if (countdowns.length) { update; }	}	mw.hook('wikipage.content').add(init); }(window.countdownTimer = window.countdownTimer || {}, mediaWiki, jQuery));
 * (function (module, mw, $, undefined) {

// End Countdown