Utilisateur:Pmartin/vector.js
Note : après avoir publié vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
- Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
- Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
- Internet Explorer / Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
- Opera : appuyez sur Ctrl + F5.
/**
* application de [[w:Wikipédia:Prise de décision/Système de cache]], puis [[Wikiversité:La_salle_café/33_2010]]
* un <span class="noarchive"> autour du lien l'empêche d'être pris en compte
* pour celui-ci uniquement
* un no_external_cache=true dans un monobook personnel désactive le script
*/
$(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');
}
for( i = 0;i < external_links.length;i++)
{
var chemin = external_links[i].href;
if(chemin.indexOf("http://wikiwix.com/cache/")==-1 && chemin.indexOf("http://web.archive.org/web/*/")==-1 && chemin.indexOf(wgServer)==-1 && chemin.indexOf("wikimedia.org")==-1 && chemin.indexOf("stable.toolserver.org")==-1)
{
var li = external_links[i].parentNode;
if (li.className == "noarchive") continue;
var depth = 0;
while ((depth < 3) && (li.tagName != "OL") && (li.parentNode != null)) {
li = li.parentNode;
depth++;
}
var titre = getTextContent(external_links[i]);
var last = document.createElement("small");
last.setAttribute("class", "cachelinks");
last.style.color = "#3366BB";
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/?org=" + wgServer + "&url=" + chemin.replace(/%/g, "%25").replace(/&/g, "%26") + "&title=" + encodeURIComponent(titre));
link.setAttribute("title", "archive de "+ titre);
link.appendChild(document.createTextNode("archive"));
link.style.color = "#3366BB";
last.appendChild(link);
last.appendChild(document.createTextNode("]"));
}
}
}
}
);
// Récupère proprement le contenu textuel d'un noeud et de ses noeuds descendants
// Copyright 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 : insérer un élément dans une page
*/
function insertAfter(parent, node, referenceNode) {
parent.insertBefore(node, referenceNode.nextSibling);
}