MediaWiki:Common.js

/* */

importScript( 'User:Grunny/ajaxcloakrequest.js' );

// onload stuff var firstRun = true;

function loadFunc { if( firstRun ) { firstRun = false; } else { return; }

window.pageName = wgPageName; window.storagePresent = (typeof(localStorage) != 'undefined');

// DEPRECATED if( document.getElementById('infoboxinternal') != null && document.getElementById('infoboxend') != null ) { document.getElementById('infoboxend').innerHTML = '[Hide]'; }

// Upload form - need to run before adding hide buttons if ( wgCanonicalSpecialPageName === 'Upload' ) { setupUploadForm; }

addHideButtons;

if( document.getElementById('mp3-navlink') !== null ) { document.getElementById('mp3-navlink').onclick = onArticleNavClick; document.getElementById('mp3-navlink').getElementsByTagName('a')[0].href = 'javascript:void(0)'; }

if( window.storagePresent ) { initVisibility; }

fillEditSummaries; fillPreloads;

substUsername; substUsernameTOC; rewriteTitle; showEras('title-eraicons'); showEras('title-shortcut'); rewriteHover; addAlternatingRowColors; // replaceSearchIcon; this is now called from MediaWiki:Monobook.js	fixSearch; hideContentSub;

var body = document.getElementsByTagName('body')[0]; var bodyClass = body.className;

if( !bodyClass || (bodyClass.indexOf('page-') === -1) ) { var page = window.pageName.replace(/\W/g, '_'); body.className += ' page-' + page; }

if( typeof(onPageLoad) != "undefined" ) { onPageLoad; } }

function infoboxToggle { var page = window.pageName.replace(/\W/g, '_'); var nowShown;

if(document.getElementById('infoboxtoggle').innerHTML == '[Hide]') { document.getElementById('infoboxinternal').style.display = 'none'; document.getElementById('infoboxtoggle').innerHTML = '[Show]'; nowShown = false; } else { document.getElementById('infoboxinternal').style.display = 'block'; document.getElementById('infoboxtoggle').innerHTML = '[Hide]'; nowShown = true; }

if(window.storagePresent) { localStorage.setItem('infoboxshow-' + page, nowShown); } }

/** * jQuery version of Sikon's fillEditSummaries * @author Grunny */ function fillEditSummaries {

if( !$( '#wpSummaryLabel' ).length ) { return; }	var	summaryOptionsHtml = '', $summaryOptionsList, $summaryLabel = $( '#wpSummaryLabel' );

$.get( wgScript, { title: 'Template:Stdsummaries', action: 'raw', ctype: 'text/plain' } ).done( function( data ) {		var lines = data.split( '\n' );		for( var i = 0; i < lines.length; i++ ) {			var value = ( lines[i].indexOf( '-- ' ) === 0 ) ? lines[i].substring(3) : "";			summaryOptionsHtml += '' + lines[i] + ' ';		}		$summaryOptionsList = $( ' ' ).attr( 'id', 'stdEditSummaries' ).html( summaryOptionsHtml ).change( function { var value = $( this ).val; if ( value !== '' ) { if( skin === 'oasis' ) { $( '#wpSummary' ).text( value ); } else { $( '#wpSummary' ).val( value ); }			}		} );

$summaryLabel.prepend( 'Standard summaries: ', $summaryOptionsList, ' ' ); } );

}

/** * jQuery version of Sikon's fillPreloads * @author Grunny */ function fillPreloads {

if( !$( '#lf-preload' ).length ) { return; }	var	preloadOptionsHtml = '', $preloadOptionsList;

$( '#lf-preload' ).attr( 'style', 'display: block' );

$.get( wgScript, { title: 'Template:Stdpreloads', action: 'raw', ctype: 'text/plain' } ).done( function( data ) {		var lines = data.split( '\n' );		for( var i = 0; i < lines.length; i++ ) {			var value = ( lines[i].indexOf( '-- ' ) === 0 ) ? lines[i].substring(3) : "";			preloadOptionsHtml += '' + lines[i] + ' ';		}		$preloadOptionsList = $( ' ' ).attr( 'id', 'stdSummaries' ).html( preloadOptionsHtml ).change( function { var value = $( this ).val; if ( value !== '' ) { value = 'Template:' + value + '/preload'; value = value.replace( ' ', '_' ); $.get( wgScript, { title: value, action: 'raw', ctype: 'text/plain' } ).done( function( data ) {					insertAtCursor( document.getElementById( 'wpTextbox1' ), data );				} ); }		} );

$( '#lf-preload-cbox' ).html( $preloadOptionsList ); } );

$( '#lf-preload-pagename' ).html( '' ); $( '#lf-preload-button' ).html( '' );

}

