Revision 137868 of "User:PerfektesChaos/js/fileDescCommons.js" 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;
$( 'a.image' ).attr( 'href', function( i, href ) {
src = $( this ).find( 'img' ).attr( 'src' );
if ( src ) {
if ( src.indexOf( store ) >= 0 ) {
k = href.indexOf( site );
if ( k >= 0 ) {
return shift + href.substr( k + n );
}
}
}
} ); // .attr()
} ); // .ready()
mw.loader.state( "ext.gadget.fileDescCommons", "ready" );
}( mediaWiki, jQuery ) );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?oldid=137868.
![]() ![]() 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.
|