MediaWiki:Gadget-ZoomViewer.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
This user script seems to have a documentation page at MediaWiki:Gadget-ZoomViewer. |
/*global $, mw*/
/*jshint curly:false, boss:true */
if ( mw.config.get('wgNamespaceNumber') === 6 && mw.config.get('wgAction') === 'view' && !mw.util.getParamValue('diff')) {
$(document).ready(
function () {
'use strict';
// get page name and data on the image
var name = mw.config.get('wgPageName').replace( /_/g, ' ' )
, id = $('#file img[alt=\'' + name.replace( /'/g, '\\\'' ) + '\']').data();
// check if the image is below 2MP
if (!id) { return; }
var p = id.fileHeight * id.fileWidth;
if( p < 2*1024*1024 ) return;
// build ZoomViewer links
var links = $("<span>", { id: "ZoomViewerLinks", style: "white-space:nowrap; display:inline-block;" })
, fileName = name.match(/File:(.+\.jpe?g)/i);
// only operate on JPG images
if (!fileName) { return; }
var url = "https://zoomviewer.toolforge.org/index.php?f=" + encodeURIComponent( fileName[1] )
, link = $("<a>", { href: url + "&flash=no", text: "ZoomViewer" });
links.append("; ", link);
$('.fileInfo').after(links);
}
);
}