function doCustomPreload { var value = $( '#lf-preload-pagename > input' ).val; value = value.replace( ' ', '_' ); $.get( wgScript, { title: value, action: 'raw', ctype: 'text/plain' } ).done( function( data ) {		insertAtCursor( document.getElementById( 'wpTextbox1' ), data );	} ); }

// ============================================================ // BEGIN JavaScript title rewrite -- jQuery version and new wikia skin fixes by Grunny

function rewriteTitle { if( typeof( window.SKIP_TITLE_REWRITE ) != 'undefined' && window.SKIP_TITLE_REWRITE ) { return; }

if( $('#title-meta').length == 0 ) { return; }

var newTitle = $('#title-meta').html; if( skin == "oasis" ) { $('header.WikiaPageHeader > h1').html(' ' + newTitle + ' '); $('header.WikiaPageHeader > h1').attr('style','text-align:' + $('#title-align').html + ';'); } else { $('.firstHeading').html(' ' + newTitle + ' '); $('.firstHeading').attr('style','text-align:' + $('#title-align').html + ';'); } }

function showEras(className) { if( skin == 'oasis' ) { return; }

if( typeof( SKIP_ERAS ) != 'undefined' && SKIP_ERAS ) return;

var titleDiv = document.getElementById( className );

if( titleDiv == null || titleDiv == undefined ) return;

var cloneNode = titleDiv.cloneNode(true); var firstHeading = getFirstHeading; firstHeading.insertBefore(cloneNode, firstHeading.childNodes[0]); cloneNode.style.display = "block"; } // END JavaScript title rewrite

function initVisibility { var page = window.pageName.replace(/\W/g,'_'); var show = localStorage.getItem('infoboxshow-' + page);

if( show == 'false' ) { infoboxToggle; }

var hidables = getElementsByClass('hidable');

for(var i = 0; i < hidables.length; i++) { show = localStorage.getItem('hidableshow-' + i + '_' + page);

if( show == 'false' ) { var content = getElementsByClass('hidable-content', hidables[i]); var button = getElementsByClass('hidable-button', hidables[i]);

if( content != null && content.length > 0 &&				button != null && button.length > 0 && content[0].style.display != 'none' ) {				button[0].onclick('bypass'); }		} else if( show == 'true' ) { var content = getElementsByClass('hidable-content', hidables[i]); var button = getElementsByClass('hidable-button', hidables[i]);

if( content != null && content.length > 0 &&				button != null && button.length > 0 && content[0].style.display == 'none' ) {				button[0].onclick('bypass'); }		}	} }

function onArticleNavClick { var div = document.getElementById('mp3-nav');

if( div.style.display == 'block' ) div.style.display = 'none'; else div.style.display = 'block'; }

function addAlternatingRowColors { var infoboxes = getElementsByClass('infobox', document.getElementById('content'));

if( infoboxes.length == 0 ) return;

for( var k = 0; k < infoboxes.length; k++ ) { var infobox = infoboxes[k];

var rows = infobox.getElementsByTagName('tr'); var changeColor = false;

for( var i = 0; i < rows.length; i++ ) { if(rows[i].className.indexOf('infoboxstopalt') != -1) break;

var ths = rows[i].getElementsByTagName('th');

if( ths.length > 0 ) { continue; }

if(changeColor) rows[i].style.backgroundColor = '#f9f9f9'; changeColor = !changeColor; }	} }

function addHideButtons { var hidables = getElementsByClass('hidable');

for( var i = 0; i < hidables.length; i++ ) { var box = hidables[i]; var button = getElementsByClass('hidable-button', box, 'span');

if( button != null && button.length > 0 ) { button = button[0];

button.onclick = toggleHidable; button.appendChild( document.createTextNode('[Hide]') );

if( new ClassTester('start-hidden').isMatch(box) ) button.onclick('bypass'); }	} }

