MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus HuskyWiki
KKeine Bearbeitungszusammenfassung
Markierung: Zurückgesetzt
KKeine Bearbeitungszusammenfassung
Markierung: Zurückgesetzt
Zeile 1: Zeile 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/**
/**
  * Collapsible tables
  * 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.)
  *
  *
  * Allows tables to be collapsed, showing only the header. See [[Wikipedia:NavFrame]].
  * Since Common.js isn't a gadget, there is no place to declare its
  * @maintainer [[User:R. Koot]] (on Wikipedia)
* 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.
  */
  */


var autoCollapse = 2;
/* global mw, $ */
var collapseCaption = 'hide';
/* jshint strict:false, browser:true */
var expandCaption = 'show';
 
mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify', 'jquery.client'] ).done( function () {
/* Begin of mw.loader.using callback */


function hasClass( element, className ) {
/**
var Classes = element.className.split( " " );
* Main Page layout fixes
for ( var i = 0; i < Classes.length; i++ ) {
*
if ( Classes[i] == className ) {
* Description: Adds an additional link to the complete list of languages available.
return true;
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
}
*/
}
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
return false;
    $( function () {
        mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
            'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
    } );
}
}


function collapseTable( tableIndex ) {
/**
var i;
* Redirect User:Name/skin.js and skin.css to the current skin's pages
var Button = document.getElementById( 'collapseButton' + tableIndex );
* (unless the 'skin' page really exists)
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
* @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 
* @rev: 2
if ( !Table || !Button ) {
*/
return false;
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
var Rows = Table.getElementsByTagName( 'tr' );
      and that the latter is 'skin.js' or 'skin.css' */
 
    if ( titleParts.length == 2 ) {
if ( Button.firstChild.data == collapseCaption ) {
        var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
for ( i = 1; i < Rows.length; i++ ) {
        if ( titleParts.slice( -1 ) == 'skin.js' ) {
Rows[i].style.display = 'none';
            window.location.href = mw.util.getUrl( userSkinPage + '.js' );
}
        } else if ( titleParts.slice( -1 ) == 'skin.css' ) {
Button.firstChild.data = expandCaption;
            window.location.href = mw.util.getUrl( userSkinPage + '.css' );
} else {
        }
for ( i = 1; i < Rows.length; i++ ) {
    }
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
}
}


function createCollapseButtons() {
/**
var i;
* Map addPortletLink to mw.util
var tableIndex = 0;
* @deprecated: Use mw.util.addPortletLink instead.
var NavigationBoxes = {};
*/
var Tables = document.getElementsByTagName( 'table' );
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );


for ( i = 0; i < Tables.length; i++ ) {
/**
if ( hasClass( Tables[i], 'collapsible' ) ) {
* Extract a URL parameter from the current URL
NavigationBoxes[ tableIndex ] = Tables[i];
* @deprecated: Use mw.util.getParamValue with proper escaping
Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
*/
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );


var Button = document.createElement( 'span' );
/**
var ButtonLink = document.createElement( 'a' );
* Test if an element has a certain class
var ButtonText = document.createTextNode( collapseCaption );
* @deprecated:  Use $(element).hasClass() instead.
*/
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
    return $( element ).hasClass( className );
}, 'Use jQuery.hasClass() instead' );


Button.style.styleFloat = 'right';
/**
Button.style.cssFloat = 'right';
* @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
Button.style.fontWeight = 'normal';
* @rev 6
Button.style.textAlign = 'right';
*/
Button.style.width = '6em';
var extraCSS = mw.util.getParamValue( 'withCSS' ),
    extraJS = mw.util.getParamValue( 'withJS' );


ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
if ( extraCSS ) {
ButtonLink.setAttribute( 'href', 'javascript:collapseTable(' + tableIndex + ');' );
    if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
ButtonLink.appendChild( ButtonText );
        mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
    } else {
        mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
    }
}


