Difference between revisions of "MediaWiki:Common.js"

From Coastal Wiki
Jump to: navigation, search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
if (typeof usersignature == 'undefined') var usersignature = '-- \~\~\~\~';
 
if (typeof usersignature == 'undefined') var usersignature = '-- \~\~\~\~';
 
+
/**
//==========================================================================================================
+
* Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
// General purpose popup code
+
* loaded for all users on every wiki page. If possible create a gadget that is
//==========================================================================================================
+
* enabled by default instead of adding it here (since gadgets are fully
 
+
* optimized ResourceLoader modules with possibility to add dependencies etc.)
function getXEBPopupDiv(name)
+
*
{
+
* Since Common.js isn't a gadget, there is no place to declare its
XEBMainDiv= document.getElementById("XEB");
+
* dependencies, so we have to lazy load them with mw.loader.using on demand and
if(XEBMainDiv==null){
+
* then execute the rest in the callback. In most cases these dependencies will
XEBMainDiv=document.createElement("div");
+
* be loaded (or loading) already and the callback will not be delayed. In case a
document.body.appendChild(XEBMainDiv);
+
* dependency hasn't arrived yet it'll make sure those are loaded before this.
XEBMainDiv.id="XEB";
+
*/
}
+
 
+
/* global mw, $, importStylesheet, importScript */
me= document.getElementById("XEBPopup" & name);
+
/* jshint curly:false eqnull:true, strict:false, browser:true */
if(!(me==null))return me;
+
me=document.createElement("div");
+
mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
XEBMainDiv.appendChild(me);
+
/* Begin of mw.loader.using callback */
 
+
me.id="XEBPopup";
+
/**
me.style.position='absolute';
+
* Main Page layout fixes
me.display='none';
+
*
me.visibility='hidden';
+
* Description: Adds an additional link to the complete list of languages available.
me.onmouseout=CheckHideXEBPopup;
+
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
me.onmouseover=cancelHidePopup;
+
*/
return me;
+
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
 +
    $( function () {
 +
        mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
 +
            'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
 +
    } );
 +
}
 +
 +
/**
 +
* Redirect User:Name/skin.js and skin.css to the current skin's pages
 +
* (unless the 'skin' page really exists)
 +
* @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 +
* @rev: 2
 +
*/
 +
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
 +
    var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
 +
    /* Make sure there was a part before and after the slash
 +
      and that the latter is 'skin.js' or 'skin.css' */
 +
    if ( titleParts.length == 2 ) {
 +
        var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
 +
        if ( titleParts.slice( -1 ) == 'skin.js' ) {
 +
            window.location.href = mw.util.getUrl( userSkinPage + '.js' );
 +
        } else if ( titleParts.slice( -1 ) == 'skin.css' ) {
 +
            window.location.href = mw.util.getUrl( userSkinPage + '.css' );
 +
        }
 +
    }
 
}
 
}
 
   
 
   
//Function:
+
/**
// CheckHideXEBPopup
+
* Map addPortletLink to mw.util
//Purpose:
+
*
// Looks at the cursor position and if it has moved outside the popup it will close the popup
+
* @deprecated: Use mw.util.addPortletLink instead.
//Called:
+
*/
// When the onMouseEvent is fired on the popup
+
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink,
 
+
'Use mw.util.addPortletLink instead' );
function CheckHideXEBPopup(e){
+
m= document.getElementById("XEBmnu");
+
/**
if(is_gecko)
+
* Extract a URL parameter from the current URL
{
+
*
ph=m.offsetHeight;
+
* @deprecated: Use mw.util.getParamValue with proper escaping
var x=e.clientX + window.scrollX;
+
*/
var y=e.clientY + window.scrollY;;
+
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
s=window.getComputedStyle(m,"");
+
ph=s.height;
+
/**
ph=Number(ph.substring(0,ph.length-2));
+
* Test if an element has a certain class
}
+
*
else
+
* @deprecated: Use $(element).hasClass() instead.
{
+
*/
var x=event.clientX+ document.documentElement.scrollLeft + document.body.scrollLeft;
+
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
var y=event.clientY+ document.documentElement.scrollTop + document.body.scrollTop;
+
    return $( element ).hasClass( className );
ph=m.offsetHeight;
+
}, 'Use jQuery.hasClass() instead' );
 +
 +
/**
 +
* @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
 +
* @rev 5
 +
*/
 +
// CSS
 +
var extraCSS = mw.util.getParamValue( 'withCSS' );
 +
if ( extraCSS ) {
 +
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
 +
importStylesheet( extraCSS );
 +
} else {
 +
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
 
}
 
}
pl=curPopup.x;
 
pt=curPopup.y;
 
pw=m.style.width;
 
pw=Number(pw.substring(0,pw.length-2));
 
 
if(x>(pl+2)&&x<(pl+pw-5)&&y>(pt+2)&&y<(pt+ph-5))return;
 
curPopup.hideTimeout=setTimeout('hideXEBPopup()',XEBHideDelay*1000);
 
 
}
 
}
 
