Jump to content

User:Patrick87/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Patrick87 (talk | contribs) at 20:00, 8 May 2013 (Add preview button to upload form and preload with information template). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// ########## only for enwiki ##########

// Change "Upload file" link from [[Wikipedia:File Upload Wizard]] to [[Special:Upload]]
var d = document.getElementById("t-upload");
d.innerHTML = d.innerHTML.replace("wiki/Wikipedia:File_Upload_Wizard", "wiki/Special:Upload");

// Add preview button to upload form and preload with information template
if (mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload') {
    importScript("User:Patrick87/UploadForm.js");
}

// markAdmins (original source [[:de:Benutzer:PDD/markAdmins.js]])
importScript('User:Patrick87/markAdmins.js');
markcomadmins = true; // zusätzlich: Commons-Admins besonders hervorheben
markwdadmins  = true; // zusätzlich: Wikidata-Admins besonders hervorheben



// ########## interwiki content ##########

// [[en:User:Haza-w/Drop-down menus]]
importScriptURI('http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Haza-w/cactions.js');
var cactions = {
    itabs: false
};


// [[en:User:Gary King/comments in local time.js]]
importScriptURI('http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Gary King/comments in local time.js');
LocalComments = {
    dateDifference: false,
    dateFormat: 'ymd',
    twentyFourHours: true,
    dayOfWeek: false
};


// [[de:Benutzer:TMg/filterContributions.js]]
//importScriptURI('http://de.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=Benutzer:TMg/filterContributions.js');

// [[de:Benutzer:Revolus/beitraege_filtern.js]]
//importScriptURI('http://de.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=Benutzer:Revolus/beitraege filtern.js');

// [[de:Benutzer:P.Copp/scripts/hideduplicatecontribs.js]]
importScriptURI('http://de.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=Benutzer:P.Copp/scripts/hideduplicatecontribs.js');


//[[de:Benutzer:TMg/moveInterwikisToTop.js]]
var moveInterwikisToTopArray = ["de", "en"];
mw.loader.load("//de.wikipedia.org/w/index.php?title=Benutzer:TMg/moveInterwikisToTop.js&action=raw&ctype=text/javascript");


// [[mw:User:Remember the dot/Syntax highlighter]]
mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=application/javascript&smaxage=21600&maxage=86400');


// WikiEditor [[mw:Extension:WikiEditor]]
var customizeToolbar = function() {
    // strikethrough button
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'main',
        group: 'format',
        tools: {
                "strikethrough": {
                        label: 'Strike',
                        type: 'button',
                        icon: '/media/wikipedia/commons/f/f9/Toolbaricon_regular_S_stroke.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<s>",
                                        post: "</s>"
                                }
                        }
                }
        }
    });
    // math button
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            section: 'advanced',
            group: 'format',
            tools: {
                    "math": {
                            label: 'Math',
                            type: 'button',
                            icon: '/media/wikipedia/commons/2/2e/Button_math.png',
                            action: {
                                    type: 'encapsulate',
                                    options: {
                                            pre: "<math>",
                                            post: "</math>"
                                    }
                            }
                    }
            }
    } );
    // code button
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            section: 'advanced',
            group: 'format',
            tools: {
                    "code": {
                            label: 'Code',
                            type: 'button',
                            icon: '/media/wikipedia/commons/2/23/Button_code.png',
                            action: {
                                    type: 'encapsulate',
                                    options: {
                                            pre: "<code>",
                                            post: "</code>"
                                    }
                            }
                    }
            }
    } );
};
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
        mw.loader.using( 'user.options', function () {
                if ( mw.user.options.get('usebetatoolbar') ) {
                        mw.loader.using( 'ext.wikiEditor.toolbar', function () {
                                $(document).ready( customizeToolbar );
                        } );
                }
        } );
}