Button.appendChild( document.createTextNode( '[' ) );
if ( extraJS ) {
Button.appendChild( ButtonLink );
    if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
Button.appendChild( document.createTextNode( ']' ) );
        mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
 
    } else {
var Header = Tables[i].getElementsByTagName( 'tr' )[0].getElementsByTagName( 'th' )[0];
        mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
/* only add button and increment count if there is a header row to work with */
    }
if (Header) {
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
}
 
for ( i = 0; i < tableIndex; i++ ) {
if ( hasClass( NavigationBoxes[i], 'collapsed' ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], 'autocollapse' ) ) ) {
collapseTable( i );
}
}
}
}


$( createCollapseButtons );
/**
 
* 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' );
        }
    } );
} )();


/**
/**
  * Dynamic Navigation Bars (experimental)
  * Collapsible tables
*
* Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
  *
  *
  *  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.
  */
  */


// set up the words in your language
var autoCollapse = 2;
var NavigationBarHide = '[' + collapseCaption + ']';
var collapseCaption = 'Einklappen';
var NavigationBarShow = '[' + expandCaption + ']';
var expandCaption = 'Ausklappen';
var tableIndex = 0;


// shows and hides content and picture (if available) of navigation bars
function collapseTable( tableIndex ) {
// Parameters:
    var Button = document.getElementById( 'collapseButton' + tableIndex );
// indexNavigationBar: the index of navigation bar to be toggled
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );
function toggleNavigationBar(indexNavigationBar) {
var NavChild;
var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar);
var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar);


if (!NavFrame || !NavToggle) {
    if ( !Table || !Button ) {
return false;
        return false;
}
    }


// if shown now
    var Rows = Table.rows;
if (NavToggle.firstChild.data == NavigationBarHide) {
    var i;
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
    var $row0 = $(Rows[0]);
if ( hasClass( NavChild, 'NavPic' ) ) {
NavChild.style.display = 'none';
}
if ( hasClass( NavChild, 'NavContent') ) {
NavChild.style.display = 'none';
}
}
NavToggle.firstChild.data = NavigationBarShow;


// if hidden now
    if ( Button.firstChild.data === collapseCaption ) {
} else if (NavToggle.firstChild.data == NavigationBarShow) {
        for ( i = 1; i < Rows.length; i++ ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
            Rows[i].style.display = 'none';
if (hasClass(NavChild, 'NavPic')) {
        }
NavChild.style.display = 'block';
        Button.firstChild.data = expandCaption;
}
    } else {
if (hasClass(NavChild, 'NavContent')) {
        for ( i = 1; i < Rows.length; i++ ) {
NavChild.style.display = 'block';
            Rows[i].style.display = $row0.css( 'display' );
}
        }
}
        Button.firstChild.data = collapseCaption;
NavToggle.firstChild.data = NavigationBarHide;
    }
}
}
}


