MediaWiki:Monobook.js : Différence entre versions
Un article de JurisPedia, le droit partagé.
| Ligne 3 : | Ligne 3 : | ||
/* under a GNU Free Documentation License http://www.gnu.org/copyleft/fdl.html */ | /* under a GNU Free Documentation License http://www.gnu.org/copyleft/fdl.html */ | ||
/* tooltips and access keys */ | /* tooltips and access keys */ | ||
| + | /* <pre> <nowiki> */ | ||
| + | //============================================================ | ||
| + | // | ||
| + | // Info-bulle et touches de raccourci | ||
| + | // | ||
| + | //============================================================ | ||
| + | |||
ta = new Object(); | ta = new Object(); | ||
| − | ta['pt-userpage'] = new Array('.','Ma page utilisateur'); | + | ta['pt-userpage'] = new Array('.', 'Ma page utilisateur'); |
| − | ta['pt-anonuserpage'] = new Array('.','La page utilisateur pour l\'adresse IP que vous utilisez'); | + | ta['pt-anonuserpage'] = new Array('.', 'La page utilisateur pour l\'adresse IP que vous utilisez'); |
| − | ta['pt-mytalk'] = new Array('N','Ma page de discussion'); | + | ta['pt-mytalk'] = new Array('N', 'Ma page de discussion'); |
| − | ta['pt-anontalk'] = new Array('N','La page de discussion pour cette adresse'); | + | ta['pt-anontalk'] = new Array('N', 'La page de discussion pour cette adresse'); |
| − | ta['pt-preferences'] = new Array('','Mes préférences'); | + | ta['pt-preferences'] = new Array('', 'Mes préférences'); |
| − | ta['pt-watchlist'] = new Array('L','La liste des pages que vous suivez'); | + | ta['pt-watchlist'] = new Array('L', 'La liste des pages que vous suivez'); |
| − | ta['pt-mycontris'] = new Array('Y','La liste de mes contributions'); | + | ta['pt-mycontris'] = new Array('Y', 'La liste de mes contributions'); |
| − | + | ta['ca-talk'] = new Array('T', 'Discussion pour cette page'); | |
| − | + | ta['ca-edit'] = new Array('E', 'Vous pouvez modifier cette page. Merci de prévisualiser avant d\'enregistrer.'); | |
| − | + | ta['ca-addsection'] = new Array('+', 'Ajouter un commentaire à cette discussion.'); | |
| − | + | ta['ca-viewsource'] = new Array('E', 'Cette page est protégée. Vous pouvez toutefois en voir le contenu.'); | |
| − | + | ta['ca-history'] = new Array('H', 'Les auteurs et versions précédentes de cette page.'); | |
| − | ta['ca-talk'] = new Array('T','Discussion pour cette page'); | + | ta['ca-protect'] = new Array('=', 'Pour protéger cette page.'); |
| − | ta['ca-edit'] = new Array('E','Vous pouvez modifier cette page. Merci de prévisualiser avant d\'enregistrer.'); | + | ta['ca-delete'] = new Array('D', 'Pour supprimer cette page.'); |
| − | ta['ca-addsection'] = new Array('+','Ajouter un commentaire à cette discussion.'); | + | ta['ca-undelete'] = new Array('D', 'Pour restaurer cette page.'); |
| − | ta['ca-viewsource'] = new Array('E','Cette page est protégée. Vous pouvez toutefois en voir le contenu.'); | + | ta['ca-move'] = new Array('M', 'Pour déplacer ou renommer cette page.'); |
| − | ta['ca-history'] = new Array('H','Les versions précédentes de cette page.'); | + | ta['ca-nomove'] = new Array('', 'Vous n\'avez pas la permission de déplacer cette page.'); |
| − | ta['ca-protect'] = new Array('=','Pour protéger cette page.'); | + | ta['ca-watch'] = new Array('W', 'Ajoutez cette page à votre liste de suivi.'); |
| − | ta['ca-delete'] = new Array('D','Pour supprimer cette page.'); | + | ta['ca-unwatch'] = new Array('W', 'Retirez cette page de votre liste de suivi.'); |
| − | ta['ca-undelete'] = new Array('D','Pour restaurer cette page.'); | + | ta['search'] = new Array('F', 'Pour effectuer une recherche.'); |
| − | ta['ca-move'] = new Array('M','Pour déplacer ou renommer cette page.'); | + | ta['p-logo'] = new Array('', 'Page principale.'); |
| − | ta['ca-nomove'] = new Array('','Vous n\'avez pas la permission de déplacer cette page.'); | + | ta['n-mainpage'] = new Array('Z', 'Pour afficher la page principale.'); |
| − | ta['ca-watch'] = new Array('W','Ajoutez cette page à votre liste de suivi.'); | + | ta['n-portal'] = new Array('', 'À propos du projet.'); |
| − | ta['ca-unwatch'] = new Array('W','Retirez cette page de votre liste de suivi.'); | + | ta['n-currentevents'] = new Array('', 'Trouvez des informations sur les événements récents.'); |
| − | ta['search'] = new Array('F','Pour effectuer une recherche.'); | + | ta['n-recentchanges'] = new Array('R', 'La liste des modifications récentes.'); |
| − | ta['p-logo'] = new Array('','Page principale.'); | + | ta['n-randompage'] = new Array('X', 'Afficher une page au hasard.'); |
| − | ta['n-mainpage'] = new Array('Z','Pour afficher la page principale.'); | + | ta['n-help'] = new Array('', 'Aide.'); |
| − | ta['n-portal'] = new Array('','À propos du projet.'); | + | ta['n-sitesupport'] = new Array('', 'Pour soutenir le projet.'); |
| − | ta['n-currentevents'] = new Array('','Trouvez des informations sur les événements récents.'); | + | ta['t-whatlinkshere'] = new Array('J', 'Liste des pages liées à celle-ci.'); |
| − | ta['n-recentchanges'] = new Array('R','La liste des modifications récentes.'); | + | ta['t-recentchangeslinked'] = new Array('K', 'Liste des modifications récentes des pages liées à celle-ci.'); |
| − | ta['n-randompage'] = new Array('X','Afficher une page au hasard.'); | + | ta['feed-rss'] = new Array('', 'Alimenter le flux RSS pour cette page.'); |
| − | ta['n-help'] = new Array('','Aide.'); | + | ta['feed-atom'] = new Array('', 'Alimenter le flux Atom pour cette page.'); |
| − | ta['n-sitesupport'] = new Array('',' | + | ta['t-contributions'] = new Array('', 'Voir la liste des contributions de cet utilisateur.'); |
| − | ta['t-whatlinkshere'] = new Array('J','Liste des pages liées à celle-ci.'); | + | ta['t-emailuser'] = new Array('', 'Envoyer un courriel à cet utilisateur.'); |
| − | ta['t-recentchangeslinked'] = new Array('K','Liste des modifications récentes des pages liées à celle-ci.'); | + | ta['t-upload'] = new Array('U', 'Importer une image ou fichier média sur le serveur.'); |
| − | ta['feed-rss'] = new Array('','Alimenter le flux RSS pour cette page.'); | + | ta['t-specialpages'] = new Array('Q', 'Liste des pages spéciales.'); |
| − | ta['feed-atom'] = new Array('','Alimenter le flux Atom pour cette page.'); | + | ta['ca-nstab-main'] = new Array('C', 'Afficher le contenu de cette page.'); |
| − | ta['t-contributions'] = new Array('','Voir la liste des contributions de cet utilisateur.'); | + | ta['ca-nstab-user'] = new Array('C', 'Afficher la page utilisateur.'); |
| − | ta['t-emailuser'] = new Array('','Envoyer un courriel à cet utilisateur.'); | + | ta['ca-nstab-media'] = new Array('C', 'Afficher la page média.'); |
| − | ta['t-upload'] = new Array('U','Importer une image ou fichier média sur le serveur.'); | + | ta['ca-nstab-special'] = new Array('', 'Ceci est une page spéciale, vous ne pouvez pas la modifier.'); |
| − | ta['t-specialpages'] = new Array('Q','Liste des pages spéciales.'); | + | ta['ca-nstab-wp'] = new Array('A', 'Afficher la page du projet.'); |
| − | ta['ca-nstab-main'] = new Array('C','Afficher le contenu de cette page.'); | + | ta['ca-nstab-image'] = new Array('C', 'Afficher la page de description de l\'image.'); |
| − | ta['ca-nstab-user'] = new Array('C','Afficher la page utilisateur.'); | + | ta['ca-nstab-mediawiki'] = new Array('C', 'Afficher le message système.'); |
| − | ta['ca-nstab-media'] = new Array('C','Afficher la page média.'); | + | ta['ca-nstab-template'] = new Array('C', 'Afficher le modèle.'); |
| − | ta['ca-nstab-special'] = new Array('','Ceci est une page spéciale, vous ne pouvez pas la modifier.'); | + | ta['ca-nstab-help'] = new Array('C', 'Afficher la page d\'aide.'); |
| − | ta['ca-nstab-wp'] = new Array('A','Afficher la page du projet.'); | + | ta['ca-nstab-category'] = new Array('C', 'Afficher la page de catégorie.'); |
| − | ta['ca-nstab-image'] = new Array('C','Afficher la page de description de l\'image.'); | + | |
| − | ta['ca-nstab-mediawiki'] = new Array('C','Afficher le message système.'); | + | |
| − | ta['ca-nstab-template'] = new Array('C','Afficher le modèle.'); | + | |
| − | ta['ca-nstab-help'] = new Array('C','Afficher la page d\'aide.'); | + | |
| − | ta['ca-nstab-category'] = new Array('C','Afficher la page de catégorie.'); | + | |
| − | // ============================================================ | + | //============================================================ |
| − | // | + | // |
| + | // Fonctions de gestion | ||
| + | // | ||
| + | //============================================================ | ||
| − | / | + | /** |
| − | + | * Installation d'une nouvelle fonction de cette façon: | |
| − | + | * aOnloadFunctions[aOnloadFunctions.length] = nom_de_la_fonction; // (sans parenthèses) | |
| − | if (!window.aOnloadFunctions) { | + | */ |
| − | var aOnloadFunctions = new Array(); | + | if (!window.aOnloadFunctions) { |
| + | var aOnloadFunctions = new Array(); | ||
} | } | ||
| − | window.onload = function() { | + | window.onload = function() |
| + | { | ||
if (window.aOnloadFunctions) { | if (window.aOnloadFunctions) { | ||
for (var _i=0; _i<aOnloadFunctions.length; _i++) { | for (var _i=0; _i<aOnloadFunctions.length; _i++) { | ||
| Ligne 74 : | Ligne 81 : | ||
} | } | ||
| − | |||
| − | |||
| + | /** | ||
| + | * Ajouter une nouvelle fonction a excuter au chargement de la page. | ||
| + | */ | ||
| + | function addLoadEvent(func) | ||
| + | { | ||
| + | if (window.addEventListener) | ||
| + | window.addEventListener("load", func, false); | ||
| + | else if (window.attachEvent) | ||
| + | window.attachEvent("onload", func); | ||
| + | } | ||
| − | // ============================================================ | + | //============================================================ |
| − | // BEGIN Dynamic Navigation Bars | + | // |
| − | + | // Boites deroulantes | |
| − | // set up the words in your language | + | // |
| − | var NavigationBarHide = 'Enrouler'; | + | //============================================================ |
| − | var NavigationBarShow = 'Dérouler'; | + | // BEGIN Dynamic Navigation Bars (experimantal) |
| − | + | ||
| − | // set up max count of Navigation Bars on page, | + | // set up the words in your language |
| − | // if there are more, all will be hidden | + | var NavigationBarHide = '[ Enrouler ]'; |
| − | // NavigationBarShowDefault = 0; // all bars will be hidden | + | var NavigationBarShow = '[ Dérouler ]'; |
| − | // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden | + | |
| − | var NavigationBarShowDefault = | + | // set up max count of Navigation Bars on page, |
| − | + | // if there are more, all will be hidden | |
| − | + | // NavigationBarShowDefault = 0; // all bars will be hidden | |
| − | // shows and hides content and picture (if available) of navigation bars | + | // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden |
| − | // Parameters: | + | var NavigationBarShowDefault = 0; |
| − | // indexNavigationBar: the index of navigation bar to be toggled | + | |
| − | function toggleNavigationBar(indexNavigationBar) | + | |
| − | { | + | // shows and hides content and picture (if available) of navigation bars |
| + | // Parameters: | ||
| + | // indexNavigationBar: the index of navigation bar to be toggled | ||
| + | function toggleNavigationBar(indexNavigationBar) | ||
| + | { | ||
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); | var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); | ||
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); | var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); | ||
| − | + | ||
if (!NavFrame || !NavToggle) { | if (!NavFrame || !NavToggle) { | ||
return false; | return false; | ||
} | } | ||
| − | + | ||
// if shown now | // if shown now | ||
if (NavToggle.firstChild.data == NavigationBarHide) { | if (NavToggle.firstChild.data == NavigationBarHide) { | ||
| Ligne 116 : | Ligne 135 : | ||
if (NavChild.className == 'NavContent') { | if (NavChild.className == 'NavContent') { | ||
NavChild.style.display = 'none'; | NavChild.style.display = 'none'; | ||
| − | |||
| − | |||
| − | |||
} | } | ||
} | } | ||
| − | + | NavToggle.firstChild.data = NavigationBarShow; | |
| + | |||
// if hidden now | // if hidden now | ||
} else if (NavToggle.firstChild.data == NavigationBarShow) { | } else if (NavToggle.firstChild.data == NavigationBarShow) { | ||
| Ligne 134 : | Ligne 151 : | ||
if (NavChild.className == 'NavContent') { | if (NavChild.className == 'NavContent') { | ||
NavChild.style.display = 'block'; | NavChild.style.display = 'block'; | ||
| − | |||
| − | |||
| − | |||
} | } | ||
} | } | ||
| + | NavToggle.firstChild.data = NavigationBarHide; | ||
} | } | ||
| − | } | + | } |
| − | + | ||
| − | // adds show/hide-button to navigation bars | + | // adds show/hide-button to navigation bars |
| − | function createNavigationBarToggleButton() | + | function createNavigationBarToggleButton() |
| − | { | + | { |
var indexNavigationBar = 0; | var indexNavigationBar = 0; | ||
| − | // iterate over all <div>-elements | + | // iterate over all < div >-elements |
for( | for( | ||
var i=0; | var i=0; | ||
| Ligne 154 : | Ligne 169 : | ||
// if found a navigation bar | // if found a navigation bar | ||
if (NavFrame.className == "NavFrame") { | if (NavFrame.className == "NavFrame") { | ||
| − | + | ||
indexNavigationBar++; | indexNavigationBar++; | ||
var NavToggle = document.createElement("a"); | var NavToggle = document.createElement("a"); | ||
| Ligne 160 : | Ligne 175 : | ||
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); | NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); | ||
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); | NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); | ||
| − | + | ||
var NavToggleText = document.createTextNode(NavigationBarHide); | var NavToggleText = document.createTextNode(NavigationBarHide); | ||
NavToggle.appendChild(NavToggleText); | NavToggle.appendChild(NavToggleText); | ||
| − | + | // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) | |
| − | // | + | for( |
| − | + | var j=0; | |
| − | NavFrame. | + | j < NavFrame.childNodes.length; |
| − | + | j++ | |
| − | NavFrame. | + | ) { |
| − | + | if (NavFrame.childNodes[j].className == "NavHead") { | |
| + | NavFrame.childNodes[j].appendChild(NavToggle); | ||
| + | } | ||
| + | } | ||
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); | NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); | ||
} | } | ||
| Ligne 183 : | Ligne 201 : | ||
} | } | ||
} | } | ||
| + | |||
| + | } | ||
| + | |||
| + | addLoadEvent(createNavigationBarToggleButton); | ||
| + | |||
| + | // END Dynamic Navigation Bars | ||
| + | //============================================================ | ||
| + | // | ||
| + | // Fonctions de remplissage automatique | ||
| + | // | ||
| + | //============================================================ | ||
| + | |||
| + | function InitPaS(page_name) | ||
| + | { | ||
| + | var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->"; | ||
| + | var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des Pages à supprimer -->"; | ||
| + | var tpl = '{{subst:' + 'Initialiser PàS|' + page_name | ||
| + | + '|~~~~|jour={{subst:CURRENTDAY}}|mois={{subst:CURRENTMONTH}}}}'; | ||
| + | return c1 + '\n' + tpl + '\n' + c2; | ||
} | } | ||
| − | + | function InitPaV(page_name) | |
| + | { | ||
| + | var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->"; | ||
| + | var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des Pages à vérifier -->"; | ||
| + | var tpl = '{{subst:' + 'Initialiser PàV|' + page_name + '|~~~~}}'; | ||
| + | return c1 + '\n' + tpl + '\n' + c2; | ||
| + | } | ||
| + | |||
| + | function InitLANN(page_name) | ||
| + | { | ||
| + | var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->"; | ||
| + | var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des articles non neutres -->"; | ||
| + | var tpl = '{{subst:' + 'Initialiser LANN|' + page_name + '|~~~~}}'; | ||
| + | return c1 + '\n' + tpl + '\n' + c2; | ||
| + | } | ||
| + | |||
| + | function InitIaS(page_name) | ||
| + | { | ||
| + | var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->"; | ||
| + | var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des Images à supprimer -->"; | ||
| + | var tpl = '{{subst:' + 'Initialiser IàS|' + page_name + '|~~~~|jour={{subst:CURRENTDAY}}|mois={{subst:CURRENTMONTH}}}}'; | ||
| + | return c1 + '\n' + tpl + '\n' + c2; | ||
| + | } | ||
| + | |||
| + | function InitPAdQ(page_name) | ||
| + | { | ||
| + | var c1 = "<!--\n À la création de la page, suivez les consignes ci-dessous pour proposer l'article.\n\n ATTENTION : Veuillez ne rien effacer !\n-->"; | ||
| + | var tpl = '{{subst:' + 'Initialiser PAdQ|' + page_name + '|~~~~'; | ||
| + | var c2 = "| 1. Indiquez sur la ligne ci-dessous la raison pour laquelle vous proposez cet article. Vous n'avez pas besoin de signer/dater, ni de voter par la suite : votre proposition tient lieu de vote 'Pour'. |"; | ||
| + | var tpl2 = "Je propose cet article car... (votre motivation)"; | ||
| + | var c3 = "| 2. Sauvegardez cette page et créez un lien vers elle dans Jurispedia:Proposition articles de qualité."; | ||
| + | var c4 = "Pour cela, choisissez une thématique dans la page, modifiez-la et ajoutez un lien sous la forme :"; | ||
| + | var c5 = "** [[/" + page_name + "]] proposé le ~~~~~ "; | ||
| + | var c6 = "Vous devez créer cette référence dans la section 'Phase I' de la thématique choisie (suivez les autres exemples)."; | ||
| + | return c1 + '\n\n' + tpl + '\n' + c2 + '\n' + tpl2 + '\n\n' + c3 + '\n\n' + c4 + '\n' + c5 + '\n' + c6 + '}}\n'; | ||
| + | } | ||
| + | |||
| + | function InitIaA(page_name) | ||
| + | { | ||
| + | var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->"; | ||
| + | return c1 + '\n{{subst:Amélioration image}}' | ||
| + | } | ||
| + | |||
| + | function InitPCP(page_name) | ||
| + | { | ||
| + | var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->"; | ||
| + | var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des articles soupçonnées de violation de copyright -->"; | ||
| + | var tpl = '{{subst:' + 'Initialiser PCP|' + page_name + '|~~~~}}'; | ||
| + | return c1 + '\n' + tpl + '\n' + c2; | ||
| + | } | ||
| + | |||
| + | function InitArbReq(page_name) | ||
| + | { | ||
| + | var c1 = "<" + "!-- Remplissez les champs (???) puis sauvegardez --" + ">\n"; | ||
| + | var c2 = "[[Catégorie:Arbitrage en cours]]\n{" + "{Page d'arbitrage}}\n\nArbitre coordinateur :\n\n"; | ||
| + | var c3 = "Arbitre(s) ne participant pas à cet arbitrage :\n\n"; | ||
| + | var c4 = "== Description du conflit ==\n\n'''Demande déposée par''' : [[Utilisateur:X|X]] le ??? à ???\n\n"; | ||
| + | var c5 = "''Parties concernées par le conflit'' : ??? et [[Utilisateur:???|]] (et [[Utilisateur:???|]]).\n\n"; | ||
| + | var c6 = "''Nature du conflit'' : ???\n\n"; | ||
| + | var c7 = "''Recevabilité'' :\n\n''Décision'' :\n\n"; | ||
| + | var c8 = "== Arguments de ??? ==\n{" + "{CAr limite des arguments}}\n\n"; | ||
| + | var c9 = c8; | ||
| + | var c10 = "== Recevabilité ==\n\n== Mesures conservatoires ==\n<" + "!-- Mesures telles que protection de page, interdiction d'édition ou blocage, décidée par le coordinateur, avec justification. Les autres arbitres y réagissent ici. --" + ">\n\n== Discussion sur le fond ==\n\n=== Commentaires des arbitres ===\n\n"; | ||
| + | var c11 = "=== Propositions ===\n\n==== Proposition 1 ====\n\n<u>Proposition :</u>\n\n<u>Vote :</u>"; | ||
| + | return c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10 + c11; | ||
| + | } | ||
| + | |||
| + | var init_if_empty = new Array( | ||
| + | new Array('Jurispedia:Pages_%C3%A0_supprimer/', InitPaS), | ||
| + | new Array('Jurispedia:Pages_%C3%A0_v%C3%A9rifier/', InitPaV), | ||
| + | new Array('Jurispedia:Liste_des_articles_non_neutres/', InitLANN), | ||
| + | new Array('Jurispedia:Images_%C3%A0_supprimer/', InitIaS), | ||
| + | new Array('Jurispedia:Proposition_articles_de_qualit%C3%A9/', InitPAdQ), | ||
| + | new Array('Jurispedia:Pages_soup%C3%A7onn%C3%A9es_de_violation_de_copyright/', InitPCP), | ||
| + | new Array('Jurispedia:Comit%C3%A9_d%27arbitrage/Arbitrage/', InitArbReq) | ||
| + | ); | ||
| + | |||
| + | /** | ||
| + | * Remplit la zone d'édition si elle est vide avec le texte retourné par | ||
| + | * un pointeur de fonction sélectionné par le nom de la page. | ||
| + | */ | ||
| + | function InitPage() | ||
| + | { | ||
| + | // TODO, il faut tester l'existence de l'edit box et la longueur | ||
| + | // du texte en dehors de la boucle | ||
| + | ugly_url = 'http://fr.jurispedia.org/index.php?title='; | ||
| + | for (var i = 0; i < init_if_empty.length; ++i) { | ||
| + | var page_name = document.URL; | ||
| + | var page_match = init_if_empty[i][0]; | ||
| + | var index = page_name.indexOf(ugly_url + page_match); | ||
| + | if (index != -1) { | ||
| + | var text_area = document.editform.wpTextbox1; | ||
| + | if (text_area.value.length == 0) { | ||
| + | page_name = page_name.slice((ugly_url + page_match).length); | ||
| + | page_name = page_name.split('&')[0]; | ||
| + | page_name = decodeURI(page_name); | ||
| + | page_name = page_name.replace(/_/g, ' ') | ||
| + | text_area.value = init_if_empty[i][1](page_name); | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | addLoadEvent(InitPage); | ||
| + | |||
| + | |||
| + | //============================================================ | ||
| + | // | ||
| + | // Caractères spéciaux | ||
| + | // | ||
| + | //============================================================ | ||
| + | |||
| + | /** | ||
| + | * Ajoutez le menu pour choisir des sous-ensembles de caractères spéciaux | ||
| + | * @note L'ordre de cette liste doit correspondre a celui de MediaWiki:Edittools ! | ||
| + | */ | ||
| + | function addCharSubsetMenu() { | ||
| + | var specialchars = document.getElementById('specialchars'); | ||
| + | |||
| + | if (specialchars) { | ||
| + | var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">"; | ||
| + | menu += "<option>Wiki</option>"; | ||
| + | menu += "<option>Mathématiques</option>"; | ||
| + | menu += "<option>API</option>"; | ||
| + | menu += "<option>Latin/Romain</option>"; | ||
| + | menu += "<option>Grec</option>"; | ||
| + | menu += "<option>Cyrillique</option>"; | ||
| + | menu += "<option>AHD</option>"; | ||
| + | menu += "<option>Allemand</option>"; | ||
| + | menu += "<option>Arabe</option>"; | ||
| + | menu += "<option>Catalan</option>"; | ||
| + | menu += "<option>Croate</option>"; | ||
| + | menu += "<option>Espagnol</option>"; | ||
| + | menu += "<option>Espéranto</option>"; | ||
| + | menu += "<option>Estonien</option>"; | ||
| + | menu += "<option>Gallois</option>"; | ||
| + | menu += "<option>Hawaien</option>"; | ||
| + | menu += "<option>Hébreu</option>"; | ||
| + | menu += "<option>Hiéroglyphe</option>"; | ||
| + | menu += "<option>Hollandais</option>"; | ||
| + | menu += "<option>Hongrois</option>"; | ||
| + | menu += "<option>Indo-européen</option>"; | ||
| + | menu += "<option>Irlandais</option>"; | ||
| + | menu += "<option>Islandais</option>"; | ||
| + | menu += "<option>Italien</option>"; | ||
| + | menu += "<option>Letton</option>"; | ||
| + | menu += "<option>Lituanien</option>"; | ||
| + | menu += "<option>Maltais</option>"; | ||
| + | menu += "<option>Navajo & Apache</option>"; | ||
| + | menu += "<option>Pinyin</option>"; | ||
| + | menu += "<option>Polonais</option>"; | ||
| + | menu += "<option>Portugais</option>"; | ||
| + | menu += "<option>Rōmaji</option>"; | ||
| + | menu += "<option>Roumain</option>"; | ||
| + | menu += "<option>Scandinave</option>"; | ||
| + | menu += "<option>Serbe</option>"; | ||
| + | menu += "<option>Tchèque</option>"; | ||
| + | menu += "<option>Turc</option>"; | ||
| + | menu += "<option>Vieil anglais</option>"; | ||
| + | menu += "<option>Vietnamien</option>"; | ||
| + | menu += "<option>Yiddish</option>"; | ||
| + | menu += "</select>"; | ||
| + | specialchars.innerHTML = menu + specialchars.innerHTML; | ||
| + | |||
| + | /* default subset - try to use a cookie some day */ | ||
| + | chooseCharSubset(0); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | /* select subsection of special characters */ | ||
| + | function chooseCharSubset(s) { | ||
| + | var l = document.getElementById('specialchars').getElementsByTagName('p'); | ||
| + | for (var i = 0; i < l.length ; i++) { | ||
| + | l[i].style.display = i == s ? 'inline' : 'none'; | ||
| + | l[i].style.visibility = i == s ? 'visible' : 'hidden'; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | addLoadEvent(addCharSubsetMenu); | ||
| + | |||
| + | |||
| + | //============================================================ | ||
| + | // | ||
| + | // Choix de l'affichage des références | ||
| + | // | ||
| + | //============================================================ | ||
| + | |||
| + | /** | ||
| + | * Choix du mode d'affichage des références. | ||
| + | * @note L'ordre de cette liste doit correspondre a celui de Modèle:Édition ! | ||
| + | */ | ||
| + | function addBibSubsetMenu() | ||
| + | { | ||
| + | var specialBib = document.getElementById('specialBib'); | ||
| + | |||
| + | if (specialBib) | ||
| + | { | ||
| + | specialBib.style.display = 'block'; | ||
| + | var menu = "<select style=\"display:inline;\" onChange=\"chooseBibSubset(selectedIndex)\">"; | ||
| + | menu += "<option>Liste</option>"; | ||
| + | menu += "<option>WikiNorme</option>"; | ||
| + | menu += "<option>BibTeX</option>"; | ||
| + | menu += "<option>ISBD</option>"; | ||
| + | menu += "<option>ISO690</option>"; | ||
| + | menu += "</select>"; | ||
| + | specialBib.innerHTML = specialBib.innerHTML + menu; | ||
| + | } | ||
| + | /* default subset - try to use a cookie some day */ | ||
| + | chooseBibSubset(0); | ||
| + | } | ||
| + | |||
| + | /* select subsection of special characters */ | ||
| + | function chooseBibSubset(s) | ||
| + | { | ||
| + | var l = document.getElementsByTagName('div'); | ||
| + | for (var i = 0; i < l.length ; i++) | ||
| + | { | ||
| + | if(l[i].className == 'BibList') l[i].style.display = s == 0 ? 'block' : 'none'; | ||
| + | else if(l[i].className == 'WikiNorme') l[i].style.display = s == 1 ? 'block' : 'none'; | ||
| + | else if(l[i].className == 'BibTeX') l[i].style.display = s == 2 ? 'block' : 'none'; | ||
| + | else if(l[i].className == 'ISBD') l[i].style.display = s == 3 ? 'block' : 'none'; | ||
| + | else if(l[i].className == 'ISO690') l[i].style.display = s == 4 ? 'block' : 'none'; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | addLoadEvent(addBibSubsetMenu); | ||
| + | |||
| + | |||
| + | |||
| + | //============================================================ | ||
| + | // | ||
| + | // Prévisualisation rapide | ||
| + | // | ||
| + | //============================================================ | ||
| + | |||
| + | /** | ||
| + | * Script de ajoutant une option de prévisualisation rapide. | ||
| + | * | ||
| + | * | ||
| + | * English: Add a Quick View option on the Edit pages. | ||
| + | * This script add 2 new buttons into the "editButtons" div. | ||
| + | * When QuickPrev button is press, the content of edit window | ||
| + | * is retreived and parsed using regular expressions. | ||
| + | * | ||
| + | * @author: fr:user:aoineko | ||
| + | * @version: 0.2 | ||
| + | */ | ||
| + | function addQuickPreview() | ||
| + | { | ||
| + | var QuickPreviewBtnTitle = "Prévisualisation rapide de vos modifications [Alt + Q]"; | ||
| + | var QuickPreviewBtnValue = "Prévisualisation rapide"; | ||
| + | var QuickPrevHideBtnTitle = "Cacher la prévisualisation rapide [Alt + H]"; | ||
| + | var QuickPrevHideBtnValue = "Cacher"; | ||
| + | |||
| + | var div = document.getElementsByTagName('div'); | ||
| + | for(var i = 0; i < div.length ; i++) | ||
| + | { | ||
| + | if(div[i].className == "editButtons") // search "editButtons" div | ||
| + | { | ||
| + | div[i].appendChild(document.createElement("br")); // add a <br/> | ||
| + | |||
| + | var wpQuick = document.createElement("input"); // create and set the "QuickPrev" button | ||
| + | wpQuick.setAttribute("id", "wpQuick"); | ||
| + | wpQuick.setAttribute("name", "wpQuick"); | ||
| + | wpQuick.setAttribute("title", QuickPreviewBtnTitle); | ||
| + | wpQuick.setAttribute("value", QuickPreviewBtnValue); | ||
| + | wpQuick.setAttribute("type", "button"); | ||
| + | wpQuick.setAttribute("onclick", "doQuickPreview();"); | ||
| + | wpQuick.setAttribute("tabindex", "8"); | ||
| + | wpQuick.setAttribute("accesskey", "Q"); | ||
| + | div[i].appendChild(wpQuick); | ||
| + | |||
| + | var wpHide = document.createElement("input"); // create and set the "Hide" button | ||
| + | wpHide.setAttribute("id", "wpHide"); | ||
| + | wpHide.setAttribute("name", "wpHide"); | ||
| + | wpHide.setAttribute("title", QuickPrevHideBtnTitle); | ||
| + | wpHide.setAttribute("value", QuickPrevHideBtnValue); | ||
| + | wpHide.setAttribute("type", "button"); | ||
| + | wpHide.setAttribute("onclick", "hideQuickPreview();"); | ||
| + | wpHide.setAttribute("tabindex", "9"); | ||
| + | wpHide.setAttribute("accesskey", "H"); | ||
| + | div[i].appendChild(wpHide); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | /// Retreive current code and parse it | ||
| + | function doQuickPreview() | ||
| + | { | ||
| + | var wpQuickPreview = document.getElementById("wpQuickPreview"); | ||
| + | if(!wpQuickPreview) | ||
| + | { | ||
| + | /*var l = document.getElementsByTagName('div'); | ||
| + | for(var i = 0; i < l.length ; i++) | ||
| + | if(l[i].className == "previewnote") | ||
| + | wpQuickPreview = l; | ||
| + | |||
| + | if(!wpQuickPreview)*/ | ||
| + | { | ||
| + | wpQuickPreview = document.createElement("div"); | ||
| + | wpQuickPreview.setAttribute("style", "border:solid 1px gray; width:100%; margin-top:1em; margin-bottom:1em; padding:0.5em;"); | ||
| + | var wpSummaryLabel = document.getElementById("wpSummaryLabel"); | ||
| + | wpSummaryLabel.parentNode.insertBefore(wpQuickPreview, wpSummaryLabel); | ||
| + | } | ||
| + | wpQuickPreview.setAttribute("id", "wpQuickPreview"); | ||
| + | } | ||
| + | wpQuickPreview.style.display = "block"; | ||
| + | |||
| + | wpTextbox1 = document.getElementById("wpTextbox1"); | ||
| + | var str = "=Prévisualisation rapide=\n" + wpTextbox1.value; | ||
| + | var qp = new QuickPreview(str); | ||
| + | wpQuickPreview.innerHTML = qp.Parse(); | ||
| + | } | ||
| + | |||
| + | function QuickPreview(wiki) | ||
| + | { | ||
| + | this.line = wiki.split(/\n/); | ||
| + | this.html = new String; | ||
| + | |||
| + | this.list = 0; // current list depth | ||
| + | this.tab = 0; // current tabulation depth | ||
| + | this.pre = false; /// inside a <pre> tag | ||
| + | this.para = false; /// inside a paragraph | ||
| + | |||
| + | this.HandlePre = function(i) | ||
| + | { | ||
| + | if(this.line[i][0] == ' ') | ||
| + | { | ||
| + | if(this.para) | ||
| + | { | ||
| + | this.para = false; | ||
| + | this.html += "</p>\n"; | ||
| + | } | ||
| + | if(!this.pre) | ||
| + | { | ||
| + | this.pre = true; | ||
| + | this.html += "<pre>\n"; | ||
| + | } | ||
| + | this.html += this.line[i] + "\n"; | ||
| + | return true; | ||
| + | } | ||
| + | else if(this.pre) | ||
| + | { | ||
| + | this.pre = false; | ||
| + | this.html += "</pre>\n"; | ||
| + | } | ||
| + | return false; | ||
| + | }; | ||
| + | |||
| + | this.HandleH = function(i) | ||
| + | { | ||
| + | if(res = this.line[i].match(/^(={1,6})(.*)\1(.*)$/)) | ||
| + | { | ||
| + | this.line[i] = "<h" + res[1].length + ">" + res[2] + "</h" + res[1].length + ">" + res[3]; | ||
| + | return true; | ||
| + | } | ||
| + | return false; | ||
| + | }; | ||
| + | |||
| + | this.Parse = function() | ||
| + | { | ||
| + | this.html = ""; | ||
| + | |||
| + | for(var i = 0; i < this.line.length ; i++) | ||
| + | { | ||
| + | var p = true; | ||
| + | |||
| + | if(this.HandlePre(i)) | ||
| + | continue; | ||
| + | |||
| + | if(this.HandleH(i)) | ||
| + | p = false; | ||
| + | |||
| + | if(p && !this.para) | ||
| + | { | ||
| + | this.para = true; | ||
| + | this.html += "<p>"; | ||
| + | } | ||
| + | |||
| + | this.html += this.line[i] | ||
| + | |||
| + | // Sign // | ||
| + | .replace(/~{5}/g, Date()) | ||
| + | .replace(/~{4}/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px yellow;'>Signature</span> "+Date()) | ||
| + | .replace(/~{3}/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px yellow;'>Signature</span>") | ||
| + | |||
| + | // Style // | ||
| + | .replace(/'''''(.*?)''(.*?)'''/g, "<strong><em>$1</em>$2</strong>") | ||
| + | .replace(/'''''(.*?)'''(.*?)''/g, "<em><strong>$1</strong>$2</em>") | ||
| + | .replace(/'''(.*?)''(.*?)'''''/g, "<strong>$1<em>$2</em></strong>") | ||
| + | .replace(/'''''(.*?)''''/g, "<strong><em>\'$1</em></strong>") | ||
| + | .replace(/''''(.*?)''''/g, "<strong><em>$1</em></strong>") | ||
| + | .replace(/''''(.*?)'''/g, "<strong>\'$1</strong>") | ||
| + | .replace(/'''(.*?)'''/g, "<strong>$1</strong>") | ||
| + | .replace(/'''(.*?)''/g, "<em>\'$1</em>") | ||
| + | .replace(/''(.*?)''/g, "<em>$1</em>") | ||
| + | |||
| + | // List // | ||
| + | .replace(/^\*(.*)/g, "<li>$1</li>") | ||
| + | .replace(/^#(.*)/g, "<li>$1</li>") | ||
| + | .replace(/^:(.*)/g, "<li>$1</li>") | ||
| + | |||
| + | // Link // | ||
| + | .replace(/\{\{([^\|]*).*}}/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px lightgreen;'>Modèle : $1</span>") | ||
| + | .replace(/\[\[[Ii]mage:([^\|]*)[^\[]*\]\]/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px lightblue;'>Image : $1</span>") | ||
| + | .replace(/\[\[[Cc]atégorie:([^\|]*)[^\[]*\]\]/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px #FF8080;'><a href='/wiki/Catégorie:$1' title='$1'>Catégorie : $1</a></span>") | ||
| + | .replace(/\[\[([^\[.]*)\|([^\[.]*)\]\]/g, "<a href='/wiki/$1' title='$1'>$2</a>") | ||
| + | .replace(/\[\[([^\[.]*)\]\]/g, "<a href='/wiki/$1' title='$1'>$1</a>") | ||
| + | /* | ||
| + | // Special // | ||
| + | .replace(/\n\n/g, "\n\n<br/>") | ||
| + | .replace(/(^|\n)-{4}(?!~)/g, "<hr/>") | ||
| + | |||
| + | // Table // | ||
| + | .replace(/(^|\n)\{\|(.*)/g, "$1<table $2>") | ||
| + | .replace(/(^|\n)\|}/g, "$1</table>") | ||
| + | .replace(/(^|\n)(\|.*)\|\|/g, "$1$2</td><td>") | ||
| + | .replace(/(^|\n)\|[^-}](.*)/g, "$1</td>$2<td>") | ||
| + | .replace(/(^|\n)(!.*)!!/g, "$1$2</th><th>") | ||
| + | .replace(/(^|\n)/g, "$1</th>$2<th>") | ||
| + | */ | ||
| + | ; | ||
| + | this.html += "\n"; | ||
| + | } | ||
| + | |||
| + | return this.html; | ||
| + | }; | ||
| + | }; | ||
| + | |||
| + | /// Hide | ||
| + | function hideQuickPreview() | ||
| + | { | ||
| + | var wpQuickPreview = document.getElementById("wpQuickPreview"); | ||
| + | if(wpQuickPreview) | ||
| + | { | ||
| + | wpQuickPreview.style.display = 'none'; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | addLoadEvent(addQuickPreview); | ||
| + | |||
| + | //============================================================ | ||
| + | // | ||
| + | // Barre d'outil | ||
| + | // | ||
| + | //============================================================ | ||
| + | |||
| + | //============================================================ | ||
| + | // Générateur de tableaux | ||
| + | //============================================================ | ||
| + | |||
| + | /** | ||
| + | * | ||
| + | * English: Generate an array using Mediawiki syntax | ||
| + | * | ||
| + | * @author: fr:user:dake | ||
| + | * @version: 0.1 | ||
| + | */ | ||
| + | |||
| + | function generateTableau(nbCol, nbRow, border, styleHeader, styleLine) | ||
| + | { | ||
| + | var code = "\n"; | ||
| + | if (styleHeader==1) { | ||
| + | code += '{{entête tableau charte}}\n'; | ||
| + | } else { | ||
| + | code += '{| border="' + border + '"\n'; | ||
| + | code += '|+ Titre du tableau\n'; | ||
| + | } | ||
| + | |||
| + | for (var i=0;i<nbCol;i++) code += '! en-tête ' + i + '\n' | ||
| + | |||
| + | for (var j=0;j<nbRow;j++) { | ||
| + | if ((j+1)%2==0 && styleLine==1) { | ||
| + | code += '|-{{ligne grise}}\n' | ||
| + | } else { | ||
| + | code += '|-----\n' | ||
| + | } | ||
| + | |||
| + | for (var i=0;i<nbCol;i++) code += '| élément\n'; | ||
| + | } | ||
| + | |||
| + | code += '|}'; | ||
| + | insertTags('','', code); | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * | ||
| + | * English: Open a popup with parameters to generate an array. | ||
| + | * The number of rows/columns can be modified. Some additional | ||
| + | * parameters are related to templates available on :fr | ||
| + | * | ||
| + | * @author: fr:user:dake | ||
| + | * @version: 0.1 | ||
| + | */ | ||
| + | |||
| + | function popupTableau() | ||
| + | { | ||
| + | var popup = window.open('','name','height=400,width=500'); | ||
| + | |||
| + | javaCode = '<script type="text\/javascript">function insertCode(){'; | ||
| + | javaCode += 'var row = parseInt(document.paramForm.inputRow.value); ' | ||
| + | javaCode += 'var col = parseInt(document.paramForm.inputCol.value); ' | ||
| + | javaCode += 'var bord = parseInt(document.paramForm.inputBorder.value); ' | ||
| + | javaCode += 'var styleHeader = document.paramForm.inputHeader.checked; ' | ||
| + | javaCode += 'var styleLine = document.paramForm.inputLine.checked; ' | ||
| + | javaCode += 'window.opener.generateTableau(col,row,bord,styleHeader,styleLine); ' | ||
| + | javaCode += '}<\/script>'; | ||
| + | |||
| + | popup.document.write('<html><head><title>Paramètres du tableau</title>'); | ||
| + | popup.document.write('<script type="text\/javascript" src="\/skins-1.5\/common\/wikibits.js"><!-- wikibits js --><\/script>'); | ||
| + | popup.document.write('<style type="text\/css" media="screen,projection">/*<![CDATA[*/ @import "\/skins-1.5\/monobook\/main.css?5"; /*]]>*/<\/style>'); | ||
| + | popup.document.write(javaCode); | ||
| + | popup.document.write('</head><body>'); | ||
| + | popup.document.write('<p>Veuillez entrer les paramètres du tableau : </p>'); | ||
| + | popup.document.write('<form name="paramForm">'); | ||
| + | popup.document.write('Nombre de lignes : <input type="text" name="inputRow" value="3" ><p>'); | ||
| + | popup.document.write('Nombre de colonnes : <input type="text" name="inputCol" value="3" ><p>'); | ||
| + | popup.document.write('Largeur de la bordure : <input type="text" name="inputBorder" value="1" ><p>'); | ||
| + | popup.document.write('En-tête en gris (style « charte graphique ») : <input type="checkbox" name="inputHeader" checked="1" ><p>'); | ||
| + | popup.document.write('Lignes grises alternées (style « charte graphique ») : <input type="checkbox" name="inputLine" checked="1" ><p>'); | ||
| + | popup.document.write('</form">'); | ||
| + | popup.document.write('<p><a href="javascript:insertCode()"> Insérer le code dans la fenêtre d\'édition</a></p>'); | ||
| + | popup.document.write('<p><a href="javascript:self.close()"> Fermer</a></p>'); | ||
| + | popup.document.write('</body></html>'); | ||
| + | popup.document.close(); | ||
| + | } | ||
| + | |||
| + | //============================================================ | ||
| + | // Insertion de nouveaux boutons dans la barre d'outil | ||
| + | //============================================================ | ||
| + | |||
| + | /** | ||
| + | * Ajoute quelques boutons sur la barre d'outil | ||
| + | * Inspiré de mon code précédent et des icônes sur he: | ||
| + | * @author: fr:user:dake | ||
| + | * @version: 0.1 | ||
| + | */ | ||
| + | function ImprovedToolbar() | ||
| + | { | ||
| + | tooly = document.getElementById('toolbar'); | ||
| + | if (tooly == null) return; | ||
| + | |||
| + | StrikeTextButton = "<a href=\"javascript:insertTags('<s>','</s>','');\"><img src=\"http://upload.wikimedia.org/edia/fr/3/30/Btn_toolbar_rayer.png\" alt=\"Rayer\" title=\"Rayer\"></a>"; | ||
| + | EnumTextButton = "<a href=\"javascript:insertTags('\\n# élément 1\\n# élément 2\\n# élément 3','','');\"><img src=\"http://upload.wikimedia.org/edia/fr/8/88/Btn_toolbar_enum.png\" alt=\"Énumération\" title=\"Énumération\"></a>"; | ||
| + | ListTextButton = "<a href=\"javascript:insertTags('\\n* élément A\\n* élément B\\n* élément C','','');\"><img src=\"http://upload.wikimedia.org/edia/fr/1/11/Btn_toolbar_liste.png\" alt=\"Liste\" title=\"Liste\"></a>"; | ||
| + | GalleryButton = "<a href=\"javascript:insertTags('\\n<gallery>\\nImage:Vista-openbsd.png|Légende\\nImage:AMule.png|Légende\\nImage:Cyberduck icon.png|Légende\\n</gallery>','','');\"><img src=\"http://upload.wikimedia.org/edia/fr/9/9e/Btn_toolbar_gallery.png\" alt=\"Galerie d'images\" title=\"Galerie d'images\"></a>"; | ||
| + | CommentTextButton = "<a href=\"javascript:insertTags('<!--','-->','');\"><img src=\"http://upload.wikimedia.org/edia/fr/3/37/Btn_toolbar_commentaire.png\" alt=\"Commentaire\" title=\"Commentaire\"></a>"; | ||
| + | RedirectButton = "<a href=\"javascript:insertTags('#REDIRECT [[',']]','nom de la destination');\"><img src=\"http://upload.wikimedia.org/edia/en/c/c8/Button_redirect.png\" alt=\"Redirection\" title=\"Redirection\"></a>"; | ||
| + | ArrayButton = "<a href=\"javascript:popupTableau();\"><img src=\"http://upload.wikimedia.org/edia/fr/0/04/Button_array.png\" alt=\"Tableau\" title=\"Tableau\"></a>"; | ||
| + | |||
| + | tooly.innerHTML = tooly.innerHTML + StrikeTextButton + EnumTextButton + | ||
| + | ListTextButton + CommentTextButton + GalleryButton + RedirectButton + ArrayButton ; | ||
| + | } | ||
| + | |||
| + | addLoadEvent(ImprovedToolbar); | ||
| + | |||
| + | |||
| + | //============================================================ | ||
| + | // | ||
| + | // Divers | ||
| + | // | ||
| + | //============================================================ | ||
| + | |||
| + | /** | ||
| + | * Transformer les pages du Bistro en page de discussion | ||
| + | */ | ||
| + | function DiscussionBistro() | ||
| + | { | ||
| + | if(document.title.search("édia:Le Bistro") != -1) | ||
| + | document.body.className = "ns-1"; | ||
| + | } | ||
| + | |||
| + | addLoadEvent(DiscussionBistro); | ||
| + | |||
| + | /** | ||
| + | * Ajout d'un style particulier aux liens interlangues vers des articles de qualités | ||
| + | */ | ||
| + | function LienAdQ() | ||
| + | { | ||
| + | var lang = document.getElementById("p-lang"); // fin language link list | ||
| + | if(lang) | ||
| + | { | ||
| + | var span = document.getElementsByTagName("span"); | ||
| + | for(i=0; i<span.length; i++) // iterate over all <span>-elements | ||
| + | { | ||
| + | // if found a AdQ span | ||
| + | if(span[i].className == "AdQ") { | ||
| + | var li = lang.getElementsByTagName("li"); | ||
| + | for(j=0; j<li.length; j++) { | ||
| + | if(li[j].className == "interwiki-" + span[i].id) { // if found a AdQ link | ||
| + | li[j].style.padding = "0 0 0 16px"; | ||
| + | li[j].style.backgroundImage = "url('http://upload.wikimedia.org/edia/fr/3/36/Icone_etoile.png')"; | ||
| + | li[j].style.backgroundRepeat = "no-repeat"; | ||
| + | li[j].title = "Lien vers un article de qualité"; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | addLoadEvent(LienAdQ); | ||
| + | |||
| + | /* | ||
| + | * VraiTitre : Ajout du titre réel d'un article pour lequel MediaWiki n'affiche pas correctement | ||
| + | */ | ||
| + | |||
| + | function VraiTitre() | ||
| + | { | ||
| + | var balise = document.getElementById("vrai_titre"); | ||
| + | if (!balise) return; | ||
| + | vrai_titre = balise.childNodes[0].nodeValue; | ||
| + | var titre = document.getElementsByTagName("H1")[0]; | ||
| + | rectificatif = titre.appendChild(document.createElement("span")); | ||
| + | rectificatif.setAttribute ("style","color:#AAAAAA; font-size:0.7em; font-style:italic; display:inline;"); | ||
| + | rectificatif.appendChild(document.createTextNode(" ("+ vrai_titre +")")); | ||
| + | } | ||
| + | addLoadEvent(VraiTitre); | ||
| − | |||
| − | |||
| − | /* </pre> */ | + | /* </nowiki> </pre> */ |
Version du 6 avril 2006 à 16:09
/* <pre> */
/* From http://fr.wikipedia.org/wiki/MediaWiki:Monobook.js */
/* under a GNU Free Documentation License http://www.gnu.org/copyleft/fdl.html */
/* tooltips and access keys */
/* <pre> <nowiki> */
//============================================================
//
// Info-bulle et touches de raccourci
//
//============================================================
ta = new Object();
ta['pt-userpage'] = new Array('.', 'Ma page utilisateur');
ta['pt-anonuserpage'] = new Array('.', 'La page utilisateur pour l\'adresse IP que vous utilisez');
ta['pt-mytalk'] = new Array('N', 'Ma page de discussion');
ta['pt-anontalk'] = new Array('N', 'La page de discussion pour cette adresse');
ta['pt-preferences'] = new Array('', 'Mes préférences');
ta['pt-watchlist'] = new Array('L', 'La liste des pages que vous suivez');
ta['pt-mycontris'] = new Array('Y', 'La liste de mes contributions');
ta['ca-talk'] = new Array('T', 'Discussion pour cette page');
ta['ca-edit'] = new Array('E', 'Vous pouvez modifier cette page. Merci de prévisualiser avant d\'enregistrer.');
ta['ca-addsection'] = new Array('+', 'Ajouter un commentaire à cette discussion.');
ta['ca-viewsource'] = new Array('E', 'Cette page est protégée. Vous pouvez toutefois en voir le contenu.');
ta['ca-history'] = new Array('H', 'Les auteurs et versions précédentes de cette page.');
ta['ca-protect'] = new Array('=', 'Pour protéger cette page.');
ta['ca-delete'] = new Array('D', 'Pour supprimer cette page.');
ta['ca-undelete'] = new Array('D', 'Pour restaurer cette page.');
ta['ca-move'] = new Array('M', 'Pour déplacer ou renommer cette page.');
ta['ca-nomove'] = new Array('', 'Vous n\'avez pas la permission de déplacer cette page.');
ta['ca-watch'] = new Array('W', 'Ajoutez cette page à votre liste de suivi.');
ta['ca-unwatch'] = new Array('W', 'Retirez cette page de votre liste de suivi.');
ta['search'] = new Array('F', 'Pour effectuer une recherche.');
ta['p-logo'] = new Array('', 'Page principale.');
ta['n-mainpage'] = new Array('Z', 'Pour afficher la page principale.');
ta['n-portal'] = new Array('', 'À propos du projet.');
ta['n-currentevents'] = new Array('', 'Trouvez des informations sur les événements récents.');
ta['n-recentchanges'] = new Array('R', 'La liste des modifications récentes.');
ta['n-randompage'] = new Array('X', 'Afficher une page au hasard.');
ta['n-help'] = new Array('', 'Aide.');
ta['n-sitesupport'] = new Array('', 'Pour soutenir le projet.');
ta['t-whatlinkshere'] = new Array('J', 'Liste des pages liées à celle-ci.');
ta['t-recentchangeslinked'] = new Array('K', 'Liste des modifications récentes des pages liées à celle-ci.');
ta['feed-rss'] = new Array('', 'Alimenter le flux RSS pour cette page.');
ta['feed-atom'] = new Array('', 'Alimenter le flux Atom pour cette page.');
ta['t-contributions'] = new Array('', 'Voir la liste des contributions de cet utilisateur.');
ta['t-emailuser'] = new Array('', 'Envoyer un courriel à cet utilisateur.');
ta['t-upload'] = new Array('U', 'Importer une image ou fichier média sur le serveur.');
ta['t-specialpages'] = new Array('Q', 'Liste des pages spéciales.');
ta['ca-nstab-main'] = new Array('C', 'Afficher le contenu de cette page.');
ta['ca-nstab-user'] = new Array('C', 'Afficher la page utilisateur.');
ta['ca-nstab-media'] = new Array('C', 'Afficher la page média.');
ta['ca-nstab-special'] = new Array('', 'Ceci est une page spéciale, vous ne pouvez pas la modifier.');
ta['ca-nstab-wp'] = new Array('A', 'Afficher la page du projet.');
ta['ca-nstab-image'] = new Array('C', 'Afficher la page de description de l\'image.');
ta['ca-nstab-mediawiki'] = new Array('C', 'Afficher le message système.');
ta['ca-nstab-template'] = new Array('C', 'Afficher le modèle.');
ta['ca-nstab-help'] = new Array('C', 'Afficher la page d\'aide.');
ta['ca-nstab-category'] = new Array('C', 'Afficher la page de catégorie.');
//============================================================
//
// Fonctions de gestion
//
//============================================================
/**
* Installation d'une nouvelle fonction de cette façon:
* aOnloadFunctions[aOnloadFunctions.length] = nom_de_la_fonction; // (sans parenthèses)
*/
if (!window.aOnloadFunctions) {
var aOnloadFunctions = new Array();
}
window.onload = function()
{
if (window.aOnloadFunctions) {
for (var _i=0; _i<aOnloadFunctions.length; _i++) {
aOnloadFunctions[_i]();
}
}
}
/**
* Ajouter une nouvelle fonction a excuter au chargement de la page.
*/
function addLoadEvent(func)
{
if (window.addEventListener)
window.addEventListener("load", func, false);
else if (window.attachEvent)
window.attachEvent("onload", func);
}
//============================================================
//
// Boites deroulantes
//
//============================================================
// BEGIN Dynamic Navigation Bars (experimantal)
// set up the words in your language
var NavigationBarHide = '[ Enrouler ]';
var NavigationBarShow = '[ Dérouler ]';
// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 0;
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar)
{
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {
return false;
}
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (NavChild.className == 'NavPic') {
NavChild.style.display = 'none';
}
if (NavChild.className == 'NavContent') {
NavChild.style.display = 'none';
}
}
NavToggle.firstChild.data = NavigationBarShow;
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (NavChild.className == 'NavPic') {
NavChild.style.display = 'block';
}
if (NavChild.className == 'NavContent') {
NavChild.style.display = 'block';
}
}
NavToggle.firstChild.data = NavigationBarHide;
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
var indexNavigationBar = 0;
// iterate over all < div >-elements
for(
var i=0;
NavFrame = document.getElementsByTagName("div")[i];
i++
) {
// if found a navigation bar
if (NavFrame.className == "NavFrame") {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
for(
var j=0;
j < NavFrame.childNodes.length;
j++
) {
if (NavFrame.childNodes[j].className == "NavHead") {
NavFrame.childNodes[j].appendChild(NavToggle);
}
}
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
// if more Navigation Bars found than Default: hide all
if (NavigationBarShowDefault < indexNavigationBar) {
for(
var i=1;
i<=indexNavigationBar;
i++
) {
toggleNavigationBar(i);
}
}
}
addLoadEvent(createNavigationBarToggleButton);
// END Dynamic Navigation Bars
//============================================================
//
// Fonctions de remplissage automatique
//
//============================================================
function InitPaS(page_name)
{
var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->";
var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des Pages à supprimer -->";
var tpl = '{{subst:' + 'Initialiser PàS|' + page_name
+ '|~~~~|jour={{subst:CURRENTDAY}}|mois={{subst:CURRENTMONTH}}}}';
return c1 + '\n' + tpl + '\n' + c2;
}
function InitPaV(page_name)
{
var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->";
var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des Pages à vérifier -->";
var tpl = '{{subst:' + 'Initialiser PàV|' + page_name + '|~~~~}}';
return c1 + '\n' + tpl + '\n' + c2;
}
function InitLANN(page_name)
{
var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->";
var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des articles non neutres -->";
var tpl = '{{subst:' + 'Initialiser LANN|' + page_name + '|~~~~}}';
return c1 + '\n' + tpl + '\n' + c2;
}
function InitIaS(page_name)
{
var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->";
var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des Images à supprimer -->";
var tpl = '{{subst:' + 'Initialiser IàS|' + page_name + '|~~~~|jour={{subst:CURRENTDAY}}|mois={{subst:CURRENTMONTH}}}}';
return c1 + '\n' + tpl + '\n' + c2;
}
function InitPAdQ(page_name)
{
var c1 = "<!--\n À la création de la page, suivez les consignes ci-dessous pour proposer l'article.\n\n ATTENTION : Veuillez ne rien effacer !\n-->";
var tpl = '{{subst:' + 'Initialiser PAdQ|' + page_name + '|~~~~';
var c2 = "| 1. Indiquez sur la ligne ci-dessous la raison pour laquelle vous proposez cet article. Vous n'avez pas besoin de signer/dater, ni de voter par la suite : votre proposition tient lieu de vote 'Pour'. |";
var tpl2 = "Je propose cet article car... (votre motivation)";
var c3 = "| 2. Sauvegardez cette page et créez un lien vers elle dans Jurispedia:Proposition articles de qualité.";
var c4 = "Pour cela, choisissez une thématique dans la page, modifiez-la et ajoutez un lien sous la forme :";
var c5 = "** [[/" + page_name + "]] proposé le ~~~~~ ";
var c6 = "Vous devez créer cette référence dans la section 'Phase I' de la thématique choisie (suivez les autres exemples).";
return c1 + '\n\n' + tpl + '\n' + c2 + '\n' + tpl2 + '\n\n' + c3 + '\n\n' + c4 + '\n' + c5 + '\n' + c6 + '}}\n';
}
function InitIaA(page_name)
{
var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->";
return c1 + '\n{{subst:Amélioration image}}'
}
function InitPCP(page_name)
{
var c1 = "<!-- Sauvegarder la page pour l'initialiser puis suivre les instructions -->";
var c2 = "<!-- N'oubliez pas d'ajouter le lien vers cette page dans la page principale des articles soupçonnées de violation de copyright -->";
var tpl = '{{subst:' + 'Initialiser PCP|' + page_name + '|~~~~}}';
return c1 + '\n' + tpl + '\n' + c2;
}
function InitArbReq(page_name)
{
var c1 = "<" + "!-- Remplissez les champs (???) puis sauvegardez --" + ">\n";
var c2 = "[[Catégorie:Arbitrage en cours]]\n{" + "{Page d'arbitrage}}\n\nArbitre coordinateur :\n\n";
var c3 = "Arbitre(s) ne participant pas à cet arbitrage :\n\n";
var c4 = "== Description du conflit ==\n\n'''Demande déposée par''' : [[Utilisateur:X|X]] le ??? à ???\n\n";
var c5 = "''Parties concernées par le conflit'' : ??? et [[Utilisateur:???|]] (et [[Utilisateur:???|]]).\n\n";
var c6 = "''Nature du conflit'' : ???\n\n";
var c7 = "''Recevabilité'' :\n\n''Décision'' :\n\n";
var c8 = "== Arguments de ??? ==\n{" + "{CAr limite des arguments}}\n\n";
var c9 = c8;
var c10 = "== Recevabilité ==\n\n== Mesures conservatoires ==\n<" + "!-- Mesures telles que protection de page, interdiction d'édition ou blocage, décidée par le coordinateur, avec justification. Les autres arbitres y réagissent ici. --" + ">\n\n== Discussion sur le fond ==\n\n=== Commentaires des arbitres ===\n\n";
var c11 = "=== Propositions ===\n\n==== Proposition 1 ====\n\n<u>Proposition :</u>\n\n<u>Vote :</u>";
return c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10 + c11;
}
var init_if_empty = new Array(
new Array('Jurispedia:Pages_%C3%A0_supprimer/', InitPaS),
new Array('Jurispedia:Pages_%C3%A0_v%C3%A9rifier/', InitPaV),
new Array('Jurispedia:Liste_des_articles_non_neutres/', InitLANN),
new Array('Jurispedia:Images_%C3%A0_supprimer/', InitIaS),
new Array('Jurispedia:Proposition_articles_de_qualit%C3%A9/', InitPAdQ),
new Array('Jurispedia:Pages_soup%C3%A7onn%C3%A9es_de_violation_de_copyright/', InitPCP),
new Array('Jurispedia:Comit%C3%A9_d%27arbitrage/Arbitrage/', InitArbReq)
);
/**
* Remplit la zone d'édition si elle est vide avec le texte retourné par
* un pointeur de fonction sélectionné par le nom de la page.
*/
function InitPage()
{
// TODO, il faut tester l'existence de l'edit box et la longueur
// du texte en dehors de la boucle
ugly_url = 'http://fr.jurispedia.org/index.php?title=';
for (var i = 0; i < init_if_empty.length; ++i) {
var page_name = document.URL;
var page_match = init_if_empty[i][0];
var index = page_name.indexOf(ugly_url + page_match);
if (index != -1) {
var text_area = document.editform.wpTextbox1;
if (text_area.value.length == 0) {
page_name = page_name.slice((ugly_url + page_match).length);
page_name = page_name.split('&')[0];
page_name = decodeURI(page_name);
page_name = page_name.replace(/_/g, ' ')
text_area.value = init_if_empty[i][1](page_name);
break;
}
}
}
}
addLoadEvent(InitPage);
//============================================================
//
// Caractères spéciaux
//
//============================================================
/**
* Ajoutez le menu pour choisir des sous-ensembles de caractères spéciaux
* @note L'ordre de cette liste doit correspondre a celui de MediaWiki:Edittools !
*/
function addCharSubsetMenu() {
var specialchars = document.getElementById('specialchars');
if (specialchars) {
var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">";
menu += "<option>Wiki</option>";
menu += "<option>Mathématiques</option>";
menu += "<option>API</option>";
menu += "<option>Latin/Romain</option>";
menu += "<option>Grec</option>";
menu += "<option>Cyrillique</option>";
menu += "<option>AHD</option>";
menu += "<option>Allemand</option>";
menu += "<option>Arabe</option>";
menu += "<option>Catalan</option>";
menu += "<option>Croate</option>";
menu += "<option>Espagnol</option>";
menu += "<option>Espéranto</option>";
menu += "<option>Estonien</option>";
menu += "<option>Gallois</option>";
menu += "<option>Hawaien</option>";
menu += "<option>Hébreu</option>";
menu += "<option>Hiéroglyphe</option>";
menu += "<option>Hollandais</option>";
menu += "<option>Hongrois</option>";
menu += "<option>Indo-européen</option>";
menu += "<option>Irlandais</option>";
menu += "<option>Islandais</option>";
menu += "<option>Italien</option>";
menu += "<option>Letton</option>";
menu += "<option>Lituanien</option>";
menu += "<option>Maltais</option>";
menu += "<option>Navajo & Apache</option>";
menu += "<option>Pinyin</option>";
menu += "<option>Polonais</option>";
menu += "<option>Portugais</option>";
menu += "<option>Rōmaji</option>";
menu += "<option>Roumain</option>";
menu += "<option>Scandinave</option>";
menu += "<option>Serbe</option>";
menu += "<option>Tchèque</option>";
menu += "<option>Turc</option>";
menu += "<option>Vieil anglais</option>";
menu += "<option>Vietnamien</option>";
menu += "<option>Yiddish</option>";
menu += "</select>";
specialchars.innerHTML = menu + specialchars.innerHTML;
/* default subset - try to use a cookie some day */
chooseCharSubset(0);
}
}
/* select subsection of special characters */
function chooseCharSubset(s) {
var l = document.getElementById('specialchars').getElementsByTagName('p');
for (var i = 0; i < l.length ; i++) {
l[i].style.display = i == s ? 'inline' : 'none';
l[i].style.visibility = i == s ? 'visible' : 'hidden';
}
}
addLoadEvent(addCharSubsetMenu);
//============================================================
//
// Choix de l'affichage des références
//
//============================================================
/**
* Choix du mode d'affichage des références.
* @note L'ordre de cette liste doit correspondre a celui de Modèle:Édition !
*/
function addBibSubsetMenu()
{
var specialBib = document.getElementById('specialBib');
if (specialBib)
{
specialBib.style.display = 'block';
var menu = "<select style=\"display:inline;\" onChange=\"chooseBibSubset(selectedIndex)\">";
menu += "<option>Liste</option>";
menu += "<option>WikiNorme</option>";
menu += "<option>BibTeX</option>";
menu += "<option>ISBD</option>";
menu += "<option>ISO690</option>";
menu += "</select>";
specialBib.innerHTML = specialBib.innerHTML + menu;
}
/* default subset - try to use a cookie some day */
chooseBibSubset(0);
}
/* select subsection of special characters */
function chooseBibSubset(s)
{
var l = document.getElementsByTagName('div');
for (var i = 0; i < l.length ; i++)
{
if(l[i].className == 'BibList') l[i].style.display = s == 0 ? 'block' : 'none';
else if(l[i].className == 'WikiNorme') l[i].style.display = s == 1 ? 'block' : 'none';
else if(l[i].className == 'BibTeX') l[i].style.display = s == 2 ? 'block' : 'none';
else if(l[i].className == 'ISBD') l[i].style.display = s == 3 ? 'block' : 'none';
else if(l[i].className == 'ISO690') l[i].style.display = s == 4 ? 'block' : 'none';
}
}
addLoadEvent(addBibSubsetMenu);
//============================================================
//
// Prévisualisation rapide
//
//============================================================
/**
* Script de ajoutant une option de prévisualisation rapide.
*
*
* English: Add a Quick View option on the Edit pages.
* This script add 2 new buttons into the "editButtons" div.
* When QuickPrev button is press, the content of edit window
* is retreived and parsed using regular expressions.
*
* @author: fr:user:aoineko
* @version: 0.2
*/
function addQuickPreview()
{
var QuickPreviewBtnTitle = "Prévisualisation rapide de vos modifications [Alt + Q]";
var QuickPreviewBtnValue = "Prévisualisation rapide";
var QuickPrevHideBtnTitle = "Cacher la prévisualisation rapide [Alt + H]";
var QuickPrevHideBtnValue = "Cacher";
var div = document.getElementsByTagName('div');
for(var i = 0; i < div.length ; i++)
{
if(div[i].className == "editButtons") // search "editButtons" div
{
div[i].appendChild(document.createElement("br")); // add a <br/>
var wpQuick = document.createElement("input"); // create and set the "QuickPrev" button
wpQuick.setAttribute("id", "wpQuick");
wpQuick.setAttribute("name", "wpQuick");
wpQuick.setAttribute("title", QuickPreviewBtnTitle);
wpQuick.setAttribute("value", QuickPreviewBtnValue);
wpQuick.setAttribute("type", "button");
wpQuick.setAttribute("onclick", "doQuickPreview();");
wpQuick.setAttribute("tabindex", "8");
wpQuick.setAttribute("accesskey", "Q");
div[i].appendChild(wpQuick);
var wpHide = document.createElement("input"); // create and set the "Hide" button
wpHide.setAttribute("id", "wpHide");
wpHide.setAttribute("name", "wpHide");
wpHide.setAttribute("title", QuickPrevHideBtnTitle);
wpHide.setAttribute("value", QuickPrevHideBtnValue);
wpHide.setAttribute("type", "button");
wpHide.setAttribute("onclick", "hideQuickPreview();");
wpHide.setAttribute("tabindex", "9");
wpHide.setAttribute("accesskey", "H");
div[i].appendChild(wpHide);
}
}
}
/// Retreive current code and parse it
function doQuickPreview()
{
var wpQuickPreview = document.getElementById("wpQuickPreview");
if(!wpQuickPreview)
{
/*var l = document.getElementsByTagName('div');
for(var i = 0; i < l.length ; i++)
if(l[i].className == "previewnote")
wpQuickPreview = l;
if(!wpQuickPreview)*/
{
wpQuickPreview = document.createElement("div");
wpQuickPreview.setAttribute("style", "border:solid 1px gray; width:100%; margin-top:1em; margin-bottom:1em; padding:0.5em;");
var wpSummaryLabel = document.getElementById("wpSummaryLabel");
wpSummaryLabel.parentNode.insertBefore(wpQuickPreview, wpSummaryLabel);
}
wpQuickPreview.setAttribute("id", "wpQuickPreview");
}
wpQuickPreview.style.display = "block";
wpTextbox1 = document.getElementById("wpTextbox1");
var str = "=Prévisualisation rapide=\n" + wpTextbox1.value;
var qp = new QuickPreview(str);
wpQuickPreview.innerHTML = qp.Parse();
}
function QuickPreview(wiki)
{
this.line = wiki.split(/\n/);
this.html = new String;
this.list = 0; // current list depth
this.tab = 0; // current tabulation depth
this.pre = false; /// inside a <pre> tag
this.para = false; /// inside a paragraph
this.HandlePre = function(i)
{
if(this.line[i][0] == ' ')
{
if(this.para)
{
this.para = false;
this.html += "</p>\n";
}
if(!this.pre)
{
this.pre = true;
this.html += "<pre>\n";
}
this.html += this.line[i] + "\n";
return true;
}
else if(this.pre)
{
this.pre = false;
this.html += "</pre>\n";
}
return false;
};
this.HandleH = function(i)
{
if(res = this.line[i].match(/^(={1,6})(.*)\1(.*)$/))
{
this.line[i] = "<h" + res[1].length + ">" + res[2] + "</h" + res[1].length + ">" + res[3];
return true;
}
return false;
};
this.Parse = function()
{
this.html = "";
for(var i = 0; i < this.line.length ; i++)
{
var p = true;
if(this.HandlePre(i))
continue;
if(this.HandleH(i))
p = false;
if(p && !this.para)
{
this.para = true;
this.html += "<p>";
}
this.html += this.line[i]
// Sign //
.replace(/~{5}/g, Date())
.replace(/~{4}/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px yellow;'>Signature</span> "+Date())
.replace(/~{3}/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px yellow;'>Signature</span>")
// Style //
.replace(/'''''(.*?)''(.*?)'''/g, "<strong><em>$1</em>$2</strong>")
.replace(/'''''(.*?)'''(.*?)''/g, "<em><strong>$1</strong>$2</em>")
.replace(/'''(.*?)''(.*?)'''''/g, "<strong>$1<em>$2</em></strong>")
.replace(/'''''(.*?)''''/g, "<strong><em>\'$1</em></strong>")
.replace(/''''(.*?)''''/g, "<strong><em>$1</em></strong>")
.replace(/''''(.*?)'''/g, "<strong>\'$1</strong>")
.replace(/'''(.*?)'''/g, "<strong>$1</strong>")
.replace(/'''(.*?)''/g, "<em>\'$1</em>")
.replace(/''(.*?)''/g, "<em>$1</em>")
// List //
.replace(/^\*(.*)/g, "<li>$1</li>")
.replace(/^#(.*)/g, "<li>$1</li>")
.replace(/^:(.*)/g, "<li>$1</li>")
// Link //
.replace(/\{\{([^\|]*).*}}/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px lightgreen;'>Modèle : $1</span>")
.replace(/\[\[[Ii]mage:([^\|]*)[^\[]*\]\]/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px lightblue;'>Image : $1</span>")
.replace(/\[\[[Cc]atégorie:([^\|]*)[^\[]*\]\]/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px #FF8080;'><a href='/wiki/Catégorie:$1' title='$1'>Catégorie : $1</a></span>")
.replace(/\[\[([^\[.]*)\|([^\[.]*)\]\]/g, "<a href='/wiki/$1' title='$1'>$2</a>")
.replace(/\[\[([^\[.]*)\]\]/g, "<a href='/wiki/$1' title='$1'>$1</a>")
/*
// Special //
.replace(/\n\n/g, "\n\n<br/>")
.replace(/(^|\n)-{4}(?!~)/g, "<hr/>")
// Table //
.replace(/(^|\n)\{\|(.*)/g, "$1<table $2>")
.replace(/(^|\n)\|}/g, "$1</table>")
.replace(/(^|\n)(\|.*)\|\|/g, "$1$2</td><td>")
.replace(/(^|\n)\|[^-}](.*)/g, "$1</td>$2<td>")
.replace(/(^|\n)(!.*)!!/g, "$1$2</th><th>")
.replace(/(^|\n)/g, "$1</th>$2<th>")
*/
;
this.html += "\n";
}
return this.html;
};
};
/// Hide
function hideQuickPreview()
{
var wpQuickPreview = document.getElementById("wpQuickPreview");
if(wpQuickPreview)
{
wpQuickPreview.style.display = 'none';
}
}
addLoadEvent(addQuickPreview);
//============================================================
//
// Barre d'outil
//
//============================================================
//============================================================
// Générateur de tableaux
//============================================================
/**
*
* English: Generate an array using Mediawiki syntax
*
* @author: fr:user:dake
* @version: 0.1
*/
function generateTableau(nbCol, nbRow, border, styleHeader, styleLine)
{
var code = "\n";
if (styleHeader==1) {
code += '{{entête tableau charte}}\n';
} else {
code += '{| border="' + border + '"\n';
code += '|+ Titre du tableau\n';
}
for (var i=0;i<nbCol;i++) code += '! en-tête ' + i + '\n'
for (var j=0;j<nbRow;j++) {
if ((j+1)%2==0 && styleLine==1) {
code += '|-{{ligne grise}}\n'
} else {
code += '|-----\n'
}
for (var i=0;i<nbCol;i++) code += '| élément\n';
}
code += '|}';
insertTags('','', code);
}
/**
*
* English: Open a popup with parameters to generate an array.
* The number of rows/columns can be modified. Some additional
* parameters are related to templates available on :fr
*
* @author: fr:user:dake
* @version: 0.1
*/
function popupTableau()
{
var popup = window.open('','name','height=400,width=500');
javaCode = '<script type="text\/javascript">function insertCode(){';
javaCode += 'var row = parseInt(document.paramForm.inputRow.value); '
javaCode += 'var col = parseInt(document.paramForm.inputCol.value); '
javaCode += 'var bord = parseInt(document.paramForm.inputBorder.value); '
javaCode += 'var styleHeader = document.paramForm.inputHeader.checked; '
javaCode += 'var styleLine = document.paramForm.inputLine.checked; '
javaCode += 'window.opener.generateTableau(col,row,bord,styleHeader,styleLine); '
javaCode += '}<\/script>';
popup.document.write('<html><head><title>Paramètres du tableau</title>');
popup.document.write('<script type="text\/javascript" src="\/skins-1.5\/common\/wikibits.js"><!-- wikibits js --><\/script>');
popup.document.write('<style type="text\/css" media="screen,projection">/*<![CDATA[*/ @import "\/skins-1.5\/monobook\/main.css?5"; /*]]>*/<\/style>');
popup.document.write(javaCode);
popup.document.write('</head><body>');
popup.document.write('<p>Veuillez entrer les paramètres du tableau : </p>');
popup.document.write('<form name="paramForm">');
popup.document.write('Nombre de lignes : <input type="text" name="inputRow" value="3" ><p>');
popup.document.write('Nombre de colonnes : <input type="text" name="inputCol" value="3" ><p>');
popup.document.write('Largeur de la bordure : <input type="text" name="inputBorder" value="1" ><p>');
popup.document.write('En-tête en gris (style « charte graphique ») : <input type="checkbox" name="inputHeader" checked="1" ><p>');
popup.document.write('Lignes grises alternées (style « charte graphique ») : <input type="checkbox" name="inputLine" checked="1" ><p>');
popup.document.write('</form">');
popup.document.write('<p><a href="javascript:insertCode()"> Insérer le code dans la fenêtre d\'édition</a></p>');
popup.document.write('<p><a href="javascript:self.close()"> Fermer</a></p>');
popup.document.write('</body></html>');
popup.document.close();
}
//============================================================
// Insertion de nouveaux boutons dans la barre d'outil
//============================================================
/**
* Ajoute quelques boutons sur la barre d'outil
* Inspiré de mon code précédent et des icônes sur he:
* @author: fr:user:dake
* @version: 0.1
*/
function ImprovedToolbar()
{
tooly = document.getElementById('toolbar');
if (tooly == null) return;
StrikeTextButton = "<a href=\"javascript:insertTags('<s>','</s>','');\"><img src=\"http://upload.wikimedia.org/edia/fr/3/30/Btn_toolbar_rayer.png\" alt=\"Rayer\" title=\"Rayer\"></a>";
EnumTextButton = "<a href=\"javascript:insertTags('\\n# élément 1\\n# élément 2\\n# élément 3','','');\"><img src=\"http://upload.wikimedia.org/edia/fr/8/88/Btn_toolbar_enum.png\" alt=\"Énumération\" title=\"Énumération\"></a>";
ListTextButton = "<a href=\"javascript:insertTags('\\n* élément A\\n* élément B\\n* élément C','','');\"><img src=\"http://upload.wikimedia.org/edia/fr/1/11/Btn_toolbar_liste.png\" alt=\"Liste\" title=\"Liste\"></a>";
GalleryButton = "<a href=\"javascript:insertTags('\\n<gallery>\\nImage:Vista-openbsd.png|Légende\\nImage:AMule.png|Légende\\nImage:Cyberduck icon.png|Légende\\n</gallery>','','');\"><img src=\"http://upload.wikimedia.org/edia/fr/9/9e/Btn_toolbar_gallery.png\" alt=\"Galerie d'images\" title=\"Galerie d'images\"></a>";
CommentTextButton = "<a href=\"javascript:insertTags('<!--','-->','');\"><img src=\"http://upload.wikimedia.org/edia/fr/3/37/Btn_toolbar_commentaire.png\" alt=\"Commentaire\" title=\"Commentaire\"></a>";
RedirectButton = "<a href=\"javascript:insertTags('#REDIRECT [[',']]','nom de la destination');\"><img src=\"http://upload.wikimedia.org/edia/en/c/c8/Button_redirect.png\" alt=\"Redirection\" title=\"Redirection\"></a>";
ArrayButton = "<a href=\"javascript:popupTableau();\"><img src=\"http://upload.wikimedia.org/edia/fr/0/04/Button_array.png\" alt=\"Tableau\" title=\"Tableau\"></a>";
tooly.innerHTML = tooly.innerHTML + StrikeTextButton + EnumTextButton +
ListTextButton + CommentTextButton + GalleryButton + RedirectButton + ArrayButton ;
}
addLoadEvent(ImprovedToolbar);
//============================================================
//
// Divers
//
//============================================================
/**
* Transformer les pages du Bistro en page de discussion
*/
function DiscussionBistro()
{
if(document.title.search("édia:Le Bistro") != -1)
document.body.className = "ns-1";
}
addLoadEvent(DiscussionBistro);
/**
* Ajout d'un style particulier aux liens interlangues vers des articles de qualités
*/
function LienAdQ()
{
var lang = document.getElementById("p-lang"); // fin language link list
if(lang)
{
var span = document.getElementsByTagName("span");
for(i=0; i<span.length; i++) // iterate over all <span>-elements
{
// if found a AdQ span
if(span[i].className == "AdQ") {
var li = lang.getElementsByTagName("li");
for(j=0; j<li.length; j++) {
if(li[j].className == "interwiki-" + span[i].id) { // if found a AdQ link
li[j].style.padding = "0 0 0 16px";
li[j].style.backgroundImage = "url('http://upload.wikimedia.org/edia/fr/3/36/Icone_etoile.png')";
li[j].style.backgroundRepeat = "no-repeat";
li[j].title = "Lien vers un article de qualité";
}
}
}
}
}
}
addLoadEvent(LienAdQ);
/*
* VraiTitre : Ajout du titre réel d'un article pour lequel MediaWiki n'affiche pas correctement
*/
function VraiTitre()
{
var balise = document.getElementById("vrai_titre");
if (!balise) return;
vrai_titre = balise.childNodes[0].nodeValue;
var titre = document.getElementsByTagName("H1")[0];
rectificatif = titre.appendChild(document.createElement("span"));
rectificatif.setAttribute ("style","color:#AAAAAA; font-size:0.7em; font-style:italic; display:inline;");
rectificatif.appendChild(document.createTextNode(" ("+ vrai_titre +")"));
}
addLoadEvent(VraiTitre);
/* </nowiki> </pre> */