+
function cancelHidePopup()
+
// JS
{
+
var extraJS = mw.util.getParamValue( 'withJS' );
clearTimeout(curPopup.hideTimeout)
+
if ( extraJS ) {
}
+
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
 
+
importScript( extraJS );
function hideXEBPopup(){
+
} else {
XEBMainDiv= document.getElementById("XEB");
+
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
m= document.getElementById("XEBPopup");
 
XEBMainDiv.removeChild(m);
 
}
 
 
 
function XEBstartDrag(e)
 
{
 
m=new GetPos(e||event);
 
curPopup.startDrag.mouse=m;
 
curPopup.startDrag.floatpopup.y=parseInt(curPopup.div.style.top);
 
curPopup.startDrag.floatpopup.x=parseInt(curPopup.div.style.left);
 
curPopup.dragging=true;
 
}
 
 
 
function XEBstopDrag(e)
 
{
 
if(curPopup.dragging==false)return;
 
curPopup.dragging=false;
 
}
 
 
 
function XEBDrag(e)
 
{
 
if(curPopup.dragging==false)return;
 
 
 
m=new GetPos(e||event);
 
x=parseInt(curPopup.startDrag.floatpopup.x+(m.x-curPopup.startDrag.mouse.x));
 
y=parseInt(curPopup.startDrag.floatpopup.y+(m.y-curPopup.startDrag.mouse.y));
 
 
 
curPopup.div.style.top=y+"px";
 
curPopup.div.style.left=x+"px";
 
 
 
curPopup.x=x;
 
curPopup.y=y;
 
}
 
 
 
//=============================================================================
 
// Popup: Table
 
//=============================================================================
 
 
 
function XEBPopup(name,x,y)
 
{
 
// Make sure the popup can appear on the screen
 
 
 
this.IESelectedRange=XEBgetIESelectedRange();
 
 
 
winW=(is_gecko)?window.innerWidth:document.body.offsetWidth;
 
if((winW-this.width)<x)x=(winW-this.width);
 
 
 
this.div=getXEBPopupDiv(name);
 
this.div.style.zIndex=2000;
 
this.div.display="inline";
 
this.div.visibility="visible";
 
this.div.style.top=y + "px";
 
this.x=x;
 
this.y=y;
 
this.name=name;
 
 
 
this.startDrag=new Object;
 
this.startDrag.floatpopup=new Object;
 
}
 
 
 
function setInnerHTML(text)
 
{
 
winW=(is_gecko)?window.innerWidth:document.body.offsetWidth;
 
if((winW-this.width)<this.x)this.x=(winW-this.width);
 
this.div.style.left=this.x+ "px";
 
 
 
mt="<div id='XEBmnu' style='width:" + this.width + "px' >";
 
mt+='<div id="XEBmnuTitle" class="XEBPopupTitle" onmousedown="XEBstartDrag(event)" onmouseup="XEBstopDrag(event)" onmousemove="XEBDrag(event)">Title</div>'
 
mt+=text;
 
mt+="</div>";
 
this.div.innerHTML=mt;
 
//Turn off autocomplete. If the mouse moves over the autocomplete popup then x,y in CheckHidePopup is relative to the
 
// autocomplete popup and our popup is hidden
 
var InTexts = this.div.getElementsByTagName('input');
 
for (var i = 0; i < InTexts.length; i++) {
 
        var theInput = InTexts[i];
 
if (theInput.type == 'text'){theInput.setAttribute('autocomplete','off');}
 
 
}
 
}
//Add rollover features to menu items. Doing it here means we don't have to do it for each menu
 
x=XEBgetElementsByClassName(this.div,'XEBMnuItm','span');
 
for (var i = 0; i < x.length; i++) {
 
        var theItm = x[i];
 
theItm.onmouseout=XEBMenuMouseOut;
 
theItm.onmouseover=XEBMenuMouseOver;
 
}
 
 
this.div.style.borderWidth='thin';
 
this.div.style.borderStyle='solid';
 
this.div.style.backgroundColor='#D0D0D0';
 
 
}
 
}
XEBPopup.prototype.width=250;
+
XEBPopup.prototype.dragging=false;
+
/**
XEBPopup.prototype.setInnerHTML=setInnerHTML;
+
* Import more specific scripts if necessary
 
+
*/
var curPopup;
+
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) {
 
+
    /* scripts specific to editing pages */
function GetPos(e)
+
    importScript( 'MediaWiki:Common.js/edit.js' );
{
+
} else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
this.x=e.clientX-10+ document.documentElement.scrollLeft + document.body.scrollLeft;
+
    /* watchlist scripts */
this.y=e.clientY-10+ document.documentElement.scrollTop + document.body.scrollTop;
+
    importScript( 'MediaWiki:Common.js/watchlist.js' );
 
}
 
}
 
+
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
function XEBPopupTable(e){
+
    /* file description page scripts */
m=new GetPos(e||event);
+
    importScript( 'MediaWiki:Common.js/file.js' );
 
 
curPopup=new XEBPopup("table",m.x,m.y);
 
 
 
mt='<p>Enter the table parameters below: <\/p>'
 
+'<form name="XEBPopupTableForm">'
 
+'Table caption: <input type="checkbox" name="inputCaption"><p\/>'
 
+'Table alignment: center<input type="checkbox" name="inputAlign"><p\/>'
 
+'Table headline: colored<input type="checkbox" name="inputHead"><p\/>'
 
+'Number of rows: <input type="text" name="inputRow" value="3" size="2"><p\/>'
 
+'Number of columns: <input type="text" name="inputCol" value="3" size="2"><p\/>'
 
//+'Alternating grey lines: <input type="checkbox" name="inputLine" checked="1" ><p\/>'
 
+'Item column: <input type="checkbox" name="inputItems" ><p\/>'
 
+'Sortable: <input type="checkbox" name="inputSort" ><p\/>'
 
+'<\/form>'
 
+'<i>The default table allows for fields and values only.<\/i><p\/>'
 
+'Check "Item column" to allow for the table to have fields, items, and values.<\/i><p\/>'
 
+'<p><button onClick="javascript:insertTableCode()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>'
 
 
 
curPopup.setInnerHTML(mt);
 
 
 
return true;
 
 
}
 
}
 
+
function insertTableCode(){
+
/**
f=document.XEBPopupTableForm;
+
* Load scripts specific to Internet Explorer
var caption = (f.inputCaption.checked)?"|+ TABLE CAPTION \n":"";
+
*/
var exhead = (f.inputHead.checked)?'|- style="background: #DDFFDD;"\n':"";
+
if ( $.client.profile().name === 'msie' ) {
var nbRow = parseInt(f.inputRow.value);
+
    importScript( 'MediaWiki:Common.js/IEFixes.js' );
var nbCol = parseInt(f.inputCol.value);
 
var exfield = f.inputItems.checked;
 
var align = (f.inputAlign.checked)?'align="center"':"";
 
 
 
//generateTable(caption, exhead, nbCol, nbRow, exfield, align);
 
 
 
var code = "\n";
 
code += '{| {{prettytable}} ' + align + ' '; // en: class="wikitable"
 
code+=(f.inputSort.checked)?'class="sortable" \n':'\n';
 
code += caption + exhead;
 
if (exfield) code += '!\n';
 
for (i=1;i<nbCol+1;i++) code += '! FELD ' + i + '\n';
 
var items = 0;
 
for (var j=0;j<nbRow;j++){
 
if (exfield) {
 
items++;
 
code += '|-\n! style="background: #FFDDDD;"|ITEM ' + items + '\n';
 
} else code += '|-\n';
 
for (i=0;i<nbCol;i++) code += '| Element\n';
 
}
 
code += '|}\n';
 
hideXEBPopup();
 
insertTags('','', code);
 
extendSummary('table');
 
 
 
return false;
 
 
 
 
// Get the text currently selected by user in the textAra
 
// This code is based on part of the insertTags function in wikibits.js
 
 
 
function XEBGetSelectedText()
 
{
 
var txtarea;
 
if (document.editform) {
 
txtarea = document.editform.wpTextbox1;
 
} else {
 
// some alternate form? take the first one we can find
 
var areas = document.getElementsByTagName('textarea');
 
 
 
txtarea = areas[0];
 
}
 
// IE & Opera
 
if (document.selection  && !is_gecko)
 
{
 
var theSelection = document.selection.createRange().text;
 
if (!theSelection) theSelection='';
 
}
 
// Mozilla
 
else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
 
var replaced = false;
 
var startPos = txtarea.selectionStart;
 
var endPos = txtarea.selectionEnd;
 
var theSelection = (txtarea.value).substring(startPos, endPos);
 
if (!theSelection) theSelection='';
 
}
 
return theSelection;
 
 
}
 
}
 