// adds show/hide-button to navigation bars
function createClickHandler( tableIndex ) {
function createNavigationBarToggleButton(){
    return function ( e ) {
var indexNavigationBar = 0;
        e.preventDefault();
// iterate over all < div >-elements
        collapseTable( tableIndex );
var divs = document.getElementsByTagName( 'div' );
    };
for (var i = 0; NavFrame = divs[i]; i++) {
}
// if found a navigation bar
 
if ( hasClass(NavFrame, 'NavFrame' )) {
function createCollapseButtons( $content ) {
    var NavigationBoxes = {};
    var $Tables = $content.find( 'table' );
    var i;
 
    $Tables.each( function( i, table ) {
        if ( $(table).hasClass( 'collapsible' ) ) {
 
            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = table.getElementsByTagName( 'tr' )[0];
            if ( !HeaderRow ) {
                return;
            }
            var Header = table.getElementsByTagName( 'th' )[0];
            if ( !Header ) {
                return;
            }


indexNavigationBar++;
            NavigationBoxes[ tableIndex ] = table;
var NavToggle = document.createElement('a');
            table.setAttribute( 'id', 'collapsibleTable' + tableIndex );
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');


var NavToggleText = document.createTextNode(NavigationBarHide);
            var Button    = document.createElement( 'span' );
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
            var ButtonLink = document.createElement( 'a' );
if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
            var ButtonText = document.createTextNode( collapseCaption );
if (NavChild.style.display == 'none') {
            // Styles are declared in [[MediaWiki:Common.css]]
NavToggleText = document.createTextNode(NavigationBarShow);
            Button.className = 'collapseButton';
break;
}
}
}


NavToggle.appendChild(NavToggleText);
            ButtonLink.style.color = Header.style.color;
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
            ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
for(var j=0; j < NavFrame.childNodes.length; j++) {
            ButtonLink.setAttribute( 'href', '#' );
if (hasClass(NavFrame.childNodes[j], 'NavHead')) {
            $( ButtonLink ).on( 'click', createClickHandler( tableIndex ) );
NavFrame.childNodes[j].appendChild(NavToggle);
            ButtonLink.appendChild( ButtonText );
}
}
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
}


$( createNavigationBarToggleButton );
            Button.appendChild( document.createTextNode( '[' ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( ']' ) );


            Header.insertBefore( Button, Header.firstChild );
            tableIndex++;
        }
    } );


// Shuffle for election candidates
    for ( i = 0; i < tableIndex; i++ ) {
function dshuf() {
        if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
var shufsets = {};
            ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )
var rx = new RegExp('dshuf' + '\\s+(dshufset\\d+)', 'i');
        ) {
var divs = document.getElementsByTagName('div');
            collapseTable( i );
var i = divs.length;
        }
while (i--) {
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
if (rx.test(divs[i].className)) {
            var element = NavigationBoxes[i];
if (typeof shufsets[RegExp.$1] === 'undefined') {
            while ((element = element.parentNode)) {
shufsets[RegExp.$1] = {};
                if ( $( element ).hasClass( 'outercollapse' ) ) {
shufsets[RegExp.$1].inner = [];
                    collapseTable ( i );
shufsets[RegExp.$1].member = [];
                    break;
}
                }
shufsets[RegExp.$1].inner.push({
            }
key: Math.random(),
        }
html: divs[i].innerHTML
    }
});
shufsets[RegExp.$1].member.push(divs[i]);
}
}
for (shufset in shufsets) {
shufsets[shufset].inner.sort(function(a, b) {
return a.key - b.key;
});
i = shufsets[shufset].member.length;
while (i--) {
shufsets[shufset].member[i].innerHTML = shufsets[shufset].inner[i].html;
shufsets[shufset].member[i].style.display = 'block';
}
}
}
}
$(dshuf);
 
mw.hook( 'wikipage.content' ).add( createCollapseButtons );


/**
/**
  * JSconfig
  * Dynamic Navigation Bars (experimental)
  *
  *
  * Global configuration options to enable/disable and configure
  * Description: See [[Wikipedia:NavFrame]].
* specific script features from [[MediaWiki:Common.js]] and
  * Maintainers: UNMAINTAINED
* [[MediaWiki:Monobook.js]]
* This framework adds config options (saved as cookies) to [[Special:Preferences]]
* For a more permanent change you can override the default settings in your
* [[Special:Mypage/monobook.js]]
* for Example: JSconfig.keys[loadAutoInformationTemplate] = false;
  *
* Maintainer: [[User:Dschwen]]
  */
  */


