*
* Auteurs : Pabix, Phe
* Date de dernière révision : 1114 marsaoût 2007
*/
function ancrer(){
function noeud_precedent(noeud) {
while (noeud.previousSibling.nodeType!=1)
noeud = noeud.previousSibling;
return noeud.previousSibling;
}
}
if (!document.getElementById('content')) return;
var titres = document.getElementsByTagName("span");
var i = 0;
var titre_courant;
for (i = 0 boucle1; :i while< (titre_courant=titres[.length ; i]++){
var titre_courant = titres[i].parentNode;
i++;
if (titre_courant!titres[i].className.match(/mw-headline/g)) {continue;
if (!noeud_precedent(titre_courant)) continue;
var ancre_nom;
if (!noeud_precedent(titre_courant.parentNode).lastChild) {continue;
if (!noeud_precedent(titre_courant.parentNode).lastChild.name) {continue;
var ancre_nom = noeud_precedent(titre_courant.parentNode).lastChild.name;
var small;
} else continue boucle1;
var link;
} else continue boucle1;
if (AncreTitres_afficheE) {
var small = document.createElement('small'); with(small) {
innerHTML=AncreTitres_nom_ancre;
title=AncreTitres_description;
style.color=AncreTitres_linkcolor;
style.fontSize=AncreTitres_fontSize;
}
}
var link = document.createElement('a'); with(link) {
setAttribute("ancre", wgServer + wgScriptPath + "/index.php?title=" + wgPageName + "#" + ancre_nom) ;
setAttribute("onclick", "window.prompt('Lien : ', this.getAttribute('ancre'));");
appendChild(small);
}
}
if (AncreTitres_afficheE) titre_courant.parentNode.appendChild(link);
titre_courant.appendChild(link);
small = document.createElement('small'); with(small) { ▼
}
innerHTML=AncreTitres_nom_lien_interne; ▼
if (AncreTitres_afficheI) {
title=AncreTitres_descinterne; ▼
▲ small = document.createElement('small'); with(small) {
style.color=AncreTitres_linkcolor; ▼
▲ innerHTML=AncreTitres_nom_lien_interne;
style.fontSize=AncreTitres_fontSize; ▼
▲ title=AncreTitres_descinterne;
}
▲ style.color=AncreTitres_linkcolor;
link = document.createElement('a'); with(link) { ▼
▲ style.fontSize=AncreTitres_fontSize;
setAttribute("ancre", "[[" + wgPageName + "#" + ancre_nom + "]]"); ▼
}
setAttribute("onclick", "window.prompt('Lien : ', this.getAttribute('ancre'));"); ▼
▲ link = document.createElement('a'); with(link) {
▲ setAttribute("ancre", "[[" + wgPageName + "#" + ancre_nom + "]]");
}
▲ setAttribute("onclick", "window.prompt('Lien : ', this.getAttribute('ancre'));");
if (AncreTitres_afficheI) titre_courant.parentNode.appendChild(link);
}
}
}
titre_courant.appendChild(link);
}
}
}
addOnloadHook(ancrer);
//
//</source>[[Catégorie:MediaWiki:Fonction Monobook en JavaScript]]
|