+
//Notes:
+
/**
// IE loses the cursor position in the textarea when the popup is used.  
+
* Fix for Windows XP Unicode font rendering
// So we save the cursor position here
+
*/
function XEBgetIESelectedRange(){
+
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
var IESel=new Object;
+
    mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' +
var txtarea;
+
                '.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
if (document.editform) {
 
txtarea = document.editform.wpTextbox1;
 
} else {
 
// some alternate form? take the first one we can find
 
var areas = document.getElementsByTagName('textarea');
 
 
 
txtarea = areas[0];
 
}
 
// IE & Opera
 
 
 
if (document.selection  && !is_gecko)
 
{
 
txtarea.focus();
 
IESel.Rng=document.selection.createRange();
 
return IESel;
 
}
 
 
}
 
}
 
+
function XEBinsertText(beforeText,selText,afterText,IESelectedRange) {
+
/**
var newText=beforeText + selText + afterText;
+
* WikiMiniAtlas
var txtarea;
+
*
if (document.editform) {
+
* Description: WikiMiniAtlas is a popup click and drag world map.
txtarea = document.editform.wpTextbox1;
+
*              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
} else {
+
*              The script itself is located on meta because it is used by many projects.
// some alternate form? take the first one we can find
+
*              See [[Meta:WikiMiniAtlas]] for more information.  
var areas = document.getElementsByTagName('textarea');
+
* Maintainers: [[User:Dschwen]]
txtarea = areas[0];
+
  */
}
+
( function () {
 
+
    var require_wikiminiatlas = false;
// IE
+
    var coord_filter = /geohack/;
if (document.selection && !is_gecko) {
+
    $( function () {
 
+
        $( 'a.external.text' ).each( function( key, link ) {
tr=IESelectedRange.Rng;
+
            if ( link.href && coord_filter.exec( link.href ) ) {
tr.text=newText;
+
                require_wikiminiatlas = true;
txtarea.focus();
+
                // break from loop
//txtarea.caretpos=tr.duplicate();
+
                return false;
tr.select();
+
            }
 
+
        } );
return;
+
        if ( $( 'div.kmldata' ).length ) {
 
+
            require_wikiminiatlas = true;
// Mozilla
+
        }
} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
+
        if ( require_wikiminiatlas ) {
var replaced = false;
+
            mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
var startPos = txtarea.selectionStart;
+
        }
var endPos = txtarea.selectionEnd;
+
    } );
 
+
} )();
if (endPos-startPos) {
+
replaced = true;
+
/**
}
+
* Collapsible tables
var scrollTop = txtarea.scrollTop;
+
*
// var myText = (txtarea.value).substring(startPos, endPos);
+
* Allows tables to be collapsed, showing only the header. See  [[Wikipedia:NavFrame]].
// if (!myText) {
 
// myText=sampleText;
 
// }
 
// if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
 
// subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
 
// } else {
 
// subst = tagOpen + myText + tagClose;
 
// }
 
txtarea.value = txtarea.value.substring(0, startPos) + newText +
 
txtarea.value.substring(endPos, txtarea.value.length);
 
txtarea.focus();
 
//set new selection
 
if (!replaced) {
 
var cPos = startPos+(newText.length);
 
txtarea.selectionStart = cPos;
 
txtarea.selectionEnd = cPos;
 
} else {
 
txtarea.selectionStart = startPos+beforeText.length;
 
txtarea.selectionEnd = startPos+beforeText.length+selText.length;
 
}
 
txtarea.scrollTop = scrollTop;
 
 
 
// All other browsers get no toolbar.
 
// There was previously support for a crippled "help"
 
// bar, but that caused more problems than it solved.
 
}
 
// reposition cursor if possible
 
if (txtarea.createTextRange) {
 
 
 
txtarea.caretPos = document.selection.createRange().duplicate();
 
//txtarea.caretPos =IESelectedRange.Rng;
 
}
 
txtarea.focus();
 
}
 
 
 
 
 
 
 
 
 
/** Collapsible tables *********************************************************
 
 
  *
 
  *
  *  Description: Allows tables to be collapsed, showing only the header. See
+
  * @version 2.0.3 (2014-03-14)
  *               [[Wikipedia:NavFrame]].
+
  * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
  * Maintainers: [[User:R. Koot]]
+
  * @author [[User:R. Koot]]
 +
  * @author [[User:Krinkle]]
 +
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 +
* is supported in MediaWiki core.
 
  */
 
  */
 
   
 
   
 
var autoCollapse = 2;
 
var autoCollapse = 2;
var collapseCaption = "hide";
+
var collapseCaption = 'hide';
var expandCaption = "show";
+
var expandCaption = 'show';
 
   
 
   
 
function collapseTable( tableIndex ) {
 
function collapseTable( tableIndex ) {
var Button = document.getElementById( "collapseButton" + tableIndex );
+
    var Button = document.getElementById( 'collapseButton' + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
+
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );
 +
 +
    if ( !Table || !Button ) {
 +
        return false;
 +
    }
 
   
 
   
if ( !Table || !Button ) {
+
    var Rows = Table.rows;
return false;
+
    var i;
}
 
 
   
 
   
var Rows = Table.rows;
+
    if ( Button.firstChild.data === collapseCaption ) {
 +
        for ( i = 1; i < Rows.length; i++ ) {
 +
            Rows[i].style.display = 'none';
 +
        }
 +
        Button.firstChild.data = expandCaption;
 +
    } else {
 +
        for ( i = 1; i < Rows.length; i++ ) {
 +
            Rows[i].style.display = Rows[0].style.display;
 +
        }
 +
        Button.firstChild.data = collapseCaption;
 +
    }
 +
}
 
   
 
   
if ( Button.firstChild.data == collapseCaption ) {
+
function createClickHandler( tableIndex ) {
for ( var i = 1; i < Rows.length; i++ ) {
+
    return function ( e ) {
Rows[i].style.display = "none";
+
        e.preventDefault();
}
+
        collapseTable( tableIndex );
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() {
 
function createCollapseButtons() {
var tableIndex = 0;
+
    var tableIndex = 0;
var NavigationBoxes = new Object();
+
    var NavigationBoxes = {};
var Tables = document.getElementsByTagName( "table" );
+
    var Tables = document.getElementsByTagName( 'table' );
 +
    var i;
 
   
 
   
for ( var i = 0; i < Tables.length; i++ ) {
+
    for ( i = 0; i < Tables.length; i++ ) {
if ( $(this).hasClass( Tables[i], "collapsible" ) ) {
+
        if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
 
   
 
   
/* only add button and increment count if there is a header row to work with */
+
            /* only add button and increment count if there is a header row to work with */
var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
+
            var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
if (!HeaderRow) continue;
+
            if ( !HeaderRow ) {
var Header = HeaderRow.getElementsByTagName( "th" )[0];
+
                continue;
if (!Header) continue;
+
            }
 +
            var Header = HeaderRow.getElementsByTagName( 'th' )[0];
 +
            if ( !Header ) {
 +
                continue;
 +
            }
 
   
 
   
NavigationBoxes[ tableIndex ] = Tables[i];
+
            NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
+
            Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
 
   
 
   
var Button    = document.createElement( "span" );
+
            var Button    = document.createElement( 'span' );
var ButtonLink = document.createElement( "a" );
+
            var ButtonLink = document.createElement( 'a' );
var ButtonText = document.createTextNode( collapseCaption );
+
            var ButtonText = document.createTextNode( collapseCaption );
 +
            // Styles are declared in [[MediaWiki:Common.css]]
 +
            Button.className = 'collapseButton';
 
   
 
   
Button.style.styleFloat = "right";
+
            ButtonLink.style.color = Header.style.color;
Button.style.cssFloat = "right";
+
            ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
Button.style.fontWeight = "normal";
+
            ButtonLink.setAttribute( 'href', '#' );
Button.style.textAlign = "right";
+
            $( ButtonLink ).on( 'click', createClickHandler( tableIndex ) );
Button.style.width = "6em";
+
            ButtonLink.appendChild( ButtonText );
 
   
 
   
ButtonLink.style.color = Header.style.color;
+
 
ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
+
            Button.appendChild( ButtonLink );
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
+
 
ButtonLink.appendChild( ButtonText );
 
 
   
 
   
Button.appendChild( document.createTextNode( "[" ) );
+
            Header.insertBefore( Button, Header.firstChild );
Button.appendChild( ButtonLink );
+
            tableIndex++;
Button.appendChild( document.createTextNode( "]" ) );
+
        }
 +
    }
 
   
 
   
Header.insertBefore( Button, Header.childNodes[0] );
+
    for ( i = 0;  i < tableIndex; i++ ) {
tableIndex++;
+
        if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
}
+
            ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )
}
+
        ) {
 +
            collapseTable( i );
 +
        }
 +
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
 +
            var element = NavigationBoxes[i];
 +
            while ((element = element.parentNode)) {
 +
                if ( $( element ).hasClass( 'outercollapse' ) ) {
 +
                    collapseTable ( i );
 +
                    break;
 +
                }
 +
            }
 +
        }
 +
    }
 +
}
 
   
 
   
for ( var i = 0;  i < tableIndex; i++ ) {
+
mw.hook( 'wikipage.content' ).add( createCollapseButtons );
if ( $(this).hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && $(this).hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
 
collapseTable( i );
 
}
 
}
 
}
 
 
   
 
   
jQuery(document).ready( createCollapseButtons );
+
/**
 +
* Dynamic Navigation Bars (experimental)
 +
*
 +
* Description: See [[Wikipedia:NavFrame]].
 +
* Maintainers: UNMAINTAINED
 +
*/
 
   
 
   
/** Dynamic Navigation Bars (experimental) *************************************
+
/* set up the words in your language */
  *
+
var NavigationBarHide = collapseCaption;
  *  Description: See [[Wikipedia:NavFrame]].
+
var NavigationBarShow = expandCaption;
  *  Maintainers: UNMAINTAINED
 
  */
 
 
   
 
   
// set up the words in your language
+
/**
var NavigationBarHide = '[' + collapseCaption + ']';
+
* Shows and hides content and picture (if available) of navigation bars
var NavigationBarShow = '[' + expandCaption + ']';
+
* Parameters:
 +
*    indexNavigationBar: the index of navigation bar to be toggled
 +
**/
 +
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
 +
    var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
 +
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
 +
    var NavChild;
 
   
 
   
// shows and hides content and picture (if available) of navigation bars
+
    if ( !NavFrame || !NavToggle ) {
// Parameters:
+
        return false;
//    indexNavigationBar: the index of navigation bar to be toggled
+
    }
function toggleNavigationBar(indexNavigationBar) {
 
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
 
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
 
 
   
 
   
if (!NavFrame || !NavToggle) {
+
    /* if shown now */
return false;
+
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
}
+
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
 +
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
 +
                NavChild.style.display = 'none';
 +
            }
 +
        }
 +
    NavToggle.firstChild.data = NavigationBarShow;
 
   
 
   