var JSconfig =
/* set up the words in your language */
{
var NavigationBarHide = '[' + collapseCaption + ']';
prefix : 'jsconfig_',
var NavigationBarShow = '[' + expandCaption + ']';
keys : {},
var indexNavigationBar = 0;
meta : {},


//
/**
// Register a new configuration item
  * Shows and hides content and picture (if available) of navigation bars
//  * name          : String, internal name
  * Parameters:
// * default_value : String or Boolean (type determines configuration widget)
  *     indexNavigationBar: the index of navigation bar to be toggled
// * description  : String, text appearing next to the widget in the preferences
**/
// * prefpage      : Integer (optional), section in the preferences to insert the widget:
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
//                    0 : User profile
    var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
//                    1 : Skin
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
//                    2 : Math
    var NavChild;
//                    3 : Files
//                    4 : Date and time
//                    5 : Editing
//                    6 : Recent changes
//                    7 : Watchlist
//                    8 : Search
//                    9 : Misc
//
// Access keys through JSconfig.keys[name]
//
registerKey : function( name, default_value, description, prefpage )
{
  if( typeof(JSconfig.keys[name]) === 'undefined' )
  JSconfig.keys[name] = default_value;
  else {


  // all cookies are read as strings,
     if ( !NavFrame || !NavToggle ) {
  // convert to the type of the default value
        return false;
  switch( typeof(default_value) )
     }
  {
     case 'boolean' : JSconfig.keys[name] = ( JSconfig.keys[name] == 'true' ); break;
    case 'number'  : JSconfig.keys[name] = JSconfig.keys[name]/1; break;
  }
 
  }
 
  JSconfig.meta[name] = { 'description' : description, 'page' : prefpage || 0, 'default_value' : default_value };
},
 
readCookies : function()
{
  var cookies = document.cookie.split("; ");
  var p =JSconfig.prefix.length;
  var i;
 
  for( var key in cookies )
  {
  if( cookies[key].substring(0,p) == JSconfig.prefix )
  {
    i = cookies[key].indexOf('=');
    //alert( cookies[key] + ',' + key + ',' + cookies[key].substring(p,i) );
     JSconfig.keys[cookies[key].substring(p,i)] = cookies[key].substring(i+1);
  }
  }
},


writeCookies : function()
    /* if shown now */
{
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
  for( var key in JSconfig.keys )
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
  document.cookie = JSconfig.prefix + key + '=' + JSconfig.keys[key] + '; path=/; expires=Thu, 2 Aug 2009 10:10:10 UTC';
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
},
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;


evaluateForm : function()
    /* if hidden now */
{
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
  var w_ctrl,wt;
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
  //alert('about to save JSconfig');
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
  for( var key in JSconfig.meta ) {
                NavChild.style.display = 'block';
  w_ctrl = document.getElementById( JSconfig.prefix + key );
            }
  if( w_ctrl )
        }
  {
        NavToggle.firstChild.data = NavigationBarHide;
    wt = typeof( JSconfig.meta[key].default_value );
    switch( wt ) {
    case 'boolean' : JSconfig.keys[key] = w_ctrl.checked; break;
    case 'string' : JSconfig.keys[key] = w_ctrl.value; break;
     }
     }
  }
  }


  JSconfig.writeCookies();
    event.preventDefault();
  return true;
};
},


