MediaWiki:Common.js/file.js: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
m (Created page with '→‎<source lang="javascript"><nowiki>: // SVG images: adds links to rendered PNG images in different resolutions addOnloadHook( SVGthumbs ) function SVGThumbs() ...')
 
(limits on the height as well.)
Line 11: Line 11:
       div.appendChild(document.createElement("br"));
       div.appendChild(document.createElement("br"));
       var a200 = document.createElement("a");
       var a200 = document.createElement("a");
       a200.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=200px");
       a200.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=200px&height=200px");
       a200.appendChild(document.createTextNode("200px"));
       a200.appendChild(document.createTextNode("200px"));
       var a500 = document.createElement("a");
       var a500 = document.createElement("a");
       a500.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=500px");
       a500.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=500px&height=500px");
       a500.appendChild(document.createTextNode("500px"));
       a500.appendChild(document.createTextNode("500px"));
       var a1000 = document.createElement("a");
       var a1000 = document.createElement("a");
       a1000.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=1000px");
       a1000.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=1000px&height=1000px");
       a1000.appendChild(document.createTextNode("1000px"));
       a1000.appendChild(document.createTextNode("1000px"));
       var a2000 = document.createElement("a");
       var a2000 = document.createElement("a");
       a2000.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=2000px");
       a2000.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=2000px&height=2000px");
       a2000.appendChild(document.createTextNode("2000px"));
       a2000.appendChild(document.createTextNode("2000px"));
       div.appendChild(a200);
       div.appendChild(a200);

Revision as of 13:26, 25 November 2009

/* <source lang="javascript"><nowiki> */
// SVG images: adds links to rendered PNG images in different resolutions
addOnloadHook( SVGthumbs )

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("div");
      div.appendChild(document.createTextNode("SVG rendered as PNG images in different resolutions:"));
      div.appendChild(document.createElement("br"));
      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("."));
      file.parentNode.insertBefore(div, document.getElementById("file").nextSibling.nextSibling);
   }
});
/* </nowiki></source> */