מדיה ויקי:Gadget-directlink-to-commons.js – הבדלי גרסאות
תוכן שנמחק תוכן שנוסף
depracation |
update to latest upstream |
||
שורה 2:
* Direct imagelinks to Commons
*
* Required modules: mediawiki.util
* @source mediawiki.org/wiki/Snippets/Direct_imagelinks_to_Commons▼
*▼
* @author [[commons:User:Krinkle]]▼
▲ * @source https://www.mediawiki.org/wiki/Snippets/Direct_imagelinks_to_Commons
* @version 9▼
*/
if ( mw.config.get( 'wgNamespaceNumber', 0 ) >= 0 ) {
mw.hook( 'wikipage.content' ).add( function ( $content ) {
var uploadBaseRe = /^(https:)?\/\/upload\.wikimedia\.org\/wikipedia\/commons/,
localBasePath = new RegExp( '^' + mw.util.escapeRegExp( mw.util.getUrl( localFileNSString ) ) ),
localBaseScript = new RegExp( '^' + mw.util.escapeRegExp(
) ),
$content.find( 'a.image, a.mw-file-description' ).attr( 'href', function ( i, currVal ) {▼
▲ localBasePath = mw.util.getUrl( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' ),
if ( uploadBaseRe.test( $( this ).find( 'img' ).attr( 'src' ) ) ) {▼
▲ localBaseScript = mw.util.wikiScript() + '?title=' + mw.util.wikiUrlencode( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' ),
return currVal▼
.replace( localBasePath, commonsBasePath )▼
▲ commonsBasePath = '//commons.wikimedia.org/wiki/File:',
.replace( localBaseScript, commonsBaseScript );▼
▲ commonsBaseScript = '//commons.wikimedia.org/w/index.php?title=File:';
}▼
} );▼
▲ $( 'a.image' ).attr( 'href', function ( i, currVal ) {
▲ if ( uploadBaseRe.test( $(this).find( 'img' ).attr( 'src' ) ) ) {
} );
▲ return currVal
▲ .replace( localBasePath, commonsBasePath )
▲ .replace( localBaseScript, commonsBaseScript );
▲ }
▲ });
▲ });
}
|