setUpForm : function()
/* adds show/hide-button to navigation bars */
{
function createNavigationBarToggleButton( $content ) {
  var key;
    var NavChild;
  var prefChild = document.getElementById('preferences');
    /* iterate over all < div >-elements */
  if( !prefChild ) return;
    var $divs = $content.find( 'div' );
  prefChild = prefChild.childNodes;
    $divs.each( function ( i, NavFrame ) {
        /* if found a navigation bar */
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {


  //
            indexNavigationBar++;
  // make a list of all preferences sections
            var NavToggle = document.createElement( 'a' );
  //
            NavToggle.className = 'NavToggle';
  var tabs = [];
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
  var len = prefChild.length;
            NavToggle.setAttribute( 'href', '#' );
  for( key = 0; key < len; key++ ) {
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
  if( prefChild[key].tagName &&
      prefChild[key].tagName.toLowerCase() == 'fieldset' )
    tabs.push(prefChild[key]);
  }


  //
            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
  // Create Widgets for all registered config keys
            /**
  //
            * Check if any children are already hidden.  This loop is here for backwards compatibility:
  var w_div, w_label, w_ctrl, wt;
            * the old way of making NavFrames start out collapsed was to manually add style="display:none"
  for( key in JSconfig.meta ) {
            * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
  w_div = document.createElement( 'div' );
            * 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 );


  w_label = document.createElement( 'LABEL' );
            /* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
  w_label.appendChild( document.createTextNode( JSconfig.meta[key].description ) );
            for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
  w_label.htmlFor = JSconfig.prefix + key;
                if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
                    NavFrame.childNodes[j].appendChild( NavToggle );
                }
            }
            NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
        }
    } );
}


  wt = typeof( JSconfig.meta[key].default_value );
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );


  w_ctrl = document.createElement( 'input' );
/**
  w_ctrl.id = JSconfig.prefix + key;
* 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;
        }
    }
}


  // before insertion into the DOM tree
$(uploadwizard_newusers);
  switch( wt ) {
    case 'boolean' : w_ctrl.type = 'checkbox'; break;
    case 'string'  : w_ctrl.type = 'text'; break;
  }


  w_div.appendChild( w_label );
/** Skript für [[Vorlage:Galerie]] */
  w_div.appendChild( w_ctrl );
$( function() {
  tabs[JSconfig.meta[key].page].appendChild( w_div );
  if (document.URL.match(/printable/g)) return;


  // after insertion into the DOM tree
  function toggleImageFunction(group,  remindex, shwindex) {
  switch( wt ) {
    return function() {
    case 'boolean' : w_ctrl.defaultChecked = w_ctrl.checked = JSconfig.keys[key]; break;
      document.getElementById("ImageGroupsGr" + group + "Im" + remindex).style["display"] = "none";
    case 'string' : w_ctrl.defaultValue = w_ctrl.value = JSconfig.keys[key]; break;
      document.getElementById("ImageGroupsGr" + group + "Im" + shwindex).style["display"] = "block";
  }
      return false;
    };
  }


  var divs = document.getElementsByTagName("div");
  var i = 0, j = 0;
  var units, search;
  var currentimage;
  var UnitNode;
  for (i = 0; i < divs.length; i++) {
    if (divs[i].className !== "ImageGroup") { continue; }
    UnitNode = undefined;
    search = divs[i].getElementsByTagName("div");
    for (j = 0; j < search.length; j++) {
      if (search[j].className !== "ImageGroupUnits") { continue; }
      UnitNode=search[j];
      break;
    }
    if (UnitNode === undefined) { continue; }
    units = [];
    for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
      var temp = UnitNode.childNodes[j];
      if (temp.className === "center") { units.push(temp); }
    }
    var rightlink = undefined;
    var commentText = undefined;
    for (j = 0; j < units.length; j++) {
      currentimage = units[j];
      currentimage.id = "ImageGroupsGr" + i + "Im" + j;
      var leftlink = document.createElement("a");
      if (commentText !== undefined) {
        leftlink.setAttribute("title", commentText);
      }
      var comment;
      if (typeof(currentimage.getAttribute("title")) !== "string") {
        commentText = (j+1) + "/" + units.length;
        comment = document.createElement("tt").appendChild(document.createTextNode("("+ commentText + ")"));
      } else {
        commentText = currentimage.getAttribute("title");
        comment = document.createElement("span").appendChild(document.createTextNode(commentText));
        currentimage.removeAttribute("title");
      }
      if(rightlink !== undefined) {
        rightlink.setAttribute("title", commentText);
      }
      var imghead = document.createElement("div");
      rightlink = document.createElement("a");
      if (j !== 0) {
        leftlink.href = "#";
        leftlink.onclick = toggleImageFunction(i, j, j-1);
        leftlink.appendChild(document.createTextNode("◀"));
      }
      if (j !== units.length - 1) {
        rightlink.href = "#";
        rightlink.onclick = toggleImageFunction(i, j, j+1);
        rightlink.appendChild(document.createTextNode("▶"));
      }
      imghead.style["fontSize"] = "110%";
      imghead.style["fontweight"] = "bold";
      imghead.appendChild(leftlink);
      imghead.appendChild(document.createTextNode("\xA0"));
      imghead.appendChild(comment);
      imghead.appendChild(document.createTextNode("\xA0"));
      imghead.appendChild(rightlink);
      if (units.length > 1) {
        currentimage.insertBefore(imghead,currentimage.childNodes[0]);
      }
      if (j !== 0) {
        currentimage.style["display"] = "none";
      }
    }
   }
   }
  $('#preferences').parent().on( 'submit', JSconfig.evaluateForm );
});
}
};


JSconfig.readCookies();
$(JSconfig.setUpForm);


if(location.href.indexOf('rtl=1') !== -1) {
/**
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Gadget-rtl.css&action=raw&ctype=text/css', 'text/css');
* 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;
    } );
}
}


// Import local or interwiki page as script
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
// @deprecated since MediaWiki 1.17: Use mw.loader.load(url) or $.getScript(url, callback) instead.
    $( function () {
function importScript(page, lang) {
        if ( document.getElementById( 'disambigbox' ) ) {
var query = '?title=' + encodeURIComponent(page.replace(' ','_')) + '&action=raw&ctype=text/javascript';
            addEditIntro( 'Template:Disambig_editintro' );
if (lang) {
        }
mw.loader.load('//' + lang + '.wikipedia.org/w/index.php' + query);
    } );
} else {
 
mw.loader.load('//meta.wikimedia.org' + mw.config.get( 'wgScript' ) + query);
    $( 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' );
        }
    } );
}
}


( function () {
/* End of mw.loader.using callback */
var conf = mw.config.get( [
} );
'wgCanonicalSpecialPageName',
/* DO NOT ADD CODE BELOW THIS LINE */
'wgUserGroups',
'wgPageName',
'wgUserName'
] );
 