// if shown now
+
    /* if hidden now */
if (NavToggle.firstChild.data == NavigationBarHide) {
+
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
for (
+
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
var NavChild = NavFrame.firstChild;
+
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
NavChild != null;
+
                NavChild.style.display = 'block';
NavChild = NavChild.nextSibling
+
            }
) {
+
        }
if ( $(this).hasClass( NavChild, 'NavPic' ) ) {
+
        NavToggle.firstChild.data = NavigationBarHide;
NavChild.style.display = 'none';
+
    }
}
 
if ( $(this).hasClass( NavChild, 'NavContent') ) {
 
NavChild.style.display = 'none';
 
}
 
}
 
NavToggle.firstChild.data = NavigationBarShow;
 
 
   
 
   
// if hidden now
+
    event.preventDefault();
} else if (NavToggle.firstChild.data == NavigationBarShow) {
+
};
for (
 
var NavChild = NavFrame.firstChild;
 
NavChild != null;
 
NavChild = NavChild.nextSibling
 
) {
 
if( $(this).hasClass(NavChild, 'NavPic') ) {
 
NavChild.style.display = 'block';
 
}
 
if( $(this).hasClass(NavChild, 'NavContent') ) {
 
NavChild.style.display = 'block';
 
}
 
}
 
NavToggle.firstChild.data = NavigationBarHide;
 
}
 
}
 
 
   
 
   
// adds show/hide-button to navigation bars
+
/* adds show/hide-button to navigation bars */
 
