User:Grondin/common.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/*<pre>*/
 
/**
 * 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 à 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);
}


/*</pre>
== Edition sommaire ==

<pre>*/

///////////////////////ajouts/////////////////////////


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 titles = new Array()
                titles.push("ébauche")
                titles.push("dev")
                titles.push("pub")
                titles.push("fini")
                titles.push("Une")
                titles.push("jour")
                titles.push("cat")
                titles.push("image")
                titles.push("wikif")
                titles.push("interwiki")
                titles.push("interprojet")
                titles.push("int")
                titles.push("ext")
                titles.push("corr interwiki")
                titles.push("corr int")
                titles.push("corr ext")
                titles.push("corr prjt")
                titles.push("ext -> int")
                titles.push("int -> interwiki")
                titles.push("ext -> interwiki")
                titles.push("MeP")
                titles.push("redir")
                titles.push("ortho/gram")
                titles.push("retouches")
                titles.push("ajInfo")
		titles.push("sources")
                titles.push("recat")
                titles.push("création")
                titles.push("Avis")
                titles.push("Motivation")
                titles.push("Réponse")
                titles.push("sup copyvio")
                titles.push("date")
                titles.push("blocage")


                var inputs = new Array()
                inputs.push("bandeau ébauche")
                inputs.push("Mise en Développement")
                inputs.push("Publication de la page")
                inputs.push("Article terminé. Veuillez en créer un nouveau pour coller le mieux aux actualités")
                inputs.push("Nouvelle Une")
                inputs.push("Nouvelle journée")
                inputs.push(" - catégorie")
                inputs.push(" - image")
                inputs.push("Wikification ")
                inputs.push(" - liens interwiki")
                inputs.push(" - liens interprojets")
                inputs.push(" - lien interne")
                inputs.push(" - lien externe")
                inputs.push("correction lien interwiki")
                inputs.push("correction lien interne")
                inputs.push("correction lien externe")
                inputs.push("correction lien interprojet")
                inputs.push("conversion lien externe en lien interne")
                inputs.push("conversion lien interne en lien interwiki")
                inputs.push("conversion lien externe en lien interwiki")
                inputs.push("mise en page")
                inputs.push("Redirect")
                inputs.push("correction orthographe/grammaire")
                inputs.push("diverses retouches")
                inputs.push("ajout infos")
		inputs.push("ajout sources")
                inputs.push("changement catégorie")
                inputs.push("Initialisation de la page")
                inputs.push("Avis rendu !")
                inputs.push("Motivation ")
                inputs.push("Réponse ")
                inputs.push(" - suppression passage en copyvio du site : ")
                inputs.push(" - "+ TodayDate())
                inputs.push("Avis de blocage")

                var str = ""
                for (var cpt = 0; cpt < titles.length; cpt ++)
                {
                        str += "<a href=\"javascript:addToSummary('" + inputs[cpt] + "')\""
                                + " class=\"sumLink\" title=\"Ajouter '" + inputs[cpt] +"' dans la boîte de résumé\">"
                                + titles[cpt]
                                + " ·</a> "
                }
                sumLbl.innerHTML = str + "<br />" + sumLbl.innerHTML
        }
}

addLoadEvent(DeluxeSummary)


/*</pre>

==BARRE EDITION BOUTON==

<pre>*/