function toggleHidable(bypassStorage) { var parent = getParentByClass('hidable', this); var content = getElementsByClass('hidable-content', parent); var nowShown;

if( content != null && content.length > 0 ) { content = content[0];

if( content.style.display == 'none' ) { content.style.display = content.oldDisplayStyle; this.firstChild.nodeValue = '[Hide]'; nowShown = true; } else { content.oldDisplayStyle = content.style.display; content.style.display = 'none'; this.firstChild.nodeValue = '[Show]'; nowShown = false; }

if( window.storagePresent && ( typeof( bypassStorage ) == 'undefined' || bypassStorage != 'bypass' ) ) { var page = window.pageName.replace(/\W/g, '_'); var items = getElementsByClass('hidable'); var item = -1;

for( var i = 0; i < items.length; i++ ) { if( items[i] == parent ) { item = i;					break; }			}

if( item == -1 ) { return; }

localStorage.setItem('hidableshow-' + item + '_' + page, nowShown); }	} }

/*   Replaces  with the name of the user browsing the page. Requires copying Template:USERNAME. function substUsername { $('.insertusername').text(wgUserName); }

function substUsernameTOC { var toc = $('#toc'); var userpage = $('#pt-userpage');

if( !userpage || !toc ) return;

var username = $('#pt-userpage').children(':first-child').text; $('span.toctext:not(:has(*)), span.toctext i', toc).each(function	{		$(this).text($(this).text.replace(' ', username));	}); }

function fixSearch { var button = document.getElementById('searchSubmit');

if( button ) button.name = 'go'; }

/** * Start upload form customisations * @author Green tentacle */

