MediaWiki:EditTemplates.js

From Donate
Revision as of 20:58, 22 August 2017 by Pcoombe (talk | contribs) (change Styles link)
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
$(document).ready(function() {

    if ( mw.config.get('wgPageName') == "Special:LandingPage" ) {

        importStylesheet( 'MediaWiki:EditTemplates.css' );

        $( 'body' ).append( '<div id="editTemplates"><span id="editText">Tools</span><img id="editArrow" width="8" src="//upload.wikimedia.org/wikipedia/commons/thumb/1/10/ArrowRightNavbox.svg/32px-ArrowRightNavbox.svg.png"/></div>' );

        $( 'body' ).append( '<div id="editTemplatesList"></div>' );

        $( '#editTemplatesList' ).append( '<h4>Edit templates</h4>' );

        var country = mw.util.getParamValue( 'country' ) || 'XX';
        var language = mw.util.getParamValue( 'uselang' ) || 'en';

        var editList = '' +
        '<ul>' +
        '<li><a href="/wiki/Template:Lp-layout-default?action=edit">Overall Layout</a></li>' +
        '<li><a href="/wiki/Template:2011FR/Appeal-template-default?action=edit">Appeal Template</a></li>' +
        '<li>- <a href="/wiki/Template:2011FR/Appeal-default/text/@language?action=edit">Appeal Text</a></li>' +
        '<li>- <a href="/wiki/Template:2011FR/Appeal-default/title/@language?action=edit">Appeal Title</a></li>' +
        '<li><a href="/wiki/Template:2012FR/Form-template-whereyourdonation?action=edit">Form Template</a></li>' +
        '<li>- <a href="/wiki/Template:2012FR/Form-countryspecific-control/@country?action=edit">Form Content</a></li>' +
        '<li>- <a href="/wiki/Template:2012FR/Form-section/Infobox/Default/title/@language?action=edit">Infobox Title</a></li>' +
        '<li>- <a href="/wiki/Template:2012FR/Form-section/Infobox/Default/text/@language?action=edit">Infobox Text</a></li>' +
        '</ul>';

        editList = editList.replace( /@country/g, country );
        editList = editList.replace( /@language/g, language );

        $( '#editTemplatesList' ).append( editList );

        var otherTools = '' +
        '<h4>Files</h4>' +
        '<ul>' +
        '<li><a href="/wiki/Special:AllPages?namespace=6">All files</a></li>' +
        '<li><a href="/wiki/Special:Upload">Upload file</a></li>' +
        '</ul>' +
        '<h4>Other tools</h4>' +
        '<ul>' +
        '<li><a href="/wiki/Special:AllPages">All pages</a></li>' +
        '<li><a href="/wiki/Special:PrefixIndex">All pages with prefix</a></li>' +
        '<li><a href="https://donate.wikimedia.org/w/index.php?title=Special%3APrefixIndex&prefix=2011FR%2FAppeal-&namespace=10">All appeals</a>' +
        '<li><a href="https://donate.wikimedia.org/w/index.php?title=Special%3APrefixIndex&prefix=Styles&namespace=10">Styles</a></li>' +
        '<li><a href="/wiki/Template:2012FR/Form-section/Paymentmethods">Payment methods</a></li>' +
        '<li><a href="/wiki/MediaWiki:Common.js">Site JavaScript</a></li>' +
        '<li><a href="/wiki/Special:MyContributions">My contributions</a></li>' +
        '<li><a href="/wiki/MediaWiki:EditTemplates.js">This toolbox</a></li>' +
        '</ul>';

        $( '#editTemplatesList' ).append( otherTools );

        var showEditBox = function(){
            $( '#editTemplatesList' ).css( 'display', 'inline-block' );
            $( '#editTemplates' ).click( function(){ hideEditBox(); } );
        };
        var hideEditBox = function(){
            $( '#editTemplatesList' ).css( 'display', 'none' );
            $( '#editTemplates' ).click( function(){ showEditBox(); } );
        };

        hideEditBox();
    }
    
});