Uzanto:ArnoLagrange/cache.js

El Vikipedio, la libera enciklopedio

Notu:Post publikigo forviŝu la kaŝmemoron de via foliumilo por vidi la ŝanĝojn.

  • Firefox / Safari: Premu majuskligan klavon klakante Reŝarĝi, aŭ premu aŭ Stir-F5Stir-R (⌘-R kun Makintoŝo)
  • Google Chrome: Premu Stir-majuskligklavon-R (⌘-Majuskligklavo-R kun Makintoŝo)
  • Interreta Esplorilo / Edge: Premu Stir klakante Refreŝu, aŭ premu Stir-F5
  • Opera: Premu Stir-F5.
$(function () {
 
  if (wgNamespaceNumber == 0) {
    if ((typeof no_external_cache != "undefined") && (no_external_cache)) return;
    addcache();
  }
 
  function addcache() {
    var external_links;
    if (document.getElementsByClassName) {
      external_links = document.getElementsByClassName('external');
    } else {
      external_links = getElementsByClass('external',document.getElementById("bodyContent"),'a');
    }
 
    if (external_links.length > 50) return;
 
    for( i = 0;i < external_links.length;i++) 
    {
      var chemin = external_links[i].href;
    var titre = getTextContent(external_links[i]);
 
      if(chemin.indexOf("http://wikiwix.com/cache/")==-1 && chemin.indexOf("http://web.archive.org/web/*/")==-1)
      {
      var li = external_links[i].parentNode;
      var depth = 0;
      while ((depth < 3) && (li.tagName != "LI") && (li.tagName!= "DD") && (li.parentNode != null)) {
        li = li.parentNode;
        depth++;
      }
 
      if ((li.tagName != "LI") && (li.tagName!= "DD")) continue;
      var last = li.lastChild;

      if ((last.tagName == "SUP") && (last.getAttribute("class") == "cachelinks"))
      {
        last.replaceChild(document.createTextNode(", "), last.lastChild);
      }
      else
      {
        last = document.createElement("small");
        last.setAttribute("class", "cachelinks");
        last.style.color = "#AAAAFF";
        last.appendChild(document.createTextNode("\u00a0["));
        insertAfter(external_links[i].parentNode, last, external_links[i]);
      }
 
 
      var link = document.createElement("a");
      link.setAttribute("href", "http://wikiwix.com/cache/?url=" + chemin.replace(/&/g, "%26"));
      link.setAttribute("title", "arĥivo de "+ titre);
      link.appendChild(document.createTextNode("arĥivo"));
      link.style.color = "#AAAAFF";
      last.appendChild(link);
      last.appendChild(document.createTextNode("]"));
      }
    }
  }
 
 
// Taŭge akiras la tekstan entenon de nodo kaj de ties idaro
// Kopirajto Harmen Christophe, http://openweb.eu.org/articles/validation_avancee, CC
function getTextContent(oNode) {
  if (typeof(oNode.textContent)!="undefined") {return oNode.textContent;}
  switch (oNode.nodeType) {
    case 3: // TEXT_NODE
    case 4: // CDATA_SECTION_NODE
      return oNode.nodeValue;
      break;
    case 7: // PROCESSING_INSTRUCTION_NODE
    case 8: // COMMENT_NODE
      if (getTextContent.caller!=getTextContent) {
        return oNode.nodeValue;
      }
      break;
    case 9: // DOCUMENT_NODE
    case 10: // DOCUMENT_TYPE_NODE
    case 12: // NOTATION_NODE
      return null;
      break;
  }
  var _textContent = "";
  oNode = oNode.firstChild;
  while (oNode) {
    _textContent += getTextContent(oNode);
    oNode = oNode.nextSibling;
  }
  return _textContent;
}
 
/**
* insertAfter : enmeti eron en paĝon 
*/
function insertAfter(parent, node, referenceNode) {
  parent.insertBefore(node, referenceNode.nextSibling); 
}
 
}
);