( function ( mw, $ ) {
$( 'pre.source-' + mw.config.get( 'wgPageContentModel' ) ).find( 'span.co1, span.coMULTI' ).each( function() {
var codeComment = $( this ).html().substr( $( this ).html().indexOf( '[[' ) );
var wikiLink = '', wikiLinkPipe = '', replaceWikiLink = '', extraLinks = '';// declare variables
while ( codeComment.indexOf( '[[' ) !== -1 && codeComment.indexOf( ']]' ) !== -1 ){
if ( codeComment.indexOf( '|' ) !== -1 &&
codeComment.indexOf( '|' ) > codeComment.indexOf( '[[' ) &&
codeComment.indexOf( '|' ) < codeComment.indexOf( ']]' ) ) {
wikiLink = codeComment.slice( codeComment.indexOf( '[[' ) + 2, codeComment.indexOf( '|' ) );
wikiLinkPipe = codeComment.slice( codeComment.indexOf( '|' ), codeComment.indexOf( ']]' ) );
} else {
wikiLink = codeComment.slice( codeComment.indexOf( '[[' ) + 2, codeComment.indexOf( ']]' ) );
}
replaceWikiLink = codeComment.slice( codeComment.indexOf( '[[' ), codeComment.indexOf( ']]' ) + 2 );
codeComment = codeComment.substr( codeComment.indexOf( ']]' ) + 2 );
if ( wikiLink.search( 'Special:' ) === -1 ) {
extraLinks = ' <small style="font-style: normal;">( <a href="' +
mw.util.getUrl( wikiLink, { action: 'edit#editform' } ) +
'" title="Please use [show preview] before saving.">edit</a> | <a href="' +
mw.util.getUrl( 'Special:WhatLinksHere/' + wikiLink ) +
'" title="A list of all wiki pages that link here.">wlh</a> )</small>';
}
$( this ).html( $( this ).html().replace( replaceWikiLink, '<b>[[</b><a href="' +
mw.util.getUrl( wikiLink ) + '" title="' + wikiLink + '">' + wikiLink + '</a><b>' +
wikiLinkPipe + ']]</b>' + extraLinks ) );
wikiLink = '', wikiLinkPipe = '', replaceWikiLink = '', extraLinks = '';
}
} );
} ( mediaWiki, jQuery ) );