User:A proofreader/MediaWiki:Common.js

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

/** * 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) + ";path=/" + ( ( 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 ""; }

/** * Calls wiki API and returns the response in the callback * @param data named array List of parameters to send along with the request. {'format':'json'} is set automatically. * @param method string Either POST or GET. * @param callback function Thing to run when request is complete * @param addurl string (optional) Anything you may want to add to the request url, in case you need it. */

function callAPI(data, method, callback, addurl) { data['format'] = 'json'; $.ajax({		data: data,		dataType: 'json',		url: wgScriptPath + '/api.php' + (addurl?addurl:''),		type: method,		cache: false,		success: function(response) {			if (response.error)				alert('API error: ' + response.error.info);			else 				callback(response);		},		error: function(xhr, error) { alert('AJAX error: ' + error) }	}); }

// http://www.mredkj.com/javascript/numberFormat.html#addcommas function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); }	return x1 + x2; }

/* Add UTC clock above articles */ importScript('MediaWiki:Common.js/displayTimer.js');

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

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

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

/* Intro for Update Namespace */ importScript('MediaWiki:Common.js/updateintro.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", "Forum:Yew_Grove", "RuneScape:Page_maintenance", "Special:AbuseLog", "Special:NewFiles", "Category:Speedy_deletion_candidates", "Category:Speedy_move_candidates", "Special:Statistics", "Special:NewPages", "Special:ListFiles"];

var AjaxRCRefreshText = 'Auto-refresh'; importScript('MediaWiki:Common.js/ajaxrefresh.js');

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

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

/* Copyright notice for Oasis */ /* importScript('MediaWiki:Common.js/copyright.js'); */

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

/* Chat advertisement */ importScript('MediaWiki:Common.js/chat.js');

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

/* Add MyContributions to AccountNavigation */ importScript('MediaWiki:Common.js/accountNavigation.js');

/* HighlightTables */ importScript('MediaWiki:Common.js/highlightTable.js');

/* PengLocations */ importScript('MediaWiki:Common.js/pengLocations.js');

/* Pagetitle rewrite */ importScript('MediaWiki:Common.js/pagetitle.js');

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

/* Autosort code */ importScript('User:Tyilo/autosort.js');

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

/* CVU report script */ importScript('User:Suppa_chuppa/cvu.js');

/* Joey's Monster Calc added per Forum:Calculators in infoboxes */ importScript('User:Joeytje50/monstercalc.js');

/* RC Patrol script */ if(wgPageName == 'RuneScape:RC_Patrol') importScript('User:Suppa_chuppa/rcpatrol.js'); importStylesheet('User:Suppa_chuppa/rcp.css');

/* Joey's Dropadd script */ importScript('User:Joeytje50/Dropadd.js')

/* Masthead box script */ importScript('MediaWiki:Common.js/mastheadBoxes.js');

/* Sign reminder per Forum:Script to ensure people sign their comments */ importScript('User:Tyilo/signature.js');

/* Calculator script Forum:New javascript calculators */ $(function{ if ($('.jcInput').length||$('[class*="jcPane"]').length) {	importScript('User:Stewbasic/calc.js'); }});

/* Local copy of Search.js */ importScript('MediaWiki:Common.js/Search.js');

// ================================================================== // Adding links to On the Wiki tab and change PHOTOS to FILES // ================================================================== $(document).ready(function {   if ( skin == 'oasis' && $.inArray("staff", wgUserGroups) == -1) {        $('.WikiHeaderRestyle nav ul li.marked ul').prepend('About usDisclaimer');    } });

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

// ================================================================== // Item Compare Overlays (Beta) // ================================================================== $(function {	if ($('#WikiaArticle .cioCompareLinkBeta,#bodyContent .cioCompareLinkBeta').size > 0) {		importScript('MediaWiki:Common.js/compareBeta.js');		importStylesheet('MediaWiki:Common.css/compareBeta.css');	} });

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

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

// ================================================================== // 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 // ================================================================== if (wgUserName != null && (wgPageName == 'User:' + wgUserName.replace(/ /g,'_') + '/skin.css' || wgPageName == 'User:' + wgUserName.replace(/ /g,'_') + '/skin.js')) { window.location.href = window.location.href.replace(/\/skin.(css|js)/i, '/' + skin.replace('oasis', 'wikia') + '.' + wgPageName.split('/')[1].split('.')[1]); }

/* Hide edit button on Exchange pages for anons */ function AnonMessage { if(wgUserGroups == null) { $('.anonmessage').css('display', 'inline'); } } addOnloadHook(AnonMessage)

/* Redirect non-wikia skin users to the correct link for Special:Chat */

if(wgCanonicalSpecialPageName == 'Chat' && skin != 'oasis') {	window.location.search = window.location.search + (window.location.search? '&': '?') + 'useskin=oasis'; }

// ================================================================== // Description: Make the Apple Touch Icon better on the iOS. Wiki.png //             does not suite it at this current time. // ================================================================== if ( wgNamespaceNumber !=undefined && !window.appleicon ) { addOnloadHook( setappleicon ); } var appleicon = true; function setappleicon { $('head link[rel="apple-touch-icon"]').replaceWith(''); }

//temporary fix for talk page comments bug if ($('.wikia-button.comments.secondary').attr('href') == '#WikiaArticleComments' && skin == 'oasis') { $(document).ready(function {       $('.wikia-button.comments.secondary').attr('href', '/wiki/Talk:' + wgPageName).html($('.wikia-button.comments.secondary').html.replace('Comments', 'Discussion'))    }) }

/* For RuneScape:Survey */ importScript('User:Quarenon/survey.js') /* */