function createNavigationBarToggleButton() {
 
function createNavigationBarToggleButton() {
var indexNavigationBar = 0;
+
    var indexNavigationBar = 0;
// iterate over all < div >-elements  
+
    var NavFrame;
var divs = document.getElementsByTagName("div");
+
    var NavChild;
for(
+
    /* iterate over all < div >-elements */
var i=0;  
+
    var divs = document.getElementsByTagName( 'div' );
NavFrame = divs[i];  
+
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
i++
+
        /* if found a navigation bar */
) {
+
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
// if found a navigation bar
 
if( $(this).hasClass(NavFrame, "NavFrame") ) {
 
 
   
 
   
indexNavigationBar++;
+
            indexNavigationBar++;
var NavToggle = document.createElement("a");
+
            var NavToggle = document.createElement( 'a' );
NavToggle.className = 'NavToggle';
+
            NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
+
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
+
            NavToggle.setAttribute( 'href', '#' );
 +
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
 
   
 
   
var NavToggleText = document.createTextNode(NavigationBarHide);
+
            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
for (
+
            /**
var NavChild = NavFrame.firstChild;
+
            * Check if any children are already hidden.  This loop is here for backwards compatibility:
NavChild != null;
+
            * the old way of making NavFrames start out collapsed was to manually add style="display:none"
NavChild = NavChild.nextSibling
+
            * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
) {
+
            * the content visible without JavaScript support), the new recommended way is to add the class
if ( $(this).hasClass( NavChild, 'NavPic' ) || $(this).hasClass( NavChild, 'NavContent' ) ) {
+
            * "collapsed" to the NavFrame itself, just like with collapsible tables.
if (NavChild.style.display == 'none') {
+
            */
NavToggleText = document.createTextNode(NavigationBarShow);
+
            for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
break;
+
                if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
}
+
                    if ( NavChild.style.display === 'none' ) {
}
+
                        isCollapsed = true;
}
+
                    }
 +
                }
 +
            }
 +
            if ( isCollapsed ) {
 +
                for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
 +
                    if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
 +
                        NavChild.style.display = 'none';
 +
                    }
 +
                }
 +
            }
 +
            var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
 +
            NavToggle.appendChild( NavToggleText );
 
   
 
   
NavToggle.appendChild(NavToggleText);
+
            /* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
+
            for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
for(
+
                if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
var j=0;
+
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
j < NavFrame.childNodes.length;
+
                    NavFrame.childNodes[j].appendChild( NavToggle );
j++
+
                }
) {
+
            }
if( $(this).hasClass(NavFrame.childNodes[j], "NavHead") ) {
+
            NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
NavFrame.childNodes[j].appendChild(NavToggle);
+
        }
}
+
    }
}
 
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
 
}
 
}
 
 
}
 
}
 
   
 
   
jQuery(document).ready( createNavigationBarToggleButton );
+
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
 
   
 
   
 +
/**
 +
* Uploadwizard_newusers
 +
* Switches in a message for non-autoconfirmed users at [[Wikipedia:Upload]]
 +
*
 +
* Maintainers: [[User:Krimpet]]
 +
*/
 +
function uploadwizard_newusers() {
 +
    if ( mw.config.get( 'wgNamespaceNumber' ) === 4 && mw.config.get( 'wgTitle' ) === 'Upload' && mw.config.get( 'wgAction' ) === 'view' ) {
 +
        var oldDiv = document.getElementById( 'autoconfirmedusers' ),
 +
            newDiv = document.getElementById( 'newusers' );
 +
        if ( oldDiv && newDiv ) {
 +
            var userGroups = mw.config.get( 'wgUserGroups' );
 +
            if ( userGroups ) {
 +
                for ( var i = 0; i < userGroups.length; i++ ) {
 +
                    if ( userGroups[i] === 'autoconfirmed' ) {
 +
                        oldDiv.style.display = 'block';
 +
                        newDiv.style.display = 'none';
 +
                        return;
 +
                    }
 +
                }
 +
            }
 +
            oldDiv.style.display = 'none';
 +
            newDiv.style.display = 'block';
 +
            return;
 +
        }
 +
    }
 +
}
 
   
 
   
/** Test if an element has a certain class **************************************
+
$(uploadwizard_newusers);
  *
 
  * Description: Uses regular expressions and caching for better performance.
 
  * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
 
  */
 
 
   
 
   
var hasClass = (function () {
+
/**
var reCache = {};
+
* Magic editintros ****************************************************
return function (element, className) {
+
*
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
+
* Description: Adds editintros on disambiguation pages and BLP pages.
};
+
* Maintainers: [[User:RockMFR]]
})();
+
*/
 
+
function addEditIntro( name ) {
 
+
    $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
 
+
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
 
+
    } );
//============================================================
 
// Table generator
 
//============================================================
 
/** en: Generate an array using Mediawiki syntax
 
* @author: originally from fr:user:dake
 
* @version: 0.2 */
 
function generateTable(caption, exhead, nbCol, nbRow, exfield, align){
 
 
};
 
 
 
 
 
function XEBPopupRef(e){
 
 
 
m=new GetPos(e||event);
 
 
 
curPopup=new XEBPopup("ref",m.x,m.y);
 
curPopup.width=500;
 
mt='<p>Enter the reference parameters below: <\/p>'
 
+'<form name="XEBPopupRefForm">'
 
+'Name:<input type="text" name="refName" value="" size="10"><p\/>'
 
+'Material:<input type="text" name="refMaterial" value="' + XEBGetSelectedText() + '" size="20">'
 
+'<\/form>'
 
+'<p><button onClick="javascript:insertRef()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>';
 
 
 
curPopup.setInnerHTML(mt);
 
// document.XEBPopupRefForm.refName.focus();
 
return true;
 
 
}
 
}
 
+
function insertRef(){
+
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
f=document.XEBPopupRefForm;
+
    $( function () {
var refName = f.refName.value;
+
        if ( document.getElementById( 'disambigbox' ) ) {
var refMaterial=f.refMaterial.value;
+
            addEditIntro( 'Template:Disambig_editintro' );
+
        }
hideXEBPopup();
+
    } );
var code1='<ref';
+
code1+=(refName)?' name="'+refName+'">':'>';
+
    $( function () {
code2=refMaterial;
+
        var cats = mw.config.get('wgCategories');
code3='<\/ref>'
+
        if ( !cats ) {
XEBinsertText(code1,code2,code3,curPopup.IESelectedRange);
+
            return;
 
+
        }
extendSummary('ref');
+
        if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) {
return false;
+
            addEditIntro( 'Template:BLP_editintro' );
}
+
        }
 
+
    } );
//===GEO LINK Function==================================================
 
 
 
function XEBPopupGeoLink(e)
 
