MediaWiki:Gadget-direct-link-to-Commons.js: Revizyonlar arasındaki fark

Vikipediya saydından
İçerik silindi İçerik eklendi
He7d3r (konuşmaa | yardımnar)
Migration: wikiGetlink → getUrl
 
14. liniya: 14. liniya:
uploadBaseRe = new RegExp( '^' + mw.RegExp.escape( '//upload.wikimedia.org/wikipedia/commons/' ) );
uploadBaseRe = new RegExp( '^' + mw.RegExp.escape( '//upload.wikimedia.org/wikipedia/commons/' ) );
$( 'a.image' ).attr( 'href', function( i, currVal ) {
$( 'a.image, a.mw-file-description' ).attr( 'href', function( i, currVal ) {
if ( uploadBaseRe.test( $(this).find( 'img' ).attr( 'src' ) ) ) {
if ( uploadBaseRe.test( $(this).find( 'img' ).attr( 'src' ) ) ) {
return currVal.replace( localBase, commonsBase ).replace( localBaseScript, commonsBaseScript );
return currVal.replace( localBase, commonsBase ).replace( localBaseScript, commonsBaseScript );

22.55, 7 Baba Marta 2023 sayfanın şindiki halı

/**
 * Direct imagelinks to Commons
 *
 * @source: http://www.mediawiki.org/wiki/Snippets/Direct_imagelinks_to_Commons
 * @author: [[commons:User:Krinkle]]
 * @rev: 7
 */
if ( mw.config.get( 'wgNamespaceNumber', 0 ) >= 0 ) {
        $( function() {
                var     commonsBase =  '//commons.wikimedia.org/wiki/File:',
                        localBase = mw.util.getUrl( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' ),
                        commonsBaseScript =  '//commons.wikimedia.org/w/index.php?title=File:',
                        localBaseScript = mw.util.wikiScript() + '?title=' + mw.util.wikiUrlencode( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' ),
                        uploadBaseRe = new RegExp( '^' + mw.RegExp.escape( '//upload.wikimedia.org/wikipedia/commons/' ) );
 
                $( 'a.image, a.mw-file-description' ).attr( 'href', function( i, currVal ) {
                        if ( uploadBaseRe.test( $(this).find( 'img' ).attr( 'src' ) ) ) {
                                return currVal.replace( localBase, commonsBase ).replace( localBaseScript, commonsBaseScript );
                        }
                });
        });
}