function DeluxeBar() {
  if (document.createTextNode) {
        var toolbar = document.getElementById("toolbar"); 
        if (!toolbar) return;
        

        var messages = new Array()
        var images = new Array()
        var commentaires = new Array()
        var a=-1;

//Le décompte commence à -1 avec une incrementation sur le premier message, pour éviter tout probleme en cas d'inversion ou suppression du premier message

        // le texte a été splitté sinon Mediawiki casse tout...

        messages[++a] = "{{subst:" + "Bienvenue" + "}}" +  "--" + "~~" + "~~";
        images[a] = "http://upload.wikimedia.org/wikipedia/commons/e/eb/Button_accueilB.png";
        commentaires[a] = "Bienvenue !"

        messages[++a] = "{{subst:" + "Merci IP |~~~~" + "}}" +  "--" + "~~" + "~~";
        images[a] = "http://upload.wikimedia.org/wikipedia/commons/a/a9/Button_tournesol.png";
        commentaires[a] = "Merci pour ta contribution"

        messages[++a] = "{{subst:" + "Bienvenue vandale" + "}}" +  "--" + "~~" + "~~";
        images[a] = "http://upload.wikimedia.org/wikipedia/commons/0/00/Button_vandale.png";
        commentaires[a] = "Avertissement vandalisme"

        messages[++a] = "{{" + "PD-JORF-nor-conso" + "}}" ;
        images[a] = "http://upload.wikimedia.org/wikipedia/commons/2/20/Button_COA_France.png";
        commentaires[a] = ""


      ////////////////////////////////

for (var i=0;i<messages.length;i++) {
                var img = document.createElement("img");
                img.setAttribute("src", images[i]);
                
                var ref = document.createElement("a");
                ref.setAttribute("href", "javascript:insertTags('', \"" + messages[i] + "\", '');" + 
                                 "javascript:changeSummary(\"" + commentaires[i] + "\");" ); 
                ref.appendChild(img); 
                
                toolbar.appendChild(ref);
        }
  }
}

function changeSummary(sampleText) {
        document.editform.wpSummary.value = sampleText;
}

addLoadEvent(DeluxeBar);

////FONCTION TODAYDATE///
function TodayDate()
{
        var m = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre")
        var today = new Date()
        var day = today.getDate()
        var year = today.getYear()

        if (year < 2000)
                year += 1900

        return (day + " " + m[today.getMonth()] + " " + year)
}


/* NOUVEAUX CODE POUR LES BOUTON SUPPRIMÉS */

$(function() {

  if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) == -1)
    return;

  $.each([
    // Format : pour chaque bouton
    // [
    //   'Texte à insérer avant la sélection', 'Texte à insérer après la sélection',
    //   'Image du bouton (après « commons/ » et sans « .png » à la fin)',
    //   'Texte apparaissant dans la bulle au survol du bouton',
    //   'Identifiant de l'image ; importance faible, mais il faut s'assurer que l'identifiant est unique, ne change pas et n'utilise ni espace, ni caractères spéciaux'
    // ],
    //
    /*
    [
     '', '',
     '',
     '',
     ''
    ],
    */
    [
     '{{subst:#time:j F Y}}', '',
     '3/3f/Button_attendre',
     'Date courante',
     ''
    ],
    [
     '{{formatnum:','}}',
     'e/e9/Button_formatnum',
     'Format des nombres',
     'Nombre à insérer'
    ],
    [
     '{{subst:User:Grondin/meteo|','}}',
     '4/45/Button_meteo',
     'Symboles sur les cartes météo',
     'Option 1 pour les cartes vigilances, 2 pour les cartes météo.'
    ],
    [
     '{{LangSwitch|fr=','\n|ca=\n|es=\n|default=\n}}',
     'a/a5/Button_uses',
     'Texte multilangue',
     'Entrez le texte dans la langue idoine'
    ],
    [
     '{{Mérimée|type=|','}}',
     '5/5e/Button_momument_classé',
     'Base Mérimée',
     'Entrez la référence'
    ],
    [
     '{{Palissy|type=|','}}',
     '1/11/Button_momument_inscrit',
     'Base Palissy',
     'Entrez la référence de la base Palissy.'
    ],
    [
     '{{BIC|1=','|link=|idurl=|type=}}',
     '9/9c/Button_BIC',
     'BIC',
     'Entrez la référence de la BIC.'
    ],
    [
     '{{Bien Catalogado|1=','|link=|idurl=}}', 
     '9/9c/Button_BIC',
     'BIC',
     'Entrez la référence de la base de donnée.'
    ],
], function(_, button) {
    mw.toolbar.addButton('//upload.wikimedia.org/wikipedia/commons/' + button[2] + '.png', button[3], button[0], button[1], (button[0] ? button[4] : ''), 'mw-editbutton-' + button[4]);
  });

});


/*</pre>*/
//<nowiki>

//catALot///////////////////////////////////////
////////// Cat-A-Lot user preferences //////////
window.catALotPrefs = {"watchlist":"preferences","minor":false,"editpages":true,"docleanup":true,"subcatcount":50};
////////////////////////////////////catALotEnd//
//</nowiki>