function setupUploadForm{ // Check if cookie has been set for form style. Overrides URL parameter if set. var formstyle = localStorage.getItem("uploadform");

$("#uploadBasicLinkJS").show; $("#uploadTemplateNoJS").hide;

var wpLicense = $('#wpLicense');

if ( wpLicense.length && window.location.search.indexOf('wpForReUpload=1') == -1){ if (formstyle == "guided" || (formstyle == "" && window.location.search.indexOf('basic=true') == -1)){ // Add link to basic form $("#uploadtext").prepend(' Switch to basic upload form ');

// Stretch table to full width $('#mw-htmlform-description').css('width', '100%');

// Bind upload button to verify function $('#mw-upload-form').bind('submit', verifySummary);

// Hide existing rows var rows = $('#mw-htmlform-description').find('tr'); $('tr.mw-htmlform-field-HTMLTextAreaField').hide; $('tr.mw-htmlform-field-HTMLTextAreaField').next.detach;

$('#mw-htmlform-description').addClass('hidable start-hidden');

// Add new required rows rows.eq(1).after(' Source:  '); $('#mw-htmlform-description').append(' '); var tbody1 = $('#mw-htmlform-description').children('tbody').eq(0); tbody1.append(' Description:  '); tbody1.append(' Optional fields  ');

// Add new optional rows var tbody2 = $('#mw-htmlform-description').children('tbody').eq(1); tbody2.append(' <td class="mw-label" style="width: 125px;">Attention: <td class="mw-input"><textarea id="attentionBox" cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Original designer / artist: <td class="mw-input"><textarea id="authorBox" cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Conversion / editing / upload information: <td class="mw-input"><textarea id="filespecsBox" cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Other versions / source images: <td class="mw-input"><textarea id="versionsBox" cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Artist categories: <td class="mw-input"><textarea id="catartistBox" cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Licensee categories: <td class="mw-input"><textarea id="catlicenseeBox" cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Subject categories: <td class="mw-input"><textarea id="catsubjectBox" cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Type categories: <td class="mw-input"><textarea id="cattypeBox" cols="60" rows="2" style="overflow: auto;"> '); } else { // Old style form just needs Information template in the summary box $('#wpUploadDescription').val('==Summary==\r\n');

// Add link to guided form $("#uploadtext").prepend(' Switch to guided upload form</a> '); }	} }

function verifySummary{ var wpLicense = document.getElementById('wpLicense');

// Check for licensing if ( wpLicense.value == "" ){ alert('Licensing must be completed.'); return false; }

// Check for source if ( document.getElementById('sourceBox').value == "" ){ alert('Source must be completed.'); return false; }

var strBuilder = '==Summary==\r\n';

document.getElementById('wpUploadDescription').value = strBuilder;

wpLicense.selectedIndex = 0;

return true; }

/** * End upload form customisations */

/************************************************************ * Functions.js stuff * Deprecated, most of these functions will be removed slowly ************************************************************/

/*   Source: http://www.dustindiaz.com/getelementsbyclass/ getElementsByClass, which complements getElementById and getElementsByTagName, returns an array of all subelements of node that are tagged with a specific CSS class (searchClass) and are of the tag name tag. If tag is null, it searches for any suitable elements regardless of the tag name. Example: getElementsByClass('infobox', document.getElementById('content'), 'div') selects the same elements as the CSS declaration #content div.infobox function getElementsByClass(searchClass, node, tag) {	var classElements = new Array;

if(node == null) node = document;

if(tag == null) tag = '*';

var els = node.getElementsByTagName(tag); var elsLen = els.length; var tester = new ClassTester(searchClass);

for(i = 0, j = 0; i < elsLen; i++) {		if(tester.isMatch(els[i])) {			classElements[j] = els[i]; j++; }	}	return classElements; }

function ClassTester(className) {	this.regex = new RegExp("(^|\\s)" + className + "(\\s|$)"); }

ClassTester.prototype.isMatch = function(element) {	return this.regex.test(element.className); } /*   end getElementsByClass

function insertAtCursor(myField, myValue) { //IE support if (document.selection) {		myField.focus; sel = document.selection.createRange; sel.text = myValue; }	//MOZILLA/NETSCAPE support else if(myField.selectionStart || myField.selectionStart == '0') {		var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); }	else {		myField.value += myValue; } }

function getFirstHeading { var elements = getElementsByClass('firstHeading', document.getElementById('content'), 'h1'); return (elements != null && elements.length > 0) ? elements[0] : null; }

/*   Returns the element's nearest parent that has the specified CSS class. function getParentByClass(className, element) { var tester = new ClassTester(className); var node = element.parentNode;

while(node != null && node != document) {		if(tester.isMatch(node)) return node;

node = node.parentNode; }

return null; }

/*   Performs dynamic hover class rewriting to work around the IE6 :hover bug (needs CSS changes as well) function rewriteHover { var gbl = document.getElementById("hover-global");

if(gbl == null) return;

var nodes = getElementsByClass("hoverable", gbl);

for (var i = 0; i < nodes.length; i++) { nodes[i].onmouseover = function { this.className += " over"; }		nodes[i].onmouseout = function { this.className = this.className.replace(new RegExp(" over\\b"), ""); }	} } /************************************************************ * End old Functions.js stuff * Deprecated, most of these functions will be removed slowly ************************************************************/

$( loadFunc );

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// ADVANCED AJAX AUTO-REFRESHING ARTICLES // Code originally by "pcj" of Wowpedia // Maintenance, cleanup, style and bug fixes by Grunny (http://starwars.wikia.com/wiki/User:Grunny)

///////////////////////////////////////////////////////////////////////////////////////////////////////////

window.ajaxIndicator = 'http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif'; window.AjaxRCRefreshText = 'Automatically refresh'; window.AjaxRCRefreshHoverText = 'Enable auto-refreshing page loads'; window.ajaxPages = [ 'Special:RecentChanges', 'Special:Watchlist', 'Special:Log', 'Special:NewFiles', 'Special:AbuseLog' ];

( function ( window, $, mw, Wikia ) {	'use strict';

var config = mw.config.get( [			'stylepath',			'wgAction',			'wgCanonicalSpecialPageName',			'wgPageName'		] ), // use common file as it's very likely to be already cached by user // used in oasis sidebar loading, preview modal, etc.		ajaxIndicator = window.ajaxIndicator || config.stylepath + '/common/images/ajax.gif', ajaxTimer, refreshText = typeof window.AjaxRCRefreshText === 'string' ? window.AjaxRCRefreshText : 'AJAX', refreshHover = typeof window.AjaxRCRefreshHoverText === 'string' ? window.AjaxRCRefreshHoverText : 'Enable auto-refreshing page loads', ajRefresh = window.ajaxRefresh || 60000, ajPages = window.ajaxPages || [ 'Special:RecentChanges' ], RecentChangesLocal, // don't load on these values of wgAction // @todo check if markpatrolled should be here disallowActions = [ 'delete', 'edit', 'protect', 'revisiondelete' ];

function storage( setTo ) { if ( localStorage.getItem( 'AjaxRC-refresh' ) === null ) { localStorage.setItem( 'AjaxRC-refresh', true ); }

if ( setTo === false ) { localStorage.setItem( 'AjaxRC-refresh', false ); } else if ( setTo === true ) { localStorage.setItem( 'AjaxRC-refresh', true ); }

return JSON.parse( localStorage.getItem( 'AjaxRC-refresh' ) ); }

/**	 * Main function to start the Auto-refresh process */	function preloadAJAXRL { // monobook var $appTo = $( '.firstHeading' ).length ? $( '.firstHeading' ) : // most oasis pages ( $( '#WikiaPageHeader' ).length ? $( '#WikiaPageHeader' ) :				// most oasis special pages				( $( '#AdminDashboardHeader' ).length ? $( '#AdminDashboardHeader > h1' ) : false ) ), $checkbox = $( ' ' ) .css( { 'font-size': 'xx-small', 'line-height': '100%', 'margin-left': '5px' } ) .append(					$( '<label id="ajaxToggleText" for="ajaxToggle"> ' )						.css( { 'border-bottom': '1px dotted', 'cursor': 'help' } )						.attr( 'title', refreshHover ).text( refreshText + ':' ),					$( '<input type="checkbox" id="ajaxToggle">' ).css( { 'margin-bottom': 0 } ),					$( ' ' ).css( 'display', 'none' ).append( $( ' ' ).css( { 'vertical-align': 'baseline', 'float': 'none', 'border': 0 } ) .attr( 'src', ajaxIndicator ).attr( 'alt', 'Refreshing page' ) )				),			$throbber;

// fallback for pages with profile masthead if ( $appTo === false ) { $( '#WikiaArticle' ).prepend( $checkbox ); } else { $appTo.append( $checkbox ); }

$throbber = $appTo.find( '#ajaxLoadProgress' );

$( document ).ajaxSend( function ( event, xhr, settings ) {			if ( location.href === settings.url ) {				$throbber.show;			}		} ).ajaxComplete ( function ( event, xhr, settings ) {

var $collapsibleElements = $( '#mw-content-text' ).find( '.mw-collapsible' ), ajCallAgain = window.ajaxCallAgain || [], i;

if ( location.href === settings.url ) { $throbber.hide; if ( $collapsibleElements.length ) { $collapsibleElements.makeCollapsible; }				if ( config.wgCanonicalSpecialPageName === 'Recentchanges' ) { mw.special.recentchanges.init; if ( $( '.mw-recentchanges-table' ).find( '.WikiaDropdown' ).length ) { RecentChangesLocal.init; }				}				if ( config.wgCanonicalSpecialPageName === 'WikiActivity' ) { window.WikiActivity.init; }				for ( i = 0; i < ajCallAgain.length; i++ ) { ajCallAgain[i]; }			}		} );		$( '#ajaxToggle' ).click( toggleAjaxReload );		$( '#ajaxToggle' ).attr( 'checked', storage );		if ( storage ) {			loadPageData;		}	}

/**	 * Turn refresh on and off by toggling the checkbox */	function toggleAjaxReload { if ( $( '#ajaxToggle' ).prop( 'checked' ) === true ) { storage( true ); loadPageData; } else { storage( false ); clearTimeout( ajaxTimer ); }	}

/**	 * Does the actual refresh */	function loadPageData { var $temp = $( ' ' );

$temp.load( location.href + ' #mw-content-text', function {			var $newContent = $temp.children( '#mw-content-text' );

if ( $newContent.length ) { $( '#mw-content-text' ).replaceWith( $newContent ); }

ajaxTimer = setTimeout( loadPageData, ajRefresh ); } );		$temp.remove;	}

/**	 * Load the script on specific pages * and only on certain values for wgAction (see disallowActions above) */	$( function {		if ( $.inArray( config.wgPageName, ajPages ) !== -1 && $( '#ajaxToggle' ).length === 0 && $.inArray( config.wgAction, disallowActions ) === -1 ) {			preloadAJAXRL;		}	} );

/**	 * Temp Hack: copy the RC filter JS since it can't be accessed * @source <https://github.com/Wikia/app/blob/dev/extensions/wikia/RecentChanges/js/RecentChanges.js> */	RecentChangesLocal = { init: function { this.$table = $( '.mw-recentchanges-table' ); this.$dropdown = this.$table.find( '.WikiaDropdown' ); this.$submit = this.$table.find('input[type="submit"]'); this.$submit.on( 'click.RecentChangesDropdown', $.proxy( this.saveFilters, this ) ); this.$submit.removeAttr( 'disabled' ); //FF clean this.dropdown = new Wikia.MultiSelectDropdown( this.$dropdown ); this.dropdown.on( 'change', $.proxy( this.onChange, this ) );

},

saveFilters: function( event ) { var self = this;

event.preventDefault;

self.dropdown.disable; self.$submit.attr( 'disabled', 'disabled' );

if ( self.dropdown.getSelectedValues.length === 0 ) { self.dropdown.doSelectAll( true ); }

$.nirvana.sendRequest( {				controller: 'RecentChangesController',				method: 'saveFilters',				data: {					filters: self.dropdown.getSelectedValues				},				type: 'POST',				format: 'json',				callback: function ( data ) {					window.location.reload;				}			} ); }	};

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

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// END OF AJAX AUTO-REFRESH

///////////////////////////////////////////////////////////////////////////////////////////////////////////

//Link FA

var FA_enabled = true;

function addfaicon { // if disabled if (!FA_enabled) return; var pLang = document.getElementById("p-lang"); if (!pLang) return; var lis = pLang.getElementsByTagName("li"); for (var i = 0; i < lis.length; i++) { var li = lis[i]; // only links with a corresponding Link_FA template are interesting if (!document.getElementById(li.className + "-fa"))  continue; // additional class so the template can be hidden with CSS li.className += " FA"; // change title (mouse over) li.title = "This article is rated as featured article."; } } addOnloadHook(addfaicon);

/* Magic edit intro. Copied from Wikipedia's MediaWiki:Common.js * modified for use in both Monaco and Monobook skins by Sikon * Section edit links added by Green tentacle * New Wikia skin support by Grunny */ function addEditIntro(name) { // Top link if( skin == 'oasis' ) { $('a[data-id="edit"]').attr('href',$('a[data-id="edit"]').attr('href') + '&editintro=' + name); $('span.editsection > a').each( function {			$(this).attr('href',$(this).attr('href') + '&editintro=' + name);		} ); } else { var el = document.getElementById('ca-edit');

if( typeof(el.href) == 'undefined' ) { el = el.getElementsByTagName('a')[0]; }

if (el) el.href += '&editintro=' + name;

// Section links var spans = document.getElementsByTagName('span'); for ( var i = 0; i < spans.length; i++ ) { el = null;

if (spans[i].className == 'editsection') { el = spans[i].getElementsByTagName('a')[0]; if (el) el.href += '&editintro=' + name; } else if (spans[i].className == 'editsection-upper') { el = spans[i].getElementsByTagName('a')[0]; if (el) el.href += '&editintro=' + name; }		}	} }

$( function {	if ( wgNamespaceNumber === 0 ) {		var cats = document.getElementById( 'mw-normal-catlinks' );		if ( !cats ) {			return;		}		cats = cats.getElementsByTagName( 'a' );		for ( var i = 0; i < cats.length; i++ ) {			if ( cats[i].title === 'Category:Wookieepedia featured articles' ) {				addEditIntro( 'Template:Featured_editintro' );				break;			} else if ( cats[i].title === 'Category:Wookieepedia good articles' ) {				addEditIntro( 'Template:Good_editintro' );				break;			} else if ( cats[i].title === 'Category:Wookieepedia comprehensive articles' ) {				addEditIntro( 'Template:Comprehensive_editintro' );				break;			} else if ( cats[i].title === 'Category:Articles undergoing major edits' || cats[i].title === 'Category:Works in progress' ) {				addEditIntro( 'Template:Inuse_editintro‎' );				break;			} else if ( wgPageName === 'Template:DYK editintro' ) {				addEditIntro( 'Template:Good_editintro' ); break; }		}	} else if ( wgPageName === 'Template:DidYouKnow' ) { addEditIntro( 'Template:DYK_editintro' ); } } );

// Main Page JS transform. Originally from Wikipedia:MediaWiki:Monobook.js/Wikipedia:MediaWiki:Common.js and may be further modified for local use. function mainPageRenameNamespaceTab { try { var Node = document.getElementById( 'ca-nstab-main' ).firstChild; if ( Node.textContent ) {     // Per DOM Level 3 Node.textContent = 'Main Page'; } else if ( Node.innerText ) { // IE doesn't handle .textContent Node.innerText = 'Main Page'; } else {                      // Fallback Node.replaceChild( Node.firstChild, document.createTextNode( 'Main Page' ) ); }	} catch(e) { // bailing out! } }

if ( wgTitle == 'Main Page' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) ) { addOnloadHook( mainPageRenameNamespaceTab ); } /** Archive edit tab disabling ************************************* * Disables the edit tab on old forum topic pages to stop noobs bumping old topics. * Page can still be edited by going via the edit tab on the history etc, or by * typing the edit address manually. * By Spang * Monaco support by User:Uberfuzzy * Oasis support by User:Uberfuzzy * Removal of section edit buttons and new section tab on talk pages added by Grunny * User:/User talk: support and styling in new skin by Grunny */ function disableOldForumEdit { if( typeof( enableOldForumEdit ) != 'undefined' && enableOldForumEdit ) { return; }	if( !document.getElementById('old-forum-warning') ) { return; }

if( skin == 'oasis' ) { if( wgNamespaceNumber == 2 || wgNamespaceNumber == 3 ) { $("#WikiaUserPagesHeader .wikia-menu-button li a:first").html('Archived').removeAttr('href').attr('style', 'color: darkgray;'); $('span.editsection').remove; return; } else { $("#WikiaPageHeader .wikia-menu-button a:first").html('Archived').removeAttr('href').attr('style', 'color: darkgray;'); $('span.editsection').remove; return; }	}

if( !document.getElementById('ca-edit') ) { return; }

if( skin == 'monaco' ) { editLink = document.getElementById('ca-edit'); } else if( skin == 'monobook' ) { editLink = document.getElementById('ca-edit').firstChild; } else { return; }

editLink.removeAttribute('href', 0); editLink.removeAttribute('title', 0); editLink.style.color = 'gray'; editLink.innerHTML = 'Archived';

$('span.editsection-upper').remove; $('span.editsection').remove;

appendCSS( '#control_addsection, #ca-addsection { display: none !important; }' ); } addOnloadHook( disableOldForumEdit );

//Removes the "Featured on:" line on File pages -- By Grunny addOnloadHook( function {	if ( wgNamespaceNumber == 6 && $('#file').length != 0 ) {		$('#file').html($('#file').html.replace(/Featured on\:(.*?)\<br\>/, ''));	} } );

/** * Show/hide for media timeline -- Grunny **/ $( function {	if( !$( '.timeline-toggles' ).length ) {		return;	}	$( '.timeline-toggles' ).find( 'td > a' ).click( function  { var	hideBtnClass = $( this ).parent.attr( 'class' ), $hideContent = $( 'tr.' + hideBtnClass ); if( !$hideContent.length ) { return; }		$hideContent.toggle; if ( $( this ).text.indexOf( 'hide' ) >= 1 ) { $( this ).text( $( this ).text.replace( 'hide', 'show' ) ); } else { $( this ).text( $( this ).text.replace( 'show', 'hide' ) ); }	} ); } );

// Lazy load SWTOR article appearances list $( function lazyLoadTorApp {	var	pageName = 'Star_Wars:_The_Old_Republic',		appPageName = encodeURIComponent( pageName + '/Appearances' ),		$lazyLoadEl = $( '#WookTorLazyload' ),		includeHtml,		$editLink;	if ( mw.config.get( 'wgPageName' ) !== pageName || !$lazyLoadEl.length ) {		return;	}

$lazyLoadEl.html( '<img src="http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif" style="vertical-align: baseline;" border="0" alt="Loading..." />' ); $.getJSON( '/api.php?action=parse&page=' + appPageName + '&format=json' ) .done( function ( data ) {			if ( data.parse && data.parse.text ) {				includeHtml = data.parse.text['*'];				$lazyLoadEl.html( includeHtml );				addHideButtons;				$editLink = $lazyLoadEl.prev( 'h2' ).find( '.editsection a' );				if ( $editLink.length ) {					$editLink.attr( 'href', '/index.php?title=' + appPageName + '&action=edit' );				}			}		} ); } );

/** * Hides the link to parent pages from subpages if is included **/ function hideContentSub { if ( mw.config.get( 'wgNamespaceNumber' ) === 0 || $( '#hideContentSub' ).length > 0 ) { if ( mw.config.get( 'skin' ) === 'oasis' ) { var	$wikiaHeader = $( '#WikiaPageHeader h2' ), $backToPageLink; if ( mw.config.get( 'wgNamespaceNumber' ) % 2 === 1 ) { // ugly hack to only leave back to page link on talk pages $backToPageLink = $wikiaHeader.find( 'a[accesskey="c"]' ); $wikiaHeader.html( '' ).append( $backToPageLink ); } else { $wikiaHeader.hide; }		} else { $( '#contentSub span.subpages' ).hide; }	} }

//