MediaWiki:Common.js

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

if (wgAction == "edit" || wgAction == "submit") {

/***** Custom edit buttons *****/ if (mwCustomEditButtons) {

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/c/c8/Button_redirect.png", "speedTip": "Redirect", "tagOpen": "#REDIRECT ",        "tagClose": "", "sampleText": "Insert text"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images3.wikia.nocookie.net/central/images/4/4a/Button_table.png", "speedTip": "Insert a table", "tagOpen": '{| class="wikitable"\n|-\n', "tagClose": "\n|}", "sampleText": "! header 1\n! header 2\n! header 3\n|-\n| row 1, cell 1\n| row 1, cell 2\n| row 1, cell 3\n|-\n| row 2, cell 1\n| row 2, cell 2\n| row 2, cell 3"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/central/images/1/13/Button_enter.png", "speedTip": "Line break", "tagOpen": " ", "tagClose": "", "sampleText": ""};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/central/images/1/12/Button_gallery.png", "speedTip": "Insert a picture gallery", "tagOpen": "\n ", "sampleText": "Image:Example.jpg|Caption1\nImage:Example.jpg|Caption2"}; } }

// ============================================================ // EDIT-INTRO FIX for Exchange articles // // This script is modified from English Wikipedia // Source: http://en.wikipedia.org/wiki/User:RockMFR/disambigeditintro.js // Function: Adds EditIntro to all Exchange pages //          when "edit this page" link is clicked // ============================================================

function fixEditIntro { if (wgCanonicalNamespace == "Exchange" && document.getElementById("ca-edit")) { var editLinks = document.getElementById("ca-edit").getElementsByTagName("a"); if (editLinks.length > 0) { editLinks[0].href += "&editintro=Template:ExchangeItemHelp"; }   } } addOnloadHook(fixEditIntro);

// ============================================================ // End of EDIT-INTRO FIX // ============================================================

// ============================================================ // TUTORIAL IMAGE DUPLICATION FIX for Exchange articles // // Function: Removes duplicate tutorial images from //          Exchange articles // ============================================================

function fixDuplicateTutorial { if (wgCanonicalNamespace == "Exchange") { var matchText = "Price_update_tutorial"

// Search for duplicate images with matchText var c = 0; for(var i=0; i1) { document.images[i].height="0"; document.images[i].width="0"; }           }        }    } } addOnloadHook(fixDuplicateTutorial);

// ============================================================ // End of TUTORIAL IMAGE DUPLICATION FIX // ============================================================

// ============================================================ // a test script to try to copy the [show] | [hide] feature currently in toc panels // ============================================================

var expandoShowText = "show"; var expandoHideText = "hide";

// the initAllToggles function has to be called *after* the page has finished loading otherwise the dom nodes // won't actually exist when we try to get references to them. the hookEvent function is defined in wikibits.js // and provides a mechanism for adding functions to the list of callbacks to run when a particular event // occurs. we'll use this to register a callback for the page load event, which happens after everything has // been loaded from the server. at that point the dom onodes will exist so we can safely try to get references // to them. hookEvent( "load", initAllExpandos );

// initialise all known expando panels on the page. function initAllExpandos { // check the 'initExpando' function is defined and set the 'show' and 'hide' text if it is	if (window.initExpando) { // add a line here to initialise each known expando panel. keep the name short to // avoid storing more data than necessary in the cookie. this will keep bandwidth // usage to a minimum since the cookie is sent to the server at every page request. initExpando("userbox"); // user box panel }; };

// initialise the specified expando panel. we'll add a new node that contains the // [ show | hide ] text and then automatically make sure the panel is in the correct state // by reading the cookie and checking what the last saved value was. function initExpando(name) { if (document.createTextNode) { // Uses DOM calls to avoid document.write + XHTML issues var expandoTitle = document.getElementById(name + '-title'); if (!expandoTitle) { return; }		// this section of code manipulates the dom tree and inserts a new toggle link span that contains the 'show' and 'hide' links. // dom tree before: // title // 		//  ...		// 		// dom tree after // title [%expandoHideText%] // 		//  ...		// 		var outerSpan = document.createElement('span'); outerSpan.className = 'togglespan'; var toggleLink = document.createElement('a'); toggleLink.id = name + '-link'; toggleLink.className = 'internal'; toggleLink.href = 'javascript:flipExpando(\'' + name + '\')'; toggleLink.appendChild(document.createTextNode(expandoHideText)); outerSpan.appendChild(document.createTextNode('[')); outerSpan.appendChild(toggleLink); outerSpan.appendChild(document.createTextNode(']')); expandoTitle.appendChild(document.createTextNode(' ')); expandoTitle.appendChild(outerSpan); // now we need to check whether the panel should be in 'show' mode or 'hide' mode when the page initialises var cookiePos = document.cookie.indexOf("hide" + name + "="); if (cookiePos > -1 && document.cookie.charAt(cookiePos + ("hide" + name + "=").length) == 1) { flipExpando(name); }	} }

// flips the current state of the specified expando panel. it if's currently expanded it will be collapsed // and vice versa. also updates the local cookie so that we can remember the state when we come back to // the current page. note that the changeText function is defined in wikibits.js. function flipExpando( name ) { // get references to the body content and toggle link for this named panel var expandoBody = document.getElementById(name + '-body'); var expandoLink = document.getElementById(name + '-link'); // check if the panel is in expanded or collapsed mode, then switch the mode and update the cookie if (expandoBody && expandoLink && expandoBody.style.display == 'none') { changeText(expandoLink, expandoHideText); expandoBody.style.display = 'block'; document.cookie = "hide" + name + "=0"; }	else { changeText(expandoLink, expandoShowText); expandoBody.style.display = 'none'; document.cookie = "hide" + name + "=1"; } }

// ============================================================ // BEGIN Dynamic Navigation Bars (experimantal) // This script is from Wikipedia. For author attribution, please see http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&action=history // ============================================================

/* Test if an element has a certain class ************************************** * * Description: Uses regular expressions and caching for better performance. * Maintainers: User:Mike Dillon, User:R. Koot, User:SG */

var hasClass = (function {    var reCache = {};    return function (element, className) {        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);   }; });

// ===================================================================== // Collapsible Tables // // Description: Allows tables to be collapsed, showing only the header. // Reference:  Wikipedia:Wikipedia:NavFrame //             Wikipedia:Help:Collapsing // Maintainers: Wikipedia:User:R. Koot // // ===================================================================== var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show"; function collapseTable( tableIndex ) {     var Button = document.getElementById( "collapseButton" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex ); if ( !Table || !Button ) { return false; }     var Rows = Table.getElementsByTagName( "tr" ); if ( Button.firstChild.data == collapseCaption ) { for ( var i = 1; i < Rows.length; i++ ) { Rows[i].style.display = "none"; }         Button.firstChild.data = expandCaption; } else { for ( var i = 1; i < Rows.length; i++ ) { Rows[i].style.display = Rows[0].style.display; }         Button.firstChild.data = collapseCaption; } }  function createCollapseButtons {     var tableIndex = 0; var NavigationBoxes = new Object; var Tables = document.getElementsByTagName( "table" ); for ( var i = 0; i < Tables.length; i++ ) { if ( hasClass( Tables[i], "collapsible" ) ) { /* Only add button and increment count if there is a header row to work with */ var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; if (!HeaderRow) continue; var Header = HeaderRow.getElementsByTagName( "th" )[0]; if (!Header) continue;

NavigationBoxes[ tableIndex ] = Tables[i]; Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex ); var Button    = document.createElement( "span" ); var ButtonLink = document.createElement( "a" ); var ButtonText = document.createTextNode( collapseCaption ); Button.style.styleFloat = "right"; Button.style.cssFloat = "right"; Button.style.fontWeight = "normal"; Button.style.textAlign = "right"; Button.style.width = "6em"; ButtonLink.style.color = Header.style.color; ButtonLink.setAttribute( "id", "collapseButton" + tableIndex ); ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) ); Header.insertBefore( Button, Header.childNodes[0] ); tableIndex++; }     }      for ( var i = 0;  i   ";

sidebar.innerHTML += comboString; }

if(skin == "monaco") { var sidebar = document.getElementById("102_wg");

if(sidebar == null) return;

var comboString = " Wiki Site Meter"; comboString += " ";

sidebar.innerHTML += comboString; } } addOnloadHook(wikiSiteMeter);

// ============================================================ // End of wikiSiteMeter // ============================================================

/* */