Utilisateur:DavidL/monobook.js
Un article de Wikipédia, l'encyclopédie libre.
Note : Après avoir publié la page, vous devrez forcer son rechargement pour voir les changements : Mozilla / Konqueror / Firefox : Shift-Ctrl-R, Internet Explorer / Opera : Ctrl-F5, Safari : Cmd-R.
//<source lang="javascript" line> var debug_log=""; var debug_opened = 0; var debug_div; function closeDebug() { if (debug_div) debug_div.style.display="none"; return false; } function openDebug() { debug_opened = 1; if (debug_log=="") return; var node=document.createElement("div"); node.setAttribute("id","debuglog"); node.setAttribute("style"," position: absolute; overflow: auto; background:#ccccff; padding:10px; z-index: 10; left:10%; top:10%; width:80%; height: 80%; "); lines = debug_log.split("\n"); var hh = document.createElement( "h1" ); hh.appendChild( document.createTextNode( "Journal de debuggage" ) ); node.appendChild( hh ); for(var i=0;i<lines.length;i++) if (lines[i]!="") { if (i>0) node.appendChild( document.createElement( "br" ) ); var tt = document.createElement( "tt" ); tt.appendChild( document.createTextNode( lines[i] ) ); node.appendChild( tt ); } node.setAttribute("title","Cliquer pour fermer"); node.setAttribute("onclick","return closeDebug();"); if (document.all) { node.onclick=function(){return closeDebug();} } var tc=document.getElementById("bodyContent"); tc.appendChild(node); debug_log = ""; debug_div = node; } function debuglog(s) { debug_log+=s+"\n"; if (debug_opened){ if (debug_div){ debug_div.appendChild( document.createElement( "br" ) ); var tt = document.createElement( "tt" ); tt.appendChild( document.createTextNode( s ) ); debug_div.appendChild( tt ); } else openDebug(); } } addOnloadHook(openDebug); devdebug=function(s){debuglog(s);} // ----------------------------- /** * Indicateur de page de discussion ou considérée comme telle */ var wgIsTalkPage = (((wgNamespaceNumber>0)&&(wgNamespaceNumber&1)) // Page de discussion ||((wgNamespaceNumber==4)&&(inBook("Le Bistro/")))); // ou bistro var on_talk_page=wgIsTalkPage; /** * Indicateur de page en cours d'édition */ var wgIsEditingPage = (wgAction == "edit") || (wgAction == "submit"); /***********************************************/ /* Paramétrage des extensions (auteur: DavidL) */ /***********************************************/ var jsscript_setup=[]; function addSetup(jsscript, func) { // devdebug("SETUP "+jsscript+": + "+func.name); if (! jsscript_setup[jsscript]) jsscript_setup[jsscript]=[]; jsscript_setup[jsscript].push(func); } function doSetup(jsscript) { var setup=jsscript_setup[jsscript]; // devdebug("SETUP "+jsscript+": "+setup.length+" functions"); if (setup) for(var i=0;i<setup.length;i++) setup[i](); } /***********************************************/ /* Fonctions utilitaires wiki (auteur: DavidL) */ /***********************************************/ function removeOnloadHook(func) { for(var i in onloadFuncts) if (onloadFuncts[i]==func) { onloadFuncts.splice(i + 1, 1); return; } }; // Teste si la page fait partie d'un livre donné // Ne pas oublier d'ajouter le séparateur utilisé à la fin de title // (en général / , : ou (espace)) function inBook(title) { if (wgTitle==title.substring(0,title.length-1)) return true; return wgTitle.substr(0,title.length)==title; } /** * Insérer un javascript d'une page particulière */ function wb_loadJs(page) { document.write('<script type="text/javascript" src="' + 'http://fr.wikibooks.org/w/index.php?title=' + page + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); } function wb_obtenir(nom) { wb_loadJs('MediaWiki:JSScripts/' + nom); } /** * Insérer une feuille de style d'une page particulière, idée de DavidL */ function wb_loadCss(page) { document.write('<style type="text/css">\n' + '@import url(http://fr.wikibooks.org/w/index.php?title=' + page + '&action=raw&ctype=text/css&dontcountme=s);\n</style>'); } function wb_obtenirCss(nom) { wb_loadCss('MediaWiki:CSS/' + nom); } /***********************************************/ /**********************************************/ /* Fonctions utiles diverses (auteur: DavidL) */ /**********************************************/ var placeFirstFunc=0; function addFirstOnloadHook(hookFunct) { // Allows add-on scripts to add onload functions onloadFuncts[onloadFuncts.length] = onloadFuncts[placeFirstFunc]; onloadFuncts[placeFirstFunc++] = hookFunct; } /**********************************************/ /*******************************************************/ /* Fonctions de traitement de chaînes (auteur: DavidL) */ /*******************************************************/ // (Aa : A==a) function equalsAa(str1, str2) {return str1.toUpperCase()==str2.toUpperCase();} function startsWithAa(string, prefix) {return equalsAa(string.substring(0,prefix.length),prefix);} function substractPrefixAa(string, prefix) {return startsWithAa(string, prefix)?string.substring(prefix.length):string;} /*******************************************************/ /*******************************************************/ function setupTitle(){} /*******************************************************/ wb_obtenir("Titres"); wb_obtenir("Tableau"); wb_obtenir("TableUnicode"); wb_obtenir("Categories"); categorySeparator='•'; wb_obtenir("DeluxeEdit"); wb_obtenir("DeluxeImport"); wb_obtenir("DeluxeSearch"); wb_obtenir("Sidebox"); wb_obtenir("Smileys"); smileys_create_toolbar=1; wb_obtenir("Toolbar");wb_obtenirCss("Toolbar"); wb_obtenir("OngletPurge"); wb_obtenir("OngletEditCount"); wb_obtenir('RestaurationDeluxe'); /* Version modifiée acceptant une modification de sommaire. */ function mwInsertEditButton(parent, item) { var image = document.createElement("img"); image.width = 23; image.height = 22; image.src = item.imageFile; image.border = 0; image.style.cursor = "pointer"; var ref = document.createElement("a"); var href="javascript:insertTags(\"" + item.tagOpen + "\",\"" + item.tagClose + "\",\"" + item.sampleText + "\");"; if (item.summary != null) href+="javascript:changeSummary(\"" + item.summary + "\");"; ref.setAttribute("href", href); ref.setAttribute("title", item.speedTip); ref.appendChild(image); parent.appendChild(ref); } /***************************************************************************/ /* Barre d'outils : */ /* - parenthèses */ /* - <tt>...</tt> */ /***************************************************************************/ // Wikipedia Commons url_wpcm='http://upload.wikimedia.org/wikipedia/commons/'; url_wpfr='http://upload.wikimedia.org/wikipedia/fr/'; url_wbfr='http://upload.wikimedia.org/wikibooks/fr/'; function addCustomButtonWpCm(img,desc,topen,tclose,text) {addCustomButton(url_wpcm+img,desc,topen,tclose,text);} // Boutons ajoutés : addCustomButtonWpCm('a/a4/Btn_toolbar_par.png','Parenthèses',"(",")",''); addCustomButtonWpCm('5/5f/Btn_toolbar_tt.png','TT',"<tt>","</tt>",''); addCustomButtonWpCm('e/e9/Button_headline2.png','Sous-titre niveau 3',"\n=== "," ===",'Sous-titre'); addCustomButtonWpCm('1/13/Button_enter.png','Retour à la ligne','<br />','',''); addCustomButtonWpCm('6/6a/Button_sup_letter.png','Superscript','<sup>','<\/sup>','text'); addCustomButtonWpCm('a/aa/Button_sub_letter.png','Subscript','<sub>','<\/sub>','text'); addCustomButtonWpCm('5/58/Button_small.png','Small','<small>','<\/small>','Small Text'); addCustomButtonWpCm('5/56/Button_big.png','Big','<big>','<\/big>','Big text'); addCustomButtonWpCm('b/b4/Button_category03.png','Category',"[[Category:","]]",'name'); addCustomButtonWpCm('7/79/Button_reflink.png','Insert a reference','<ref name="refname">','<\/ref>','Insert reference material'); addCustomButtonWpCm('7/79/Button_reflink.png','Insert a reference link','<ref name="','"/>','refname'); addCustomButtonWpCm('9/9a/Button_references.png','Reference footer',"\n== Notes et références ==\n<div class=\'references-small\'>\n<references/>\n</div>",'',''); addCustomButtonWpCm('c/ce/Button_no_include.png','No Include',"<noinclude>","<\/noinclude>",'Text'); addCustomButtonWpCm('7/79/Button_include.png','Include only',"<includeonly>","<\/includeonly>",'Text'); var urlp=document.location+"/"; var userpage=urlp.substring(0,48)=="http://fr.wikibooks.org/wiki/Utilisateur:DavidL/"; function addToSummary(str) { document.editform.wpSummary.value+=" "+str; } function DeluxeSummary() { var sumLbl = document.getElementById("wpSummaryLabel"); if (sumLbl) { //élargissement boite de résumé var sumInput = document.getElementById("wpSummary"); sumInput.style.width = "90%"; var summaries = [ /* title, input, */ "+ ébauche", "+ bandeau ébauche", "+ cat", "+ catégorie", "+ image", "+ image", "+ interwiki", "+ liens interwiki", "corr interwiki", "correction liens interwiki", "+ portail", "+ portail", "- image", "- image manquante", "- lien int", "- lien interne", "- lien ext", "- lien externe", "corr lien int", "correction lien interne", "corr lien ext", "correction lien externe", "lien ext -> lien int", "conversion lien externe en lien interne", "lien int -> interwiki", "conversion lien interne en lien interwiki", "MeP", "mise en page", "fusion", "fusion", "redir", "Redirect", "ortho/gram", "correction orthographe/grammaire", "retouches", "diverses retouches", "ajInfo", "ajout infos", "rangmt", "rangement interwikis/catégories", "recat", "changement catégorie", "PàS conservé", "article listé sur PàS - retrait du bandeau (conservé)", "création", "Initialisation de la page", "Vote", "A voté", "Motivation", "Ma motivation", "Réponse", "Réponse", "Defcon ", "Mise au defcon ", "à tr. Wkt ", "Article à transférer sur le Wiktionnaire", "trans. Wkt ", "Redirect sur le Wiktionnaire", "à tr. s: ", "Article à transférer sur le Wikisource", "trans. s: ", "Redirect sur le Wikisource", "blanchi", "Blanchi : ", "vandale", "Blanchi : vandalisme", "copyvio", "Blanchi : copyvio", "spam", "Blanchi : spam", "bac à sable", "Blanchi : bac à sable", "autopromo", "Blanchi : auto-promotion", "régul", "- non régularisé", "délais", "- délais non respectés", "sup copyvio", "- suppression passage en copyvio du site : ", "rv-motif", "revert de la dernière contribution. Indiquez les motifs des modifications dans boîte de résumé ou en indiquer le renvoi en page de discussion" ]; var str = ""; for (var cpt=0; cpt<summaries.length; cpt+=2) str += "<a href=\"javascript:addToSummary('" + summaries[cpt+1] + "')\"" + " class=\"sumLink\" title=\"Ajouter '" + summaries[cpt+1] +"' dans la boîte de résumé\">" + summaries[cpt] + " ·</a> "; sumLbl.innerHTML = str + "<br />" + sumLbl.innerHTML; } } addOnloadHook(DeluxeSummary); function DeluxeBar() { //devdebug("DeluxeBar..."); try{ if ( typeof ( wgAction ) == "undefined" ) return; if ( !wgIsEditingPage ) return; // le texte a été splitté sinon Mediawiki casse tout... if (wgNamespaceNumber == 3) // Page discussion utilisateur { var tb=createToolbar("msgusers","Messages utilisateurs"); tb.addModel(url_wpfr+"e/eb/Button_accueilB.png", "{{subst:" + "Bienvenue" + "}}" + "--" + "~~" + "~~", "Bienvenue !"); tb.addModel(url_wpcm+"a/a9/Button_tournesol.png", "{{subst:" + "Merci IP" + "}}" + "--" + "~~" + "~~", "Merci pour ta contribution"); tb.addModel(url_wpcm+"3/39/Button_IP.png", "{{subst:"+ "bienvenue IP" + "}}" + "--" + "~~" + "~~", "Bienvenue !"); tb.addModel(url_wpcm+"7/74/Button_oeil.png", "{{subst:" + "motivation modif" +"|page=" + "}}" + "--" + "~~" + "~~", "Modification de page sans motif"); tb.addModel(url_wpcm+"2/28/Button_info.png", "{{"+ "subst:bienvenue débutant" + "}}" + "--" + "~~" + "~~", "Bienvenue débutant !"); tb.addModel(url_wpfr+"0/00/Button_vandale.png", "{{subst:" + "Bienvenue vandale" + "}}" + "--" + "~~" + "~~", "Avertissement vandalisme"); tb.addModel(url_wpfr+"a/ad/Button_vandale2.png", "{{subst:" + "Vandalisme| " + "}}" + "--" + "~~" + "~~", "Avertissement vandalisme" + " de niveau 1 "); tb.addModel(url_wpfr+"a/ad/Button_vandale2.png", "{{subst:" + "test 1" + "}}" + "--" + "~~" + "~~", "Avertissement vandalisme" + " de niveau 1 "); tb.addModel(url_wpcm+"1/1c/Button_flamme.png", "{{subst:" + "test 2" + "}}" + "--" + "~~" + "~~", "Avertissement vandalisme" + " de niveau 2 "); tb.addModel(url_wpcm+"3/3b/Button_crocs.png", "{{subst:" + "test 3" + "}}" + "--" + "~~" + "~~", "Avertissement vandalisme" + " de niveau 3 "); tb.addModel(url_wpfr+"f/fb/Button_spam2.png", "{{subst:" + "Bienvenue spammeur" + "}}" + "--" + "~~" + "~~", "Avertissement spam "); tb.addModel(url_wpcm+"3/3b/Button_crocs.png", "{{subst:" + "Vandale bloqué" + "}}" + "--" + "~~" + "~~", "Vandale bloqué"); } tb=createToolbar("traitement","Traitement des pages"); tb.addModel(url_wpfr+"d/d9/Button_trait%C3%A9.png", "{{subst:" + "Utilisateur:Dake/Traité||--" + "~~" + "~~" + "}}", "Traité"); tb.addModel(url_wpfr+"a/ae/Button_trait%C3%A9conserver.png", "{{subst:" + "Utilisateur:Dake/TraitéConserver||--" + "~~" + "~~" + "}}", "Traité : article conservé"); tb.addModel(url_wpfr+"9/96/Button_trait%C3%A9supprimer.png", "{{subst:" + "Utilisateur:Dake/TraitéSupprimer||--" + "~~" + "~~" + "}}", "Traité : article supprimé"); tb.addModel(url_wpcm+"2/22/Button_radio_activite.png", "{{" + "suppression à revoir" + "}}", "Article sensiblement modifié"); tb.addModel(url_wpfr+"e/e5/Button_copyvio.png", "{{" + "copie de site|URL|Titre" + "}}", "Violation de copyright"); tb.addModel(url_wpfr+"e/e5/Button_copyvio.png", "{{" + "avis blanchi copyvio|1= |2= |3= |4= " + "}}"+ "--" + "~~" + "~~" , "Violation de copyright"); tb.addModel(url_wpfr+"e/e5/Button_copyvio.png", "{{" + "Bienvenue copyvio"+"| " + "}}" + "--" + "~~" + "~~", "Violation de copyright"); tb.addModel(url_wpfr+"f/f8/Button_suppr.png", "{{" + "suppression" + "}}", "Proposé à la suppression"); tb.addModel(url_wpfr+"c/cf/Button_PAdQ_rejet.png", "{{subst:" + "Utilisateur:Meanos/Modèles/PAdQ rejetée|premier/second tour|0|0|0|-|~~" + "~~}}", "Notification de rejet de la proposition"); tb.addModel(url_wpfr+"2/29/Button_PAdQ_validation.png", "{{subst:" + "Utilisateur:Meanos/Modèles/PAdQ validée|premier/second tour|0|0|0|-|~~" + "~~}}", "Notification de validation de la proposition"); tb.addModel(url_wpfr+"6/67/Button_%C3%A9clair.png", "{{subst:" + "Utilisateur:Dake/Toolbox/LicenceInconnue|test.jpg}}", "Image - licence inconnue ou imprécise"); if (on_talk_page) { tb=createToolbar("msg","Messages discussion"); tb.addModel(url_wpcm+"b/ba/Button_conserver.png", "{"+"{Joyeux anniversaire|{"+"{subst:Anniversaire Utilisateur {"+"{subst:CURRENTDAY}"+"} {"+"{subst:CURRENTMONTHNAME}"+"}"+"}"+"}"+"}"+"}", "Joyeux anniversaire !"); } tb=createToolbar("vote","Votes"); tb.addModel(url_wpcm+"f/fc/Button_supp.png", "#{{supprimer" + "}} " + "--" + "~~" + "~~", "/*Supprimer*/A voté !"); tb.addModel(url_wpcm+"b/ba/Button_conserver.png", "#{{conserver" + "}} " + "--" + "~~" + "~~", "/*Conserver*/A voté !"); tb.addModel(url_wpcm+"4/4e/Button_neutre.png", "#{{neutre" + "}} " + "--" + "~~" + "~~", "/*neutre*/Vote réservé !"); tb.addModel(url_wpcm+"7/70/Button_fusion.png", "#{{VoteFusionner" + "}} " + "--" + "~~" + "~~", "/*neutre*/Vote fusionner !"); tb.addModel(url_wpcm+"5/5f/Button_rediriger.png", "#{{Rediriger" + "}} " + "--" + "~~" + "~~", "/*neutre*/Vote rediriger !"); tb.addModel(url_wpcm+"d/d0/Button_transwiki.png", "#{{VoteTranswiki" + "}} " + "--" + "~~" + "~~", "/*neutre*/Vote transwiki !"); tb.addModel(url_wpcm+"b/ba/Button_conserver.png", "#{{pour" + "}} " + "--" + "~~" + "~~", "/*Pour*/A voté !"); tb.addModel(url_wpcm+"f/fc/Button_supp.png", "#{{contre" + "}} " + "--" + "~~" + "~~", "/*Contre*/A voté !"); tb=createToolbar("info","Information pages"); tb.addModel(url_wpcm+"b/bd/Button_recherche_ip.png", "{{" + "recherche IP" + "}}", "Bandeau recherche IP"); tb.addModel(url_wpcm+"7/7a/Button_ip_partag%C3%A9e.png", "{{" + "IP partagée" + "| " + "}}", "Bandeau IP partagée"); tb.addModel(url_wpcm+"9/9d/Button_fait.png", ":"+ "{{" + "fait" + "}}" + " --" + "~~" + "~~", "traité "); tb.addModel(url_wpcm+"3/33/Button_exclamation.png", "{{" + "Article sans source" + "| " + "}}", "Apposition bandeau article sans source "); tb.addModel(url_wpcm+"6/6d/Button_exclamation_1.png", "{{" + "sourcer" + "| " + "}}" + "--" + "~~" + "~~", "Avis d'article non sourcé "); tb.addModel(url_wpcm+"6/6a/Button_exclamation_2.png", "{{" + "sources" + "}}", "Apposition bandeau sources "); tb=createToolbar("wiki","Autres wiki"); tb.addModel(url_wpcm+"e/eb/Button_wikisource.png", "{{" + "Pour Wikisource" + "}}", "Apposition bandeau pour wikisource "); tb.addModel(url_wpcm+"e/eb/Button_wikisource.png", "{{" + "Wikisource" + "}}", "Lien sur wikisource "); tb.addModel(url_wpcm+"e/eb/Button_wikisource.png", "{{" + "Redirect Wikisource" + "}}", "Redirect vers wikisource "); tb.addModel(url_wpcm+"1/1f/Button_wiktionnaire.png", "{{" + "Pour Wiktionnaire" + "}}", "Apposition du bandeau pour Wiktionnaire "); tb.addModel(url_wpcm+"1/1f/Button_wiktionnaire.png", "{{" + "Wiktionnaire" + "}}", "Lien vers Wiktionnaire "); tb.addModel(url_wpcm+"1/1f/Button_wiktionnaire.png", "{{" + "Redirect Wiktionnaire" + "}}", "Redirect vers Wiktionnaire "); tb.addModel(url_wpcm+"6/61/Button_wikibooks.png", "{{" + "Pour Wikilivres" + "}}", "Apposition du bandeau pour Wikilivres "); tb.addModel(url_wpcm+"6/61/Button_wikibooks.png", "{{" + "Wikilivres" + "}}", "Lien vers Wikilivres "); tb.addModel(url_wpcm+"6/61/Button_wikibooks.png", "{{" + "Redirect Wikilivres" + "}}", "Redirect vers Wikilivres "); tb.addModel(url_wpcm+"f/f8/Button_Tool_commons.png", "{{" + "Désormais sur Commons" + "}}", "Image transférée sur Commons"); tb.addModel(url_wpcm+"d/d0/Button_transwiki.png", "{{" + "Vers Interwiki| | " + "}}", "Historique transféré sur le projet cible"); // openToolbars(); // nécessaire si onloadhook }catch(e){ devdebug("DeluxeBar error: "+e); } } addSetup("Toolbar", DeluxeBar); function changeSummary(sampleText) {document.editform.wpSummary.value = sampleText;} function loaddg(){ var c=document.getElementsByTagName("p");for(var f in c){ var n=c[f];if (!n.attributes) continue; var a=n.attributes.getNamedItem("class"); if(a&&(a.nodeValue=="domgen")){var d=n.childNodes[0];if(d.nodeType==3){ var m=n.removeChild(d).nodeValue.split(".");var s=m[0]; if(s.length>0) n.appendChild(document.createTextNode(s)); var p=n;var e=null;for(var i=1;i<m.length;i++){s=m[i]; if(s.length==0) p.appendChild(document.createTextNode(".")); else{while((i+1<m.length)&&(m[i+1].length==0)){s+=".";i++; if(i+1<m.length) s+=m[++i];}switch(s.charAt(0)){ case '(':if(e!=null){p.appendChild(e);p=e;}e=document.createElement(s.substring(1));break; case ')':if (e==null) p=p.parentNode;else {p.appendChild(e);e=null;} if(s.length>1) p.appendChild(document.createTextNode(s.substring(1)));break; case ':':if(e==null) p.appendChild(document.createTextNode("."+s));else{ p.appendChild(e);p=e;e=null;if(s.length>1) p.appendChild(document.createTextNode(s.substring(1)));}break; default:if(e==null) p.appendChild(document.createTextNode(s));else{var v=m[++i]; while((i+1<m.length)&&(m[i+1].length==0)){v+=".";i++;if(i+1<m.length) v+=m[++i];} e.setAttribute(s,unescape(v));}break;}}}}}}} if (userpage) addOnloadHook(loaddg); /********************************************************/ function setupSummary() { if (document.editform && document.editform.wpSummary && (document.editform.wpSummary.value=="")) document.editform.wpSummary.value="Création"; } /* Liens utiles */ function LinkSubpages(ns,title) {return "/w/index.php?title=Special%3APrefixindex&from="+escape(title)+"&namespace="+ns;} function ThisLinkSubpages() {return LinkSubpages(wgNamespaceNumber,wgTitle);} /* ------ */ function pageLinkBox() { var lb=createLinkbox("pagelinks","Spécial","pgl"); lb.addLink("subpages", "Sous-pages", "Liste des sous-pages", ThisLinkSubpages()); lb.addWikiLink("special", "Pages spéciales", "Les pages spéciales", "Special:Specialpages"); lb.addWikiLink("importmedia", "Importer image ou son", "Importer un fichier sur ce projet", "Special:Upload"); lb.addWikiLink("import", "Importer pages", "Importer des pages d'autres projets", "Special:Import"); lb.addWikiLink("modeltest", "Test de modèles", "Tester l'expansion d'un modèle", "Special:ExpandTemplates"); } addSetup("Sidebox", pageLinkBox); addOnloadHook(function (){ // ***************************** // Après chargement de la page : // ***************************** setupSummary(); // ***************************** }); /* {{Vers Interwiki|1=bc}} */ //</source>