// Multilingual description.js from commons
mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-LanguageSelect.js&action=raw&ctype=text/javascript');
 
// Tabs
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Tabs.js&action=raw&ctype=text/javascript');
 
// Handle template:InterProject
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:InterProject.js&action=raw&ctype=text/javascript');
 
// Help:Diff
if ( conf.wgPageName === 'Help:Diff' ) {
    mw.loader.load( 'mediawiki.action.history.diff' );
}
 
/**
* IE fixes as required
* (includes hlist fixup for IE)
*/
mw.loader.using( 'jquery.client', function() {
    if ( $.client.profile().name === 'msie' ) {
        mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Common.js/IEFixes.js&action=raw&ctype=text/javascript' );
    }
} );
/**
* adds an "Add Topic" link to the header of the last section. Taken from [[:w:de:Mediawiki:Common.js]]
*/
mw.loader.using( [ 'mediawiki.util' ], function() { $( function() {
var newSectionLink = $( '#ca-addsection a' );
if( newSectionLink.length ) {
  var link = newSectionLink.clone(); //create a copy
  //avoid duplicate accesskey
  link.removeAttr( 'accesskey' ).updateTooltipAccessKeys();
  //add it within the brackets
  var lastEditsectionLink = $( 'span.mw-editsection:last a:last' );
  lastEditsectionLink.after( link );
  lastEditsectionLink.after( ' | ' ); //see [[MediaWiki:Pipe-separator]]
}
})});
 
}() );
 
mw.loader.using( ['mediawiki.util'] ).done( function () {
/**
* @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
* @rev 6
*/
var extraCSS = mw.util.getParamValue( 'withCSS' ),
    extraJS = mw.util.getParamValue( 'withJS' );
if ( extraCSS ) {
    if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
        mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
    } else {
        mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
    }
}
if ( extraJS ) {
    if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
        mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
    } else {
        mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
    }
}
});

Version vom 8. März 2021, 12:25 Uhr

/**
 * 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, $ */
/* jshint strict:false, browser:true */

mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify', 'jquery.client'] ).done( 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 6
 */
var extraCSS = mw.util.getParamValue( 'withCSS' ),
    extraJS = mw.util.getParamValue( 'withJS' );

if ( extraCSS ) {
    if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
        mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
    } else {
        mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
    }
}

if ( extraJS ) {
    if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
        mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
    } else {
        mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
    }
}

