User:קיפודנחש/personalEdittools.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.
// personal edit toolbox
// witten by [[:he:User:קיפודנחש]]
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) + 1)
mw.loader.using('mediawiki.api', function() {
        function subPageName() {
                switch (mw.config.get('wgUserLanguage')) {
                        case 'he': return 'כלי עריכה';
                        case 'en': return 'Edit tools';
                }
                return 'Edit tools';
        }
        new mw.Api().get({action: 'parse', page: 'User:' + mw.config.get('wgUserName') + '/' + subPageName()})
            .done( function(data) {
                        if (data && data.parse && data.parse.text && data.parse.text['*'])
                                $(function() {
                                        $('#editpage-specialchars')
                                        .before(
                                                $('<div>', {'class': 'mw-charinsert-buttons'})
                                                .css({border: 'solid gray 1px'})
                                                .html(data.parse.text['*']));
                                        $('#personal-edittools-' + (mw.config.get('wgCanonicalNamespace') || 'Article')).toggle(true); 
                                });
                        });
                });