{
 
m=new GetPos(e||event);
 
 
 
curPopup=new XEBPopup("geo",m.x,m.y);
 
curPopup.width=300;
 
mt='<p>Enter the location parameters below: <\/p>'
 
+'<form name="XEBPopupGeoLinkForm">'
 
+'Loction:<p\/>'
 
+'<table style="background: transparent;">'
 
+'<tr><td>Latitude:<\/td><td><input type="text" autocomplete="off" name="geoLatDeg" value="" size="4"><\/td>'
 
+'<td><input type="text" name="geoLatMin" size="4"><\/td>'
 
+'<td><input type="text" name="geoLatSec" size="4"><\/td>'
 
+'<td><select name="geoLatNS"><option value="N">N<option value="S">S</select><\/td><\/tr>'
 
+'<tr><td>Longitude:<\/td><td><input type="text" name="geoLonDeg" value="" size="4"><\/td>'
 
+'<td><input type="text" name="geoLonMin" value="" size="4"><\/td>'
 
+'<td><input type="text" name="geoLonSec" value="" size="4"><\/td>'
 
+'<td><select name="geoLonEW"><option value="E">E<option value="W">W</select><\/td><\/tr>'
 
+'<\/table>'
 
+'Region:<input type="text" name="geoRegion" value="" size="4"><p\/>'
 
+'Type:'
 
+'<SELECT NAME="geoType" size="5">'
 
+'<OPTION VALUE="country">Country<OPTION VALUE="state">State'
 
+'<OPTION VALUE="adm1st">Admin unit, 1st level<OPTION VALUE="adm2st">Admin unit, 2nd level'
 
+'<OPTION VALUE="city">City<OPTION VALUE="airport">Airport'
 
+'<OPTION VALUE="mountain">Mountain<OPTION VALUE="isle">Isle'
 
+'<OPTION VALUE="waterbody">Waterbody<OPTION VALUE="landmark" SELECTED>Landmark'
 
+'<OPTION VALUE="forest">forest</SELECT><br>'
 
+'Title: <input type="checkbox" name="geoTitle" ><p\/>'
 
+'<\/form>'
 
+'<p><button onClick="javascript:insertGeoLink()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>';
 
 
 
curPopup.setInnerHTML(mt);
 
document.paramForm.refName.focus();
 
return true;
 
 
 
}
 
function insertGeoLink()
 
{
 
f=document.XEBPopupGeoLinkForm;
 
 
 
var code='{{Coor ';
 
if(f.geoTitle.checked)code+='title ';
 
ft='dms';
 
if(f.geoLatSec.value==''&&f.geoLonSec.value=='')ft='dm';
 
if(ft=='dm'&&f.geoLatMin.value==''&&f.geoLonMin.value=='')ft='d';
 
code+=ft;
 
code+='|'+f.geoLatDeg.value;
 
code+=(ft=='dm'||ft=='dms')?'|'+f.geoLatMin.value:'';
 
code+=(ft=='dms')?'|'+f.geoLatSec.value:'';
 
code+='|'+f.geoLatNS.value;
 
code+='|'+f.geoLonDeg.value;
 
code+=(ft=='dm'||ft=='dms')?'|'+f.geoLonMin.value:'';
 
code+=(ft=='dms')?'|'+f.geoLonSec.value:'';
 
code+='|'+f.geoLonEW.value;
 
code+='|type:'+f.geoType.value+'_region:'+f.geoRegion.value
 
code+='}}';
 
insertTags('','', code);
 
extendSummary('geo-location');
 
hideXEBPopup();
 
return false;
 
}
 
 
 
//===Talk Page entry Function===========================================
 
 
 
function XEBPopupTalk(e)
 
{
 
m=new GetPos(e||event);
 
 
 
curPopup=new XEBPopup("talk",m.x,m.y);
 
curPopup.width=200;
 
mt='<div style="font-size:medium"><p>Please choose:<\/p>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(1)">Test1<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(2)">Self Test<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(3)">Nonsense<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(4)">Please stop<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(5)">Last chance<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(6)">Blanking<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(7)">Blatant<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(8)">*BLOCKED*<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(9)">Spam<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(10)">Npov<\/span></div>'
 
 
 
curPopup.setInnerHTML(mt);
 
 
 
return true;
 
 
 
}
 
function XEBInsertTalk(itm)
 
{
 
hideXEBPopup();
 
if(itm==1)code='{{subst:test1-n|}}';
 
if(itm==2)code='{{subst:selftest-n|}}';
 
if(itm==3)code='{{subst:test2-n|}}';
 
if(itm==4)code='{{subst:test3-n|}}';
 
if(itm==5)code='{{subst:test4-n|}}';
 
if(itm==6)code='{{subst:test2a-n|}}';
 
if(itm==7)code='{{subst:bv-n|}}';
 
if(itm==8)code='{{subst:blantant|}}';
 
if(itm==9)code='{{subst:spam-n|}}';
 
if(itm==10)code='{{subst:NPOV user}}';
 
 
 
insertTags('','', code);
 
return false;
 
}
 
function XEBPopupImage(e)
 
{
 
m=new GetPos(e||event);
 
 
 
curPopup=new XEBPopup("image",m.x,m.y);
 
curPopup.width=300;
 
 
 
mt='<p>Enter the image parameters below: <\/p>'
 
+'<form name="XEBPopupImageForm">'
 
+'File:<input type="text" name="imgFile" value="' + XEBGetSelectedText() + '" size="30"><br>'
 
+'Type:<SELECT NAME="imgType">'
 
+'<OPTION VALUE="thumb">Thumbnail'
 
+'<OPTION VALUE="frame">Frame'
 
+'<OPTION VALUE="none">[not specified]'
 
+'</SELECT><br>'
 
+'Location:<SELECT NAME="imgLocation">'
 
+'<OPTION VALUE="left">Left'
 
+'<OPTION VALUE="center">Centre'
 
+'<OPTION VALUE="right">Right'
 
+'<OPTION VALUE="none">None'
 
+'</SELECT><br>'
 
+'Size:<input type="text" name="imgSize" value="100" size="3">px<br>'
 
+'Caption:<input type="text" name="imgCaption" value="" size="30"><\/p>'
 
+'<\/form>'
 
+'<p><button onClick="javascript:XEBInsertImage()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>';
 
 
 
curPopup.setInnerHTML(mt);
 
 
 
return true;
 
}
 
function XEBInsertImage()
 
{
 
f=document.XEBPopupImageForm;
 
hideXEBPopup();
 
var code='[[Image:';
 
code+=f.imgFile.value;
 
code+='|'+f.imgType.value;
 
code+='|'+f.imgLocation.value;
 
code+='|'+f.imgSize.value;
 
code+='|'+f.imgCaption.value;
 
code+=']]';
 
insertTags('','', code);
 
extendSummary('image');
 
 
 
return false;
 
}
 
 
 
function XEBPopupFormattedText(e)
 
