Jump to content

User:Leag/resume.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.
// Résumé Deluxe 
// Fonction ResumeDeluxeModif
// Code : Dake

function ResumeDeluxeModif(content) {
    if (document.editform.wpSummary.value != 0) {
                document.editform.wpSummary.value+=' - ';
        }
        
        document.editform.wpSummary.value+=content;
}

function ResumeDeluxe() {
        // vous pouvez ajouter vos messages ci-dessous - attention aux apostrophes et aux 
        // guillemets qui peuvent casser le script
        var messages = new Array()
        var labelBoutons = new Array()
        var ca = 0;

        messages[ca] = "Orthographe";
        labelBoutons[ca++] = "ortho";

        messages[ca] = "Categories";
        labelBoutons[ca++] = "cat";

        messages[ca] = "Wikification";
        labelBoutons[ca++] = "wiki";

        messages[ca] = "Wiki Link";
        labelBoutons[ca++] = "lien";

        messages[ca] = "Interwiki";
        labelBoutons[ca++] = "interwiki";

        messages[ca] = "Add stub";
        labelBoutons[ca++] = "+ ébauche";

        messages[ca] = "Remove stub";
        labelBoutons[ca++] = "- ébauche";

        messages[ca] = "Add portal";
        labelBoutons[ca++] = "+ portail";

        messages[ca++] = "Ludobox";
        labelBoutons[ca++] = "ludobox";

        messages[ca] = "Add image";
        labelBoutons[ca++] = "+ image";

        messages[ca] = "Revert";
        labelBoutons[ca++] = "revert";

        var nombreBoutonsParLigne = 12;
        
        // ne rien toucher ci-dessous
        var mainNode = document.getElementById("wpSummaryLabel");
        if (!mainNode) {
                return;
        }
        var summaryNode = mainNode;
        
        var formButtons = document.createElement("form");
        
        for (var i=0;i<messages.length;i++) {
                if (i%nombreBoutonsParLigne==0) {
                        formButtons.appendChild(document.createElement("p"));
                }
                        
                var nodeInput = document.createElement("input");
                nodeInput.setAttribute("type", "button"); 
                nodeInput.setAttribute("value", labelBoutons[i]); 
                nodeInput.setAttribute("onClick", "ResumeDeluxeModif('" + messages[i] + "')"); 

                formButtons.appendChild(nodeInput); 
        }
        summaryNode.appendChild(formButtons);     
}
$(ResumeDeluxe);