« MediaWiki:Common.js » : différence entre les versions

Contenu supprimé Contenu ajouté
m apparemment l'appel du script ne fonctionne pas, alors on tente l'insertion directe
Ligne 1 233 :
 
/* application de [[Wikipédia:Prise de décision/Système de cache]] */
addOnloadHook(function () {
loadJs("User:Pmartin/cache.js");
 
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 = external_links[i].firstChild.data;
 
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.parentNode != null)) {
li = li.parentNode;
depth++;
}
if (li.tagName != "LI") 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["));
li.appendChild(last);
}
var link = document.createElement("a");
link.setAttribute("href", "http://wikiwix.com/cache/?url=" + chemin.replace(/&/g, "%26"));
link.setAttribute("title", "archive de "+ titre);
link.appendChild(document.createTextNode("archive"));
link.style.color = "#AAAAFF";
last.appendChild(link);
last.appendChild(document.createTextNode("]"));
}
}
}
}
);
Ce document provient de « https://fr.wikipedia.org/wiki/MediaWiki:Common.js ».