MediaWiki:Wikia.js/sidebar.js


 * ( function ( $, mw ) {

'use strict'; var // -- BEGIN CONFIG -- /**		 * Replace these when updating for events and such * 		 * Remember to keep the comma or semi-colon at the end of each line */		// the date of the event eventDay = 19,    //day of month, 1-31 eventMonth = 12,  //month of year, 1-12 eventYear = 2015, //year // title of the sidebar box headerText = "RuneScape Wiki Christmas Party!", // fullpagename of page to link to		// use underscores instead of spaces and check capitalisation linkPagename = "RuneScape:Events Team/Christmas Party", // text to be linked linkDescription = "Come and join us for a Christmas party full of prizes this Saturday at 8 pm UTC/4 pm EST!", // -- advanced options -- // number of days to show the sidebar for // default 3, don't need to change unless an event needs to be very highly advertised // (or some other thing being used) daysToShow = 3, // time UTC to show the box until; default 23 (11pm) showUntilTime = 23, // override to ignore date and just show it until this value is changed back to false showBoxOverride = false, // -- END CONFIG -- //utility vars _time_diff = Date.UTC(eventYear, eventMonth-1, eventDay, showUntilTime) - Date.now; function addRSWGuideModule { $( ' ' )			.attr('id', 'RSWCustomModule') .attr( 'class', 'RSWGuide module' ) .append(				$( ' ' )					.css( { 'margin-top': '0px', 'margin-bottom': '10px' } )					// Head text for module					.text( headerText )			) .append(				$( ' ' )					.append( $( ' ' )							.append(								$( '' )									.attr( 'href', mw.util.wikiGetlink( linkPagename ) )									.text( linkDescription )							) )			)			.insertBefore( '.ChatModule' ); }	function init( i ) { //load once if ($('#RSWCustomModule').length) { mw.log('RSWCustomModule already loaded'); return; }		if ( i === undefined ) { mw.log('intitialising i'); i = 0; }		if ( $( '.ChatModule' ).length ) { mw.log('found ChatModule, adding RSWCustomModule'); addRSWGuideModule; return; }		if (i < 60) { //retry for 10 seconds mw.log('Failed to find ChatModule, waiting 500ms...'); i++; setTimeout( function {				init( i );			}, 500 ); }	}	if ( showBoxOverride || (_time_diff > 0 && _time_diff < daysToShow*24*60*60*1000) ) { mw.log('Loading RSWCustomModule'); mw.loader.using( ['mediawiki.util'], function {			$( function  { init(0); });		} );	}

}( this.jQuery, this.mediaWiki ) );