{
 
m=new GetPos(e||event);
 
 
 
curPopup=new XEBPopup("image",m.x,m.y);
 
curPopup.width=300;
 
 
mt='<form name="XEBPopupImageForm">'
 
+'<table  style="background: transparent;">'
 
+'<tr><td>Bold:<\/td><td><input type="checkbox" name="textBold"><\/td>'
 
+'<td>Superscript:<\/td><td><input type="checkbox" name="textSuperscript"><\/td><\/tr>'
 
+'<tr><td>Italic:<\/td><td><input type="checkbox" name="textItalic"><\/td>'
 
+'<td>Subscript:<\/td><td><input type="checkbox" name="textSubscript"><\/td><\/tr>'
 
+'<tr><td>Strike:<\/td><td><input type="checkbox" name="textStrike"><\/td>'
 
+'<td>&nbsp;<\/td><\/tr>'
 
+'</table>'
 
+'Size:<SELECT NAME="textSize">'
 
+'<OPTION VALUE="small">small'
 
+'<OPTION VALUE="normal">[Normal]'
 
+'<OPTION VALUE="big">big'
 
+'</SELECT><br><table style="background:transparent;"><tr><td>Colour:<\/td><td>'
 
+'<table width="100px">'
 
+'<tr><td colspan="4">None<\/td></tr>'
 
+'<tr><td bgcolor="aqua">&nbsp;<\/td><td bgcolor="gray"> &nbsp;<\/td>'
 
+'<td bgcolor="olive">&nbsp;<\/td><td bgcolor="navy">&nbsp;<\/td><\/tr>'
 
+'<tr><td bgcolor="black">&nbsp;<\/td><td bgcolor="green"> &nbsp;<\/td>'
 
+'<td bgcolor="purple">&nbsp;<\/td><td bgcolor="teal">&nbsp;<\/td><\/tr>'
 
+'<tr><td bgcolor="blue">&nbsp;<\/td><td bgcolor="lime">&nbsp;<\/td>'
 
+'<td bgcolor="red">&nbsp;<\/td><td bgcolor="white">&nbsp;<\/td><\/tr>'
 
+'<tr><td bgcolor="fuchsia">&nbsp;<\/td><td bgcolor="maroon">&nbsp;<\/td>'
 
+'<td bgcolor="silver">&nbsp;<\/td><td bgcolor="yellow">&nbsp;<\/td><\/tr>'
 
+'</table><\/td><\/tr>'
 
+'<\/form>'
 
+'Sample:'
 
+'<span id="sampleText">Text</span>"'
 
+'<p><button onClick="javascript:XEBInsertFormattedText()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>';
 
 
 
curPopup.setInnerHTML(mt);
 
 
 
return true;
 
}
 
 
 
function XEBUpdateSampleText()
 
{
 
f=document.XEBPopupImageForm;
 
}
 
 
 
//====================
 
 
 
function XEBMenuMouseOut(e)
 
{
 
var targ;
 
if (!e) var e = window.event;
 
if (e.target) targ = e.target;
 
else if (e.srcElement) targ = e.srcElement;
 
 
 
targ.style.color='black';
 
}
 
 
 
function XEBMenuMouseOver(e)
 
{ var targ;
 
if (!e) var e = window.event;
 
if (e.target) targ = e.target;
 
else if (e.srcElement) targ = e.srcElement;
 
 
 
targ.style.color='red';
 
}
 
 
 
//=======================================================================
 
// Other functions
 
//=======================================================================
 
 
 
function XEBgetElementsByClassName(parent,clsName,htmltag){
 
var arr = new Array();
 
var elems = parent.getElementsByTagName(htmltag);
 
for ( var cls, i = 0; ( elem = elems[i] ); i++ ){
 
if ( elem.className == clsName ){
 
arr[arr.length] = elem;
 
}
 
}
 
return arr;
 
}
 
 
 
function extendSummary(newText)
 
{
 
if(!XEBExtendEditSummary)return;
 
s=document.editform.elements['wpSummary'].value;
 
s+=(s=='')?newText:' +'+newText;
 
document.editform.elements['wpSummary'].value=s;
 
 
}
 
}
 +
  
function bug(msg)
+
/* End of mw.loader.using callback */
{
+
} );
if(wgUserName=='MarkS')alert(msg);
+
/* DO NOT ADD CODE BELOW THIS LINE */
}
 

Latest revision as of 14:12, 8 October 2014

if (typeof usersignature == 'undefined') var usersignature = '-- \~\~\~\~';
/**
 * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
 * loaded for all users on every wiki page. If possible create a gadget that is
 * enabled by default instead of adding it here (since gadgets are fully
 * optimized ResourceLoader modules with possibility to add dependencies etc.)
 *
 * Since Common.js isn't a gadget, there is no place to declare its
 * dependencies, so we have to lazy load them with mw.loader.using on demand and
 * then execute the rest in the callback. In most cases these dependencies will
 * be loaded (or loading) already and the callback will not be delayed. In case a
 * dependency hasn't arrived yet it'll make sure those are loaded before this.
 */
 
/* global mw, $, importStylesheet, importScript */
/* jshint curly:false eqnull:true, strict:false, browser:true */
 
mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
/* Begin of mw.loader.using callback */
 
/**
 * Main Page layout fixes
 *
 * Description: Adds an additional link to the complete list of languages available.
 * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
 */
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
    $( function () {
        mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
            'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
    } );
}
 
/**
 * Redirect User:Name/skin.js and skin.css to the current skin's pages
 * (unless the 'skin' page really exists)
 * @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 * @rev: 2
 */
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
    var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
    /* Make sure there was a part before and after the slash
       and that the latter is 'skin.js' or 'skin.css' */
    if ( titleParts.length == 2 ) {
        var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
        if ( titleParts.slice( -1 ) == 'skin.js' ) {
            window.location.href = mw.util.getUrl( userSkinPage + '.js' );
        } else if ( titleParts.slice( -1 ) == 'skin.css' ) {
            window.location.href = mw.util.getUrl( userSkinPage + '.css' );
        }
    }
}
 
/**
 * Map addPortletLink to mw.util 
 *
 * @deprecated: Use mw.util.addPortletLink instead.
 */
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink,
 'Use mw.util.addPortletLink instead' );
 
/**
 * Extract a URL parameter from the current URL
 *
 * @deprecated: Use mw.util.getParamValue with proper escaping
 */
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
 
/** 
 * Test if an element has a certain class
 *
 * @deprecated:  Use $(element).hasClass() instead.
 */
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
    return $( element ).hasClass( className );
}, 'Use jQuery.hasClass() instead' );
 
/**
 * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
 * @rev 5
 */
// CSS
var extraCSS = mw.util.getParamValue( 'withCSS' );
if ( extraCSS ) {
	if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
		importStylesheet( extraCSS );
	} else {
		mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
	}
}
 
// JS
var extraJS = mw.util.getParamValue( 'withJS' );
if ( extraJS ) {
	if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
		importScript( extraJS );
	} else {
		mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
	}
}
 
/**
 * Import more specific scripts if necessary
 */
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) {
    /* scripts specific to editing pages */
    importScript( 'MediaWiki:Common.js/edit.js' );
} else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
    /* watchlist scripts */
    importScript( 'MediaWiki:Common.js/watchlist.js' );
}
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
    /* file description page scripts */
    importScript( 'MediaWiki:Common.js/file.js' );
}
 
/**
 * Load scripts specific to Internet Explorer
 */
