Commons:Counter Vandalism Unit/scripts

From Wikimedia Commons, the free media repository
Jump to: navigation, search

Snippets for your edit-toolbar[edit]

Research shows that adding {{test}} and {{Welcome}} takes an average 621 ms typing time for an experienced user. Beat that with a click !

Here are some examples, feel free to use the ones you like or customize them to your need.

Vector[edit]

I wrote a little script to make it more like the old syntax. Here is the syntax to add a button to insert a signed Welcome-template :

// Welcome :
        // Welcome
        krInsertWikiEditorButton({
                "id": "welcome",
                "icon": "//upload.wikimedia.org/wikipedia/commons/thumb/2/23/Nuvola_apps_edu_languages.svg/22px-Nuvola_apps_edu_languages.svg.png",
                "label": "Welcome",
                "insertBefore": "{\{Welcome}\}~~\~~",
                "insertAfter": "",
                "sampleText": "",
                "autoSummary": { "summary": "/* Welcome to Wikimedia Commons ! */ new section", "position": "replace" }
        });

Add snippets

/**
 * Extra buttons in toolbar
 * @stats [[File:Krinkle_insertVectorButtons.js]]
 */
jQuery.getScript('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript', function () {
 
        // Welcome
        krInsertWikiEditorButton({
                "id": "welcome",
                "icon": "//upload.wikimedia.org/wikipedia/commons/thumb/2/23/Nuvola_apps_edu_languages.svg/22px-Nuvola_apps_edu_languages.svg.png",
                "label": "Welcome",
                "insertBefore": "{\{Welcome}\}~~\~~",
                "insertAfter": "",
                "sampleText": "",
                "autoSummary": { "summary": "/* Welcome to Wikimedia Commons ! */ new section", "position": "replace" }
        });
        // Welcome + Sandbox
        krInsertWikiEditorButton({
                "id": "welcometest1",
                "icon": "//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Gtk-dialog-info.svg/22px-Gtk-dialog-info.svg.png",
                "label": "Welcome + Sandbox",
                "insertBefore": "{\{Welcome}\}\n{\{subst:test|",
                "insertAfter": "}\}\~\~\~\~",
                "sampleText": "",
                "autoSummary": { "summary": "/* Please experiment in the sandbox */ new section", "position": "replace" }
        });
        // Test2
        krInsertWikiEditorButton({
                "id": "test2",
                "icon": "//upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Nuvola_apps_important.svg/22px-Nuvola_apps_important.svg.png",
                "label": "Test2",
                "insertBefore": "{\{subst:test2|",
                "insertAfter": "}\}\~\~\~\~",
                "sampleText": "",
                "autoSummary": { "summary": "/* Vandalism is not appreciated */ new section", "position": "replace" }
        }); 
        // Test3
        krInsertWikiEditorButton({
                "id": "test3",
                "icon": "//upload.wikimedia.org/wikipedia/commons/thumb/f/f1/Stop_hand_nuvola.svg/22px-Stop_hand_nuvola.svg.png",
                "label": "Test3",
                "insertBefore": "{\{subst:test3|",
                "insertAfter": "}\}\~\~\~\~",
                "sampleText": "",
                "autoSummary": { "summary": "/* Warning for repeated vandalism */ new section", "position": "replace" }
        }); 
        // Hi BASEPAGENAME
        krInsertWikiEditorButton({
                "id": "mw-customeditbutton-hibasepagename",
                "icon": "//upload.wikimedia.org/wikipedia/commons/f/f8/Waving.png",
                "label": "Hi BASEPAGENAME",
                "insertBefore": "Hi {\{subst:BASEPAGENAME}\},\n",
                "insertAfter": "",
                "sampleText": ""
        }); 
        // Happy face
        krInsertWikiEditorButton({
                "id": "mw-customeditbutton-myspecialbutton",
                "icon": "//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png",
                "label": "Insert happy face",
                "insertBefore": "[[File:Gnome-face-smile.svg|21px|",
                "insertAfter": "]]",
                "sampleText": "Happy face"
        }); 
});

Monobook[edit]

In Monobook the syntax is slightly different :

//Welcome
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageId": "mw-customeditbutton-welcome",
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/f/f2/Button_prononciation.png",
    "speedTip": "Welcome",
    "tagOpen": "{\{Welcome}\}\~\~\~\~",
    "tagClose": "",
    "sampleText": ""}

Add snippets

// Put the snippets within this function:
function InsertButtonsToToolBar() {
 
//Welcome
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageId": "mw-customeditbutton-welcome",
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/f/f2/Button_prononciation.png",
    "speedTip": "Welcome",
    "tagOpen": "{\{Welcome}\}\~\~\~\~",
    "tagClose": "",
    "sampleText": ""}
 
//Welcome + Sandbox
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageId": "mw-customeditbutton-welcometest1",
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/c/cb/Userwarntest.png",
    "speedTip": "Welcome+Sandbox",
    "tagOpen": "{\{Welcome}\}\n\n{\{subst:test|",
    "tagClose": "}\}\~\~\~\~",
    "sampleText": ""}
 
//Test2
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageId": "mw-customeditbutton-test2",
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/e/e7/Uw2.png",
    "speedTip": "Test2",
    "tagOpen": "{\{subst:test2|",
    "tagClose": "}\}\~\~\~\~",
    "sampleText": ""}
 
//Test3
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageId": "mw-customeditbutton-test3",
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/be/Uw3.png",
    "speedTip": "Test3",
    "tagOpen": "{\{subst:test3|",
    "tagClose": "}\}\~\~\~\~",
    "sampleText": ""}
}
addOnloadHook( InsertButtonsToToolBar );