Jump to content

User:Jean-Frédéric/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript('User:Dapete/ImageMapEdit.js');


/*
 * Catégories à Gauche
 *
 * Met les catégories dans un panneau de navigation
 *
 * Auteur : Jmfayard
 * Dernière révision : 3 novembre 2006
 */
 
function CategoriesAGauche() {
 
        var catlinks = document.getElementById("catlinks");
        if (!catlinks) { return; }
        var categories = catlinks.getElementsByTagName("a") ;
 
        var h5_cats = document.createElement( "h5" );
        var text = document.createTextNode( "Catégories" ) ;
        h5_cats.appendChild( text ) ;
 
        var div_cats = document.createElement( "div" );
        div_cats.setAttribute( "class", "pBody" );
 
        var ul = document.createElement( "ul" );
 
        var a_debut = 1 ; // evitons le lien Categories:
        for (var i = a_debut ; i < categories.length ; i++ ) {
                var a = categories[i] ;
                var li = document.createElement( "li" ) ;
                li.appendChild( a.cloneNode(1) ) ;
                ul.appendChild( li );
        }
 
        div_cats.appendChild( ul ) ;
 
 
        var portlet = document.createElement( "div" ) ;
        portlet.setAttribute( "class", "portlet" );
        portlet.setAttribute( "id", "p-cat" ) ;
 
        portlet.appendChild( h5_cats ) ;
 
        portlet.appendChild( div_cats ) ;
 
        //document.getElementById("column-one").insertBefore( document.getElementById("p-search"),  portlet ) ;
        //document.getElementById("column-one").appendChild(  portlet ) ;
        div_ptb = document.getElementById( "p-tb" );
        document.getElementById("column-one").insertBefore( portlet, div_ptb)
 
}
addOnloadHook( CategoriesAGauche ) ;





/*----------------------------------------------------------------------------
 * Ajoute des commentaires de modification prédéfinis
 *
 * Auteur : Dake
 * Contributions : Pabix, Tieno
 * Date de dernière révision : 12 novembre 2006
 */
//////////////////////ZONE PERSONNALISABLE//////////////////////
var resumedeluxeTitles = new Array();
with (resumedeluxeTitles) {
        push("Interwiki fr");
        push("- orthograph");
        push("- wikification");
        push("- DefaultSort");
        push("- CommonsCat");
}
var resumedeluxeInputs= new Array();
with (resumedeluxeInputs) {
        push("Adding [[fr:]]");
        push("Orthograph");
        push("Wikification");
        push("DefaultSort");
        push("Adding [[Commons:Category:]]");
}
/////////////////FIN DE LA ZONE PERSONNALISABLE/////////////////

function setSummary(str)
{
        document.editform.wpSummary.value = str;
}

function addToSummary(str)
{
        var resum = document.editform.wpSummary.value;
        if(resum != 0 && resum.indexOf("*/") < resum.length - 3) {
                document.editform.wpSummary.value += " - ";
        }
        document.editform.wpSummary.value += str;
}

function DeluxeSummary()
{
        var sumLbl = document.getElementById("wpSummaryLabel");
        if(sumLbl) {
                var sumInput = document.getElementById("wpSummary");
                sumInput.style.width = "95%";
                var str = "Messages prédéfinis : ";
                for(var cpt = 0; cpt < resumedeluxeTitles.length; cpt ++) {
                        str += "<a href=\"javascript:addToSummary('" +resumedeluxeInputs[cpt] + "')\""
                                + " class=\"sumLink\" title=\"Ajouter '" +resumedeluxeInputs[cpt] +"' dans la boîte de résumé\">"
                                + resumedeluxeTitles[cpt]
                                + "</a> ";
                }
                sumLbl.innerHTML = str + "<br />" + sumLbl.innerHTML;
        }
}
addOnloadHook(DeluxeSummary);
//

function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) {
  mwCustomEditButtons[mwCustomEditButtons.length] =
    {"imageId": imageId,
     "imageFile": imageFile,
     "speedTip": speedTip,
     "tagOpen": tagOpen,
     "tagClose": tagClose,
     "sampleText": sampleText};
}  


addCustomButton('http://upload.wikimedia.org/wikipedia/commons/f/f8/Button_Tool_commons.png',
                'Commons Cat',
                '{{Commonscat|',
                '}}',
                getArticleName(),
                'Commons');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/8/82/Button_l_fr.png',
 'Interwiki Fr',
 '[[fr:',
 ']]',
 getArticleName(),
 'Fr');

function getArticleName(){
	var name = mw.config.get('wgPageName').replace(/_/g, " ");
	return name;
}