मीडियाविकि:Common.js/file.js

विकिपुस्तक से

ध्यान दें: प्रकाशित करने के बाद बदलाव देखने के लिए आपको अपने ब्राउज़र के कैश को हटाना पड़ सकता है।

  • Firefox/Safari: Reload क्लिक समय Shift दबाएँ, या फिर Ctrl-F5 या Ctrl-R दबाएँ (Mac पर ⌘-R)
  • Google Chrome: Ctrl-Shift-R दबाएँ (Mac पर ⌘-Shift-R)
  • Internet Explorer/Edge: Refresh पर क्लिक करते समय Ctrl दबाएँ, या Ctrl-F5 दबाएँ
  • Opera: Ctrl-F5 दबाएँ।
 // SVG images: adds links to rendered PNG images in different resolutions
 function SVGThumbs() {
	 var file = document.getElementById("file"); // might fail if MediaWiki can't render the SVG
	 if (file && wgIsArticle && mw.config.get('wgTitle').match(/\.svg$/i)) {
		 var thumbu = file.getElementsByTagName('IMG')[0].src;
		 if(!thumbu) return;

		 function svgAltSize( w, title) {
			 var path = thumbu.replace(/\/\d+(px-[^\/]+$)/, "/" + w + "$1");
			 var a = document.createElement("A");
			 a.setAttribute("href", path);
			 a.appendChild(document.createTextNode(title));
			 return a;
		 }

		 var p = document.createElement("p");
		 p.className = "SVGThumbs";
		 p.appendChild(document.createTextNode("This image rendered as PNG in other sizes"+": "));
		 var l = new Array( 200, 500, 1000, 2000 )
                 for( var i = 0; i < l.length; i++ ) {
			 p.appendChild(svgAltSize( l[i], l[i] + "px"));
			 if( i < l.length-1 ) p.appendChild(document.createTextNode(", "));
                 }
		 p.appendChild(document.createTextNode("."));
		 var info = getElementsByClassName( file.parentNode, 'div', 'fullMedia' )[0];
		 if( info ) info.appendChild(p);
	 }
 };
 $( SVGThumbs )