/**
 * 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 [[Help:Collapsing]].
 *
 * @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 = 'Einklappen';
var expandCaption = 'Ausklappen';
var tableIndex = 0;

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;
    var $row0 = $(Rows[0]);

    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 = $row0.css( 'display' );
        }
        Button.firstChild.data = collapseCaption;
    }
}

function createClickHandler( tableIndex ) {
    return function ( e ) {
        e.preventDefault();
        collapseTable( tableIndex );
    };
}

function createCollapseButtons( $content ) {
    var NavigationBoxes = {};
    var $Tables = $content.find( 'table' );
    var i;

    $Tables.each( function( i, table ) {
        if ( $(table).hasClass( 'collapsible' ) ) {

            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = table.getElementsByTagName( 'tr' )[0];
            if ( !HeaderRow ) {
                return;
            }
            var Header = table.getElementsByTagName( 'th' )[0];
            if ( !Header ) {
                return;
            }

            NavigationBoxes[ tableIndex ] = table;
            table.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( document.createTextNode( '[' ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( ']' ) );

            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 + ']';
var indexNavigationBar = 0;

/**
 * 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( $content ) {
    var NavChild;
    /* iterate over all < div >-elements */
    var $divs = $content.find( 'div' );
    $divs.each( function ( i, NavFrame ) {
        /* 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);

/** Skript für [[Vorlage:Galerie]] */
$( function() {
  if (document.URL.match(/printable/g)) return;

  function toggleImageFunction(group,  remindex, shwindex) {
    return function() {
      document.getElementById("ImageGroupsGr" + group + "Im" + remindex).style["display"] = "none";
      document.getElementById("ImageGroupsGr" + group + "Im" + shwindex).style["display"] = "block";
      return false;
    };
  }

  var divs = document.getElementsByTagName("div");
  var i = 0, j = 0;
  var units, search;
  var currentimage;
  var UnitNode;
  for (i = 0; i < divs.length; i++) {
    if (divs[i].className !== "ImageGroup") { continue; }
    UnitNode = undefined;
    search = divs[i].getElementsByTagName("div");
    for (j = 0; j < search.length; j++) {
      if (search[j].className !== "ImageGroupUnits") { continue; }
      UnitNode=search[j];
      break;
    }
    if (UnitNode === undefined) { continue; }
    units = [];
    for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
      var temp = UnitNode.childNodes[j];
      if (temp.className === "center") { units.push(temp); }
    }
    var rightlink = undefined;
    var commentText = undefined;
    for (j = 0; j < units.length; j++) {
      currentimage = units[j];
      currentimage.id = "ImageGroupsGr" + i + "Im" + j;
      var leftlink = document.createElement("a");
      if (commentText !== undefined) {
        leftlink.setAttribute("title", commentText);
      }
      var comment;
      if (typeof(currentimage.getAttribute("title")) !== "string") {
        commentText = (j+1) + "/" + units.length;
        comment = document.createElement("tt").appendChild(document.createTextNode("("+ commentText + ")"));
      } else {
        commentText = currentimage.getAttribute("title");
        comment = document.createElement("span").appendChild(document.createTextNode(commentText));
        currentimage.removeAttribute("title");
      }
      if(rightlink !== undefined) {
        rightlink.setAttribute("title", commentText);
      }
      var imghead = document.createElement("div");
      rightlink = document.createElement("a");
      if (j !== 0) {
        leftlink.href = "#";
        leftlink.onclick = toggleImageFunction(i, j, j-1);
        leftlink.appendChild(document.createTextNode("◀"));
      }
      if (j !== units.length - 1) {
        rightlink.href = "#";
        rightlink.onclick = toggleImageFunction(i, j, j+1);
        rightlink.appendChild(document.createTextNode("▶"));
      }
      imghead.style["fontSize"] = "110%";
      imghead.style["fontweight"] = "bold";
      imghead.appendChild(leftlink);
      imghead.appendChild(document.createTextNode("\xA0"));
      imghead.appendChild(comment);
      imghead.appendChild(document.createTextNode("\xA0"));
      imghead.appendChild(rightlink);
      if (units.length > 1) {
        currentimage.insertBefore(imghead,currentimage.childNodes[0]);
      }
      if (j !== 0) {
        currentimage.style["display"] = "none";
      }
    }
  }
});


/**
 * 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 */