if ( $.client.profile().name === 'msie' ) {
    importScript( 'MediaWiki:Common.js/IEFixes.js' );
}
 
/**
 * Fix for Windows XP Unicode font rendering
 */
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
    mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' + 
                '.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
}
 
/**
 * WikiMiniAtlas
 *
 * Description: WikiMiniAtlas is a popup click and drag world map.
 *              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
 *              The script itself is located on meta because it is used by many projects.
 *              See [[Meta:WikiMiniAtlas]] for more information. 
 * Maintainers: [[User:Dschwen]]
 */
( function () {
    var require_wikiminiatlas = false;
    var coord_filter = /geohack/;
    $( function () {
        $( 'a.external.text' ).each( function( key, link ) {
            if ( link.href && coord_filter.exec( link.href ) ) {
                require_wikiminiatlas = true;
                // break from loop
                return false;
            }
        } );
        if ( $( 'div.kmldata' ).length ) {
            require_wikiminiatlas = true;
        }
        if ( require_wikiminiatlas ) {
            mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
        }
    } );
} )();
 
/**
 * Collapsible tables
 *
 * Allows tables to be collapsed, showing only the header. See  [[Wikipedia:NavFrame]].
 *
 * @version 2.0.3 (2014-03-14)
 * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 * @author [[User:R. Koot]]
 * @author [[User:Krinkle]]
 * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 * is supported in MediaWiki core.
 */
 
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.rows;
    var i;
 
    if ( Button.firstChild.data === collapseCaption ) {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = 'none';
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
}
 
function createClickHandler( tableIndex ) {
    return function ( e ) {
        e.preventDefault();
        collapseTable( tableIndex );
    };
}
 
function createCollapseButtons() {
    var tableIndex = 0;
    var NavigationBoxes = {};
    var Tables = document.getElementsByTagName( 'table' );
    var i;
 
    for ( i = 0; i < Tables.length; i++ ) {
        if ( $( Tables[i] ).hasClass( '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 );
            // Styles are declared in [[MediaWiki:Common.css]]
            Button.className = 'collapseButton';
 
            ButtonLink.style.color = Header.style.color;
            ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
            ButtonLink.setAttribute( 'href', '#' );
            $( ButtonLink ).on( 'click', createClickHandler( tableIndex ) );
            ButtonLink.appendChild( ButtonText );
 

            Button.appendChild( ButtonLink );

 
            Header.insertBefore( Button, Header.firstChild );
            tableIndex++;
        }
    }
 
    for ( i = 0;  i < tableIndex; i++ ) {
        if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
            ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )
        ) {
            collapseTable( i );
        } 
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
            var element = NavigationBoxes[i];
            while ((element = element.parentNode)) {
                if ( $( element ).hasClass( 'outercollapse' ) ) {
                    collapseTable ( i );
                    break;
                }
            }
        }
    }
}
 
mw.hook( 'wikipage.content' ).add( createCollapseButtons );
 
/**
 * Dynamic Navigation Bars (experimental)
 *
 * Description: See [[Wikipedia:NavFrame]].
 * Maintainers: UNMAINTAINED
 */
 
/* set up the words in your language */
var NavigationBarHide = collapseCaption;
var NavigationBarShow = expandCaption;
 
/**
 * Shows and hides content and picture (if available) of navigation bars
 * Parameters:
 *     indexNavigationBar: the index of navigation bar to be toggled
 **/
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
    var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
    var NavChild;
 
    if ( !NavFrame || !NavToggle ) {
        return false;
    }
 
    /* if shown now */
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;
 
    /* if hidden now */
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'block';
            }
        }
        NavToggle.firstChild.data = NavigationBarHide;
    }
 
    event.preventDefault();
};
 
/* adds show/hide-button to navigation bars */
function createNavigationBarToggleButton() {
    var indexNavigationBar = 0;
    var NavFrame;
    var NavChild;
    /* iterate over all < div >-elements */
    var divs = document.getElementsByTagName( 'div' );
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
        /* if found a navigation bar */
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
 
            indexNavigationBar++;
            var NavToggle = document.createElement( 'a' );
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
            NavToggle.setAttribute( 'href', '#' );
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
 
            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
            /**
             * Check if any children are already hidden.  This loop is here for backwards compatibility:
             * the old way of making NavFrames start out collapsed was to manually add style="display:none"
             * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
             * the content visible without JavaScript support), the new recommended way is to add the class
             * "collapsed" to the NavFrame itself, just like with collapsible tables.
             */
            for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
                if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                    if ( NavChild.style.display === 'none' ) {
                        isCollapsed = true;
                    }
                }
            }
            if ( isCollapsed ) {
                for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
                    if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                        NavChild.style.display = 'none';
                    }
                }
            }
            var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
            NavToggle.appendChild( NavToggleText );
 
            /* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
            for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
                if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
                    NavFrame.childNodes[j].appendChild( NavToggle );
                }
            }
            NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
        }
    }
}
 
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
 
/**
 * Uploadwizard_newusers
 * Switches in a message for non-autoconfirmed users at [[Wikipedia:Upload]]
 *
 * Maintainers: [[User:Krimpet]]
 */
function uploadwizard_newusers() {
    if ( mw.config.get( 'wgNamespaceNumber' ) === 4 && mw.config.get( 'wgTitle' ) === 'Upload' && mw.config.get( 'wgAction' ) === 'view' ) {
        var oldDiv = document.getElementById( 'autoconfirmedusers' ),
            newDiv = document.getElementById( 'newusers' );
        if ( oldDiv && newDiv ) {
            var userGroups = mw.config.get( 'wgUserGroups' );
            if ( userGroups ) {
                for ( var i = 0; i < userGroups.length; i++ ) {
                    if ( userGroups[i] === 'autoconfirmed' ) {
                        oldDiv.style.display = 'block';
                        newDiv.style.display = 'none';
                        return;
                    }
                }
            }
            oldDiv.style.display = 'none';
            newDiv.style.display = 'block';
            return;
        }
    }
}
 
$(uploadwizard_newusers);
 
/**
 * Magic editintros ****************************************************
 *
 * Description: Adds editintros on disambiguation pages and BLP pages.
 * Maintainers: [[User:RockMFR]]
 */
function addEditIntro( name ) {
    $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
    } );
}
 
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
    $( function () {
        if ( document.getElementById( 'disambigbox' ) ) {
            addEditIntro( 'Template:Disambig_editintro' );
        }
    } );
 
    $( function () {
        var cats = mw.config.get('wgCategories');
        if ( !cats ) {
            return;
        }
        if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) {
            addEditIntro( 'Template:BLP_editintro' );
        }
    } );
}
 

/* End of mw.loader.using callback */
} );
/* DO NOT ADD CODE BELOW THIS LINE */