« MediaWiki:Gadget-AncreTitres.js » : différence entre les versions
Contenu supprimé Contenu ajouté
mAucun résumé des modifications |
mAucun résumé des modifications |
||
Ligne 11 : | Ligne 11 : | ||
//////////////////////ZONE PERSONNALISABLE////////////////////// |
//////////////////////ZONE PERSONNALISABLE////////////////////// |
||
var AncreTitres_nom_ancre = "[ |
var AncreTitres_nom_ancre = "[lien]"; // Texte lien externe |
||
var AncreTitres_nom_lien_interne = "[[lien]]"; // Texte lien interne |
|||
var AncreTitres_description = "Obtenir une URL vers cette section"; // |
var AncreTitres_description = "Obtenir une URL vers cette section"; // Infobulle du lien |
||
var AncreTitres_descinterne = "Obtenir [[Lien#interne]]"; // Infobulle du lien |
|||
var AncreTitres_linkcolor="blue"; // Couleur du lien |
var AncreTitres_linkcolor="blue"; // Couleur du lien |
||
var AncreTitres_fontSize="50%"; // Taille du lien |
var AncreTitres_fontSize="50%"; // Taille du lien |
||
var AncreTitres_afficheE="true"; // Afficher le lien externe |
|||
var AncreTitres_afficheI="true"; // Afficher le lien interne |
|||
/////////////////FIN DE LA ZONE PERSONNALISABLE///////////////// |
/////////////////FIN DE LA ZONE PERSONNALISABLE///////////////// |
||
Ligne 43 : | Ligne 47 : | ||
appendChild(small); |
appendChild(small); |
||
} |
} |
||
titre_courant.parentNode.appendChild(link); |
if (AncreTitres_afficheE) titre_courant.parentNode.appendChild(link); |
||
small = document.createElement('small'); with(small) { |
|||
innerHTML=AncreTitres_lien_interne; |
|||
title=AncreTitres_descinterne; |
|||
style.color=AncreTitres_linkcolor; |
|||
style.fontSize=AncreTitres_fontSize; |
|||
} |
|||
link = document.createElement('a'); with(link) { |
|||
setAttribute("ancre", "[[" + wgPageName + "#" + noeud_precedent(titre_courant.parentNode).lastChild.name) + "]]"; |
|||
setAttribute("onclick", "window.prompt('Lien : ', this.getAttribute('ancre'));"); |
|||
appendChild(small); |
|||
} |
|||
if (AncreTitres_afficheI) titre_courant.parentNode.appendChild(link); |
|||
} |
} |
||
} |
} |
Version du 11 mars 2007 à 06:47
//<pre><nowiki>
/*
* AncreTitres
*
* Cette fonction fournit un lien vers une section de page en cliquant
* sur le lien [ancre] à droite du titre de section.
*
* Auteurs : Pabix, Phe
* Date de dernière révision : 11 mars 2007
*/
//////////////////////ZONE PERSONNALISABLE//////////////////////
var AncreTitres_nom_ancre = "[lien]"; // Texte lien externe
var AncreTitres_nom_lien_interne = "[[lien]]"; // Texte lien interne
var AncreTitres_description = "Obtenir une URL vers cette section"; // Infobulle du lien
var AncreTitres_descinterne = "Obtenir [[Lien#interne]]"; // Infobulle du lien
var AncreTitres_linkcolor="blue"; // Couleur du lien
var AncreTitres_fontSize="50%"; // Taille du lien
var AncreTitres_afficheE="true"; // Afficher le lien externe
var AncreTitres_afficheI="true"; // Afficher le lien interne
/////////////////FIN DE LA ZONE PERSONNALISABLE/////////////////
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;
while (titre_courant=titres[i]){
i++;
if (titre_courant.className.match(/mw-headline/g)) {
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 + "#" + noeud_precedent(titre_courant.parentNode).lastChild.name);
setAttribute("onclick", "window.prompt('Lien : ', this.getAttribute('ancre'));");
appendChild(small);
}
if (AncreTitres_afficheE) titre_courant.parentNode.appendChild(link);
small = document.createElement('small'); with(small) {
innerHTML=AncreTitres_lien_interne;
title=AncreTitres_descinterne;
style.color=AncreTitres_linkcolor;
style.fontSize=AncreTitres_fontSize;
}
link = document.createElement('a'); with(link) {
setAttribute("ancre", "[[" + wgPageName + "#" + noeud_precedent(titre_courant.parentNode).lastChild.name) + "]]";
setAttribute("onclick", "window.prompt('Lien : ', this.getAttribute('ancre'));");
appendChild(small);
}
if (AncreTitres_afficheI) titre_courant.parentNode.appendChild(link);
}
}
}
addLoadEvent(ancrer);
//</nowiki></pre>[[Catégorie:MediaWiki:Fonction Monobook en JavaScript]]