« MediaWiki:Gadget-AncreTitres.js » : différence entre les versions

Contenu supprimé Contenu ajouté
Pabix (discussion | contributions)
mAucun résumé des modifications
Pabix (discussion | contributions)
m et voilà, ça marche mieux maintenant !
Ligne 7 :
*
* Auteurs : Pabix, Phe
* Date de dernière révision : 1415 août 2007
*/
}
 
var AncreTitres={
//////////////////////ZONE PERSONNALISABLE//////////////////////
nom_ancre : "[URL]",
var AncreTitres_nom_ancre = "[URL]"; // Texte lien externe
nom_lien_interne : "[[lien]]",
var AncreTitres_nom_lien_interne = "[[lien]]"; // Texte lien interne
vardescription AncreTitres_description =: "Obtenir une URL vers cette section"; // Infobulle du lien,
vardescinterne AncreTitres_descinterne =: "Obtenir un [[Lien#interne]]"; // Infobulle du lien,
linkcolor : "blue",
var AncreTitres_linkcolor="blue"; // Couleur du lien
fontSize : "50%",
var AncreTitres_fontSize="50%"; // Taille du lien
afficheE : true,
var AncreTitres_afficheE="true"; // Afficher le lien externe
afficheI : true,
var AncreTitres_afficheI="true"; // Afficher le lien interne
function noeud_precedent : function(noeud) {
/////////////////FIN DE LA ZONE PERSONNALISABLE/////////////////
while (noeud.previousSibling.nodeType!=1){
 
noeud = noeud.previousSibling;
if (noeud==null) return undefined;
}
return noeud.previousSibling;
}
}
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");
Ligne 34 :
for (i = 0 ; i < titres.length ; i++){
var titre_courant = titres[i].parentNode;
if (!(titres[i].className.match(/mw-headline/ggi))) continue;
if (!AncreTitres.noeud_precedent(titre_courant)) continue;
var ancre_nom;
if (!noeud_precedent(titre_courant).lastChild) continue;
if (!AncreTitres.noeud_precedent(titre_courant).lastChild.name) continue;!= null){
var ancre_nom = AncreTitres.noeud_precedent(titre_courant).lastChild.name;
} else {
if ancre_nom (!= AncreTitres.noeud_precedent(titre_courant).lastChild) continuename;
}
var small;
var link;
if (AncreTitres_afficheEAncreTitres.afficheE) {
small = document.createElement('small'); with(small) {
innerHTML=AncreTitres_nom_ancreAncreTitres.nom_ancre;
title=AncreTitres_descriptionAncreTitres.description;
style.color=AncreTitres_linkcolorAncreTitres.linkcolor;
style.fontSize=AncreTitres_fontSizeAncreTitres.fontSize;
}
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);
}
link = document.createElement('a'); with(link) {
link.setAttribute("ancre", wgServer + wgScriptPath + "/w/index.php?title=" + wgPageName + "#" + ancre_nom) ;
link.setAttribute("onclick", "window.prompt('Lien : ', this.getAttribute('ancre'));");
link.appendChild(small);
titre_courant.appendChild(link);
}
if (AncreTitres_afficheIAncreTitres.afficheI) {
small = document.createElement('small'); with(small) {
innerHTML=AncreTitres_nom_lien_interneAncreTitres.nom_lien_interne;
title=AncreTitres_descinterneAncreTitres.descinterne;
style.color=AncreTitres_linkcolorAncreTitres.linkcolor;
style.fontSize=AncreTitres_fontSizeAncreTitres.fontSize;
}
link = document.createElement('a'); with(link) {
setAttribute("ancre", "[[" + wgPageName + "#" + ancre_nom + "]]");
setAttribute("onclick", "window.prompt('Lien : ', this.getAttribute('ancre'));");
appendChild(small);
}
link = document.createElement('a'); with(link) {
link.setAttribute("ancre", "[[" + wgPageName + "#" + ancre_nom + "]]");
link.setAttribute("onclick", "window.prompt('Lien : ', this.getAttribute('ancre'));");
link.appendChild(small);
titre_courant.appendChild(link);
}
}
}
addOnloadHookaddOnLoadHook(ancrer);
//