Difference between revisions 137873 and 138592 on testwiki// fileDescCommons.js // 2012-06-20 // Skip local file description page if present on Commons. // Precondition: Any WMF project, but not meaningful on Commons. // ResourceLoader: compatible; dependencies: mediawiki.util // Inspired by: mw:Snippets/Direct_imagelinks_to_Commons // Note: //secure.wikimedia.org keeps https but switches to //commons. /* jshint curly:true, undef:true, white:false */ /* global document: true, jQuery: true, mediaWiki: true */ /*jslint white: true */ /*globals document: true, jQuery: true, mediaWiki: true */ ( function ( mw, $ ) { "use strict"; $( document ).ready( function () { var k, n, site, shift = '//commons.wikimedia.org/wiki/File:', spaces = mw.config.get( 'wgFormattedNamespaces' ), src, store = '//upload.wikimedia.org/wikipedia/commons/'; site = mw.util.wikiGetlink( spaces[ '6' ] ) + ':'; n = site.length; window.console.log("site="+site); window.console.log("'a.image' length=" + $( 'a.image' ).length); $( 'a.image' ).attr( 'href', function( i, href ) { src = $( this ).find( 'img' ).attr( 'src' ); window.console.log("src="+src); if ( src ) { if ( src.indexOf( store ) >= 0 ) { k = href.indexOf( site ); window.console.log(k+" href="+href); if ( k >= 0 ) { return shift + href.substr( k + n ); } } } } ); // .attr() } ); // .ready() mw.loader.state( "ext.gadget.fileDescCommons", "ready" ); }( mediaWiki, jQuery ) );{{delete|Test completed, not longer needed, own user space; TIA --[[User:PerfektesChaos|PerfektesChaos]] ([[User talk:PerfektesChaos|talk]]) 17:21, 2 July 2012 (UTC)}} All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://test.wikipedia.org/w/index.php?diff=prev&oldid=138592.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|