|
|
(4 versions intermédiaires par le même utilisateur non affichées) |
Ligne 1 : |
Ligne 1 : |
− | /****
| + | addOnloadHook(function() {addSpecialCharset("Japonais", "Ā ā Ē ē Ī ī Ō ō Ū ū "); } ); |
− | *Mode édition
| |
− | *****/
| |
− |
| |
− | if(wgAction=='edit' || wgAction=='submit') {
| |
− |
| |
− |
| |
− | /*
| |
− | *Boutons Qualité
| |
− | *Auteur: ThomasV
| |
− | */
| |
− |
| |
− |
| |
− | function addQuality(form,value){
| |
− |
| |
− | var text="";
| |
− | switch(value){
| |
− | case "25%": text = "Texte incomplet"; break;
| |
− | case "50%": text = "Texte non formaté"; break;
| |
− | case "75%": text = "Complet et formaté"; break;
| |
− | case "100%": text = "Relu et corrigé"; break;
| |
− | case "Textes validés": text = "Validé"; break;
| |
− | case "mode_page|": text = "Texte en mode page"; break;
| |
− | }
| |
− |
| |
− | form.elements["wpSummary"].value="/* "+text+" */";
| |
− | s = form.elements["wpTextbox1"].value;
| |
− | s = s.replace(/\{\{TextQuality\|(.*?)\}\}/gi,"")
| |
− | form.elements["wpTextbox1"].value="{"+"{TextQuality|"+value+"}"+"}"+s;
| |
− | }
| |
− |
| |
− |
| |
− | function addQualityButtons(){
| |
− | if( wgNamespaceNumber != 0 ) return;
| |
− | var ig = document.getElementById("wpWatchthis");
| |
− | if(!ig) return;
| |
− |
| |
− | var f = document.createElement("span");
| |
− | f.innerHTML =
| |
− | ' <input type="radio" name="quality" value="25%" onclick="addQuality(this.form,this.value)"><img src = "'+q25+'">'
| |
− | +'<input type="radio" name="quality" value="50%" onclick="addQuality(this.form,this.value)"><img src = "'+q50+'">'
| |
− | +'<input type="radio" name="quality" value="75%" onclick="addQuality(this.form,this.value)"><img src = "'+q75+'">'
| |
− | +'<input type="radio" name="quality" value="100%" onclick="addQuality(this.form,this.value)"><img src = "'+q100+'">'
| |
− | +'<input type="radio" name="quality" value="Textes validés" onclick="addQuality(this.form,this.value)"><img src = "'+qvalid+'">'
| |
− | //+'<input type="radio" name="quality" value="mode_page|" onclick="addQuality(this.form,this.value)"><img src = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/92/Open_book_nae_02.svg/20px-Open_book_nae_02.svg.png">'
| |
− | +' Niveau d\’avancement du texte';
| |
− | ig.parentNode.insertBefore(f,ig.nextSibling.nextSibling.nextSibling)
| |
− | }
| |
− |
| |
− | addOnloadHook(addQualityButtons);
| |
− |
| |
− |
| |
− |
| |
− |
| |
− | /***
| |
− | *Expressions régulières
| |
− | *Auteur: ThomasV, Pathoschild
| |
− | *Note : cet outil utilise la syntaxe javascript : on utilise $ (et pas \) pour appeler un groupe dans la chaîne de remplacement.
| |
− | *Tutoriel : http://www.regular-expressions.info/tutorial.html
| |
− | ****/
| |
− |
| |
− | /* create form */
| |
− | function custom() {
| |
− |
| |
− | /* if already open */
| |
− | if(document.getElementById('regexform')) customremove()
| |
− | else {
| |
− | var editbox = document.getElementById('wpTextbox1');
| |
− | /* container */
| |
− | var regexform = document.createElement('div');
| |
− | regexform.setAttribute('id','regexform');
| |
− | editbox.parentNode.insertBefore(regexform,editbox.parentNode.firstChild);
| |
− |
| |
− | /* form tag */
| |
− | var formform = document.createElement('form');
| |
− | formform.setAttribute('id','regexformform');
| |
− | formform.setAttribute('onSubmit','customgo(); return false;');
| |
− | regexform.appendChild(formform);
| |
− |
| |
− | // add input boxes
| |
− | var newinput = document.createElement('input');
| |
− | newinput.setAttribute('id','formsearch');
| |
− | var newlabel = document.createElement('label');
| |
− | newlabel.setAttribute('for','formsearch');
| |
− | newlabel.appendChild(document.createTextNode("Remplacer "));
| |
− |
| |
− | formform.appendChild(newlabel);
| |
− | formform.appendChild(newinput);
| |
− |
| |
− | var newinput = document.createElement('input');
| |
− | newinput.setAttribute('id','formreplace');
| |
− | var newlabel = document.createElement('label');
| |
− | newlabel.setAttribute('for','formreplace');
| |
− | newlabel.appendChild(document.createTextNode(' par '));
| |
− |
| |
− | formform.appendChild(newlabel);
| |
− | formform.appendChild(newinput);
| |
− |
| |
− | // go! link
| |
− | var go_button = document.createElement('input');
| |
− | go_button.setAttribute('type',"submit");
| |
− | go_button.setAttribute('title',"go!");
| |
− | go_button.setAttribute('value',"go!");
| |
− | formform.appendChild(go_button);
| |
− |
| |
− | }
| |
− | }
| |
− |
| |
− |
| |
− |
| |
− | /* run patterns */
| |
− | function customgo() {
| |
− | /* get search and replace strings */
| |
− |
| |
− | search = document.getElementById('formsearch').value;
| |
− | search = search.replace(/\\n/g, '\n');
| |
− |
| |
− | replace = document.getElementById('formreplace').value;
| |
− | replace = replace.replace(/\\n/g, '\n');
| |
− |
| |
− | /* convert input to regex */
| |
− |
| |
− | // without delimiters
| |
− | if(!search.match(/^\s*\/[\s\S]*\/[a-z]*\s*$/i)) {
| |
− | search = new RegExp(search,'g');
| |
− | }
| |
− | // with delimiters
| |
− | else {
| |
− | // break into parts
| |
− | var regpattern = search.replace(/^\s*\/([\s\S]*)\/[a-z]*\s*$/i,'$1');
| |
− | var regmodifiers = search.replace(/^\s*\/[\s\S]*\/([a-z]*)\s*$/,'$1');
| |
− | // filter invalid flags
| |
− | regmodifiers = regmodifiers.replace(/[^gim]/ig,'');
| |
− |
| |
− | search = new RegExp(regpattern, regmodifiers);
| |
− | }
| |
− |
| |
− | /* perform */
| |
− | var editbox = document.getElementById('wpTextbox1');
| |
− | editbox.value = editbox.value.replace(search,replace);
| |
− |
| |
− | }
| |
− |
| |
− | /* remove form */
| |
− | function customremove() {
| |
− | var regexform = document.getElementById('regexform');
| |
− | regexform.parentNode.removeChild(regexform);
| |
− | patterncount = -1;
| |
− | }
| |
− |
| |
− | function add_regexp_button(){
| |
− |
| |
− | var toolbar = document.getElementById("toolbar");
| |
− | if(toolbar){
| |
− | var image = document.createElement("img");
| |
− | image.width = 23;
| |
− | image.height = 22;
| |
− | image.border = 0;
| |
− | image.className = "mw-toolbar-editbutton";
| |
− | image.style.cursor = "pointer";
| |
− | image.alt = "regexp";
| |
− | image.title = "Expression régulière";
| |
− | image.src = "http://upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png";
| |
− | image.onclick = custom;
| |
− | toolbar.appendChild(image);
| |
− | }
| |
− | }
| |
− |
| |
− | addOnloadHook(add_regexp_button)
| |
− |
| |
− |
| |
− | /*******************
| |
− | *** lst button
| |
− | ********************/
| |
− | function insert_lst(){
| |
− | tb = document.getElementById("wpTextbox1")
| |
− | if(tb) {
| |
− | if(tb.value.search("section begin")==-1){
| |
− | startPos = tb.selectionStart;
| |
− | endPos = tb.selectionEnd;
| |
− | h = tb.value.substring(0, startPos);
| |
− | m = tb.value.substring(startPos,endPos);
| |
− | f = tb.value.substring(endPos);
| |
− | tb.value="<section begin=s1 />"+h+"<section end=s1 />"+m+"<section begin=s2 />"+f+"<section end=s2 />"
| |
− | }}
| |
− | }
| |
− | function add_lst_button(){
| |
− | var toolbar = document.getElementById("toolbar");
| |
− | if(toolbar && wgNamespaceNumber==104){
| |
− | var image = document.createElement("img");
| |
− | image.width = 23;
| |
− | image.height = 22;
| |
− | image.border = 0;
| |
− | image.className = "mw-toolbar-editbutton";
| |
− | image.style.cursor = "pointer";
| |
− | image.alt = "sections";
| |
− | image.title = "Sections";
| |
− | image.src = "http://fr.wikisource.org/skins-1.5/common/images/button_hr.png";
| |
− | image.onclick = insert_lst;
| |
− | toolbar.appendChild(image);
| |
− | }
| |
− | }
| |
− | addOnloadHook(add_lst_button)
| |
− |
| |
− |
| |
− | /*
| |
− | ===Edittools===
| |
− | */
| |
− |
| |
− | /* add menu for selecting subsets of special characters */
| |
− | /***** must match MediaWiki:Edittools *****/
| |
− | function addCharSubsetMenu() {
| |
− | var specialchars = document.getElementById('specialchars');
| |
− |
| |
− | if (specialchars) {
| |
− | var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">";
| |
− | menu += "<option>Document</option>";
| |
− | menu += "<option>Poésie</option>";
| |
− | menu += "<option>Théâtre</option>";
| |
− | menu += "<option>Auteur</option>";
| |
− | menu += "<option>Latin étendu</option>";
| |
− | menu += "<option>Grec</option>";
| |
− | menu += "<option>Hébreu</option>";
| |
− | menu += "<option>Cyrillique</option>";
| |
− | menu += "<option>InterWiki</option>";
| |
− | menu += "<option>Maintenance</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';
| |
− | }
| |
− | }
| |
− |
| |
− | addOnloadHook(addCharSubsetMenu); | |
− |
| |
− | /****************************************/
| |
− | 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")
| |
− | ref.setAttribute("href", "javascript:insertTags(\"" + item.tagOpen + "\",\"" + item.tagClose + "\",\"" + item.sampleText + "\");")
| |
− | ref.setAttribute("title", item.speedTip);
| |
− | ref.appendChild(image);
| |
− |
| |
− | parent.appendChild(ref);
| |
− | }
| |
− |
| |
− | /*</pre>
| |
− |
| |
− | ===Générateur de tableaux===
| |
− | <pre>*/
| |
− |
| |
− | /**
| |
− | *
| |
− | * 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();
| |
− | }
| |
− |
| |
− |
| |
− | /*</pre>
| |
− | ===Insertion de nouveaux boutons dans la barre d'outil===
| |
− | <pre>*/
| |
− |
| |
− |
| |
− | //============================================================
| |
− | // Insertion de nouveaux boutons dans la barre d'outils
| |
− | //============================================================
| |
− |
| |
− | //Remplit la variable mwCustomEditButtons (voir /skins-1.5/commons/wikibits.js) pour ajouter des boutons à la barre d'outils
| |
− | function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText)
| |
− | {
| |
− | mwCustomEditButtons[mwCustomEditButtons.length] =
| |
− | {"imageFile": imageFile,
| |
− | "speedTip": speedTip,
| |
− | "tagOpen": tagOpen,
| |
− | "tagClose": tagClose,
| |
− | "sampleText": sampleText};
| |
− | }
| |
− |
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/8/8f/Button_poeme.png','Poésie','<poem>\\n\\n','\\n</poem>','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png','Commentaire','<!--','-->','Insérer votre commentaire');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/c/c8/Button_redirect.png','Redirection','#REDIRECT \[\[','\]\]','nom de la destination');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png','Catégorie','\[\[Catégorie:','\]\]','nom de la catégorie');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png','Textecentré','<center>','</center>','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/en/e/e9/Button_headline2.png','paragraphe niveau 3','===','===','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/en/8/8e/Button_shifting.png', 'Insérer un retrait',':','',':' );
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png','Texte plus petit','<small>','</small>','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/5/56/Button_big.png','Texte plus grand','<big>','</big>','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png','Exposant','<sup>','</sup>','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/4/4b/Button_nbsp.png','Espace insécable',' \;','','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png','Aller à la ligne','<br />','','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/4/4b/Button_class_text.png', 'Paragraphe texte','<div class=\"text\">\\n\\n','\\n</div>','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/7/78/Button_titre.png','Titre de page','\{\{Titre\|','\|\|\}\}','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/0/03/Button_chapitre.png','Titre de Chapitre','\{\{chapitre\|1=','\|2=\|3=\|type=\|nrchapitre=\|TitreChapitre=\|commentaires=\}\}','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/0/07/Button_justice.png','Titre de texte légal','\{\{Légal\\n\|1=','\\n\|2=\\n|3=\\n\}\}','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/c/c4/Button_ref.png','Ajouter une note ou référence','<ref>','</ref>','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/6/64/Buttonrefvs8.png','Liste des références','<references />','','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/c/c3/Button_travaux.png','Infoédit','\{\{Infoédit\\n\|1=','\\n\|2=\\n\|3=\\n\|4=\\n\|5=\\n\|6=\\n\}\}','');
| |
− | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/4/4c/Button_interprojet.png','Interprojet','\{\{Interprojet\\n\|nolink\\n\|etiq=','\\n\|w=\\n\|n=\\n\|wikt=\\n\|b=\\n\|q=\\n\|v=\\n\|wikispecies=\\n\|commons=\\n\|m=\\n\}\}','');
| |
− | //Ressemble à la fonction de /skins-1.5/commons/wikibits.js pour insérer un autre lien que insertTags
| |
− | function marque_tab()
| |
− | {
| |
− | var toolbar = document.getElementById('toolbar');
| |
− | if (!toolbar) return false;
| |
− |
| |
− | var textbox = document.getElementById('wpTextbox1');
| |
− | if (!textbox) return false;
| |
− |
| |
− | if (!document.selection && textbox.selectionStart == null)
| |
− | return false;
| |
− |
| |
− | var image = document.createElement("img");
| |
− | image.width = 23;
| |
− | image.height = 22;
| |
− | image.src = 'http://upload.wikimedia.org/wikipedia/commons/0/04/Button_array.png';
| |
− | image.border = 0;
| |
− | image.alt = 'Tableau';
| |
− | image.title = 'Tableau';
| |
− | image.style.cursor = "pointer";
| |
− | image.onclick = function() {
| |
− | popupTableau();
| |
− | return false;
| |
− | }
| |
− | toolbar.appendChild(image);
| |
− | }
| |
− |
| |
− | addOnloadHook(marque_tab);
| |
− |
| |
− |
| |
− | } /* endif edition*/
| |