MediaWiki:Common.js/file.js: Difference between revisions
Jump to navigation
Jump to search
(elsewhere please.) |
(typo) |
||
Line 27: | Line 27: | ||
div.appendChild(a2000); | div.appendChild(a2000); | ||
div.appendChild(document.createTextNode(".")); | div.appendChild(document.createTextNode(".")); | ||
var info = | var info = getElementsByClassName( file.parentNode, 'div', 'fullMedia' )[0]; | ||
if( info ) info.appendChild(div); | if( info ) info.appendChild(div); | ||
} | } |
Revision as of 14:01, 25 November 2009
/* <source lang="javascript"><nowiki> */ // SVG images: adds links to rendered PNG images in different resolutions function SVGThumbs() { if (wgAction == "view" && wgNamespaceNumber == 6 && wgTitle.substring(wgTitle.lastIndexOf(".")).toLowerCase() == ".svg") { var file = document.getElementById("file"); if (!file) return; // might happen if MediaWiki can't render the SVG var div = document.createElement("p"); div.appendChild(document.createTextNode("This image rendered as PNG in some resolutions"+": ")); var a200 = document.createElement("a"); a200.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=200px&height=200px"); a200.appendChild(document.createTextNode("200px")); var a500 = document.createElement("a"); a500.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=500px&height=500px"); a500.appendChild(document.createTextNode("500px")); var a1000 = document.createElement("a"); a1000.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=1000px&height=1000px"); a1000.appendChild(document.createTextNode("1000px")); var a2000 = document.createElement("a"); a2000.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=2000px&height=2000px"); a2000.appendChild(document.createTextNode("2000px")); div.appendChild(a200); div.appendChild(document.createTextNode(", ")); div.appendChild(a500); div.appendChild(document.createTextNode(", ")); div.appendChild(a1000); div.appendChild(document.createTextNode(", ")); div.appendChild(a2000); div.appendChild(document.createTextNode(".")); var info = getElementsByClassName( file.parentNode, 'div', 'fullMedia' )[0]; if( info ) info.appendChild(div); } }; addOnloadHook( SVGThumbs ) /* </nowiki></source> */