MediaWiki:Common.js

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

/*** Cookie accessor functions ***/ function setCookie(name, value, expires) { var d = new Date; d.setDate(d.getDate + expires); document.cookie = name + '=' + escape(value) + ';path=/'; } function getCookie(name) { if (document.cookie.length > 0) { var start = document.cookie.indexOf(name + '='); if (start != -1) { start = start + name.length + 1; var end = document.cookie.indexOf(';', start); if (end == -1) { end = document.cookie.length; }			return unescape(document.cookie.substring(start, end)); } 	}	return ''; }

/* Embeds IRC in pages */ importScript('MediaWiki:Common.js/embedirc.js‎');

/* Adds a Watchlist link to the Page Bar */ importScript('MediaWiki:Common.js/watchlistlink.js');

/* Custom edit buttons */ importScript('MediaWiki:Common.js/CEB.js');

/* Intro for Exchange Namespace */ importScript('MediaWiki:Common.js/exchangeintro.js');

var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show"; var maxHeight = 300;

/* Dynamic Navigation Bars */ importScript('MediaWiki:Common.js/navigationbars.js');

/* Dynamic Navigation Bars (2) */ importScript('MediaWiki:Common.js/navigationbars2.js');

/*-- Collapsible Tables --*/ importScript('MediaWiki:Common.js/collapsibletables.js');

/* Standard Edit Summaries */ importScript('MediaWiki:Common.js/standardeditsummaries.js');

/* Ajax Auto-Refresh (courtesy pcj) */ var ajaxPages = ["Special:RecentChanges", "Special:Watchlist", "Special:Log","Special:Contributions"]; var AjaxRCRefreshText = 'Auto-refresh'; importScriptPage('AjaxRC/code.js', 'dev');

/* Count-down Timer */ importScript('MediaWiki:Common.js/countdowntimer.js');

/* Embedding hack for multi-media files */ importScript('MediaWiki:Common.js/embedding.js');

/* Site Meter */ importScript('MediaWiki:Common.js/sitemeter.js');

/* Added SiteNotice Functionality */ importScript('MediaWiki:Common.js/sitenotice.js');

// ================================================================== // Item Compare Overlays // ================================================================== $(document).ready(function {	if ($('.cioCompareLink').size > 0) {		importScript('User:Quarenon/compare.js');		importStylesheet('User:Quarenon/compare.css');	} });

// ================================================================== // Dynamic Templates // ================================================================== $(document).ready(function {	if ($('.jcConfig').size > 0) {		importScript('MediaWiki:Common.js/calc.js');		importStylesheet('MediaWiki:Common.css/calc.css');	} });

// ================================================================== // Insert username // ================================================================== function UserNameReplace { if(typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace || wgUserName == null) return; $("span.insertusername").html(wgUserName); } addOnloadHook(UserNameReplace);

// ================================================================== // Changes 'article' to 'main page' on the monobook skin // ================================================================== function monobookMainPageFix { var nstab = document.getElementById("ca-nstab-main"); if (nstab && wgUserLanguage == "en") { while (nstab.firstChild) nstab = nstab.firstChild; nstab.nodeValue = "Main page"; } } if (wgPageName == "Supernatural_Wiki" || wgPageName == "Talk:Supernatural_Wiki") { addOnloadHook(monobookMainPageFix); }

// ================================================================== // Hide Auto-uploads // ================================================================== if (wgCanonicalNamespace == "Special" && wgCanonicalSpecialPageName == "Log") { importScript('User:AzBot/HideBotUploads.js'); }

// ================================================================== // Description: Redirects from /User:UserName/skin.js or .css to the user's actual skin page // Maintainer: Cacycle // ================================================================== if (wgArticleId == 0 && wgUserName) { var slash = wgPageName.indexOf('/'); var norm = wgPageName.substr(0, slash) + wgPageName.substr(slash).toLowerCase; var test = 'User:' + wgUserName.replace(/ /g, '_') + '/skin.'; var ext = null; if (norm == test + 'js') ext = 'js'; else if (norm == test + 'css') ext = 'css'; if (ext != null) window.location.href = window.location.href.replace(/\/skin.(css|js)/i, '/' + skin.replace('oasis', 'wikia') + '.' + ext); }

// ================================================================== // Adds row marking to the penguin locations table on the DnD Locations article // ================================================================== $(document).ready(function {	var pengCookieLen = 20;	var pengCookie = getCookie('pengLocations').split('');

function rowHighlight(el, val) { var cssText = ''; if (val == '2') { cssText = 'background-color: #CCC !important'; } else if (val == '1') { cssText = 'background-color: #CFC !important'; }		$(el).children('td').css('cssText', cssText); }

function save { setCookie('pengLocations', pengCookie.join(''), 60 * 60 * 24 * 7); }

if (wgPageName == 'Distractions_and_Diversions_Locations') { while (pengCookie.length < pengCookieLen) { pengCookie.push('0'); }

$('#penglocations tr').each(function(i) {			rowHighlight(this, pengCookie[i]);

$(this).mouseover(function {				rowHighlight(this, 2);			}).mouseout(function {				rowHighlight(this, pengCookie[i]);			}).click(function {				pengCookie[i] = 1 - pengCookie[i];				rowHighlight(this, pengCookie[i]);				save;			}); });

$('#penglocations').append(			$(' ').append( $(' ').attr('colspan', '7').append(					$(' ').attr('type', 'button').val('Reset marked locations').click(function { $('#penglocations tr').each(function(i) {							pengCookie[i] = '0';							rowHighlight(this, pengCookie[i]);						}); save; })				)			)		);	} });

// Disable the button to add images to existing galleries $(function{	$('#bodyContent .wikia-gallery-add a').unbind('click').click(function{return false;}); });

/*-- GEMW updating interface on exchange pages and item infoboxes --*/ importScript('User:Quarenon/gemwupdate.js');

/*-- Konami code: added per Forum:Add Konami code --*/ importScript('MediaWiki:Common.js/Konami.js');

// ===================================================================== // Pagetitle rewrite // // Rewrites the page's title, used by Template:Title // // ===================================================================== $(function{ var newTitle = $("#title-meta").html; if (!newTitle) return; var edits = $("#user_masthead_since").text; $(".firstHeading,#WikiaUserPagesHeader h1,#WikiaPageHeader h1").html(newTitle); $(".#user_masthead_head h2").html(newTitle + "" + edits + " "); });

/* */