MediaWiki:Gadget-MoveUtil.js: Difference between revisions

From Elwiki
mNo edit summary
mNo edit summary
Line 2: Line 2:
     if(mw.config.get('wgNamespaceNumber') == -1 && /MovePage(\/.+)?/.test(mw.config.get('wgTitle'))){
     if(mw.config.get('wgNamespaceNumber') == -1 && /MovePage(\/.+)?/.test(mw.config.get('wgTitle'))){
         if($('#mw-movepage-table').length){
         if($('#mw-movepage-table').length){
             $('#wpMovetalk').attr('checked', true);
             $('#wpMovetalk input.wpMovetalk').attr('checked', true);
             $('#wpLeaveRedirect').attr('checked', false);
             $('#wpLeaveRedirect input.wpLeaveRedirect').attr('checked', false);
             $('#wpMovesubpages').attr('checked', true);
             $('#wpMovesubpages input.wpMovesubpages').attr('checked', true);
             /* Bind to Submit Event */
             /* Bind to Submit Event */
             $('#movepage').submit(function(event){
             $('#movepage').submit(function(event){

Revision as of 03:19, 2 December 2015

window.RLQ.push(function(){
    if(mw.config.get('wgNamespaceNumber') == -1 && /MovePage(\/.+)?/.test(mw.config.get('wgTitle'))){
        if($('#mw-movepage-table').length){
            $('#wpMovetalk input.wpMovetalk').attr('checked', true);
            $('#wpLeaveRedirect input.wpLeaveRedirect').attr('checked', false);
            $('#wpMovesubpages input.wpMovesubpages').attr('checked', true);
            /* Bind to Submit Event */
            $('#movepage').submit(function(event){
                var from, ns, to, api;
                api = new mw.Api();

                from = $('#mw-movepage-table strong').first().text();
                ns = mw.config.get('wgFormattedNamespaces', {});
                ns = ns[$('#wpNewTitleNs').val()];
                to = $('#wpNewTitleMain').val();

                /* Add Line in MoveList */
                api.postWithToken('edit', {
                    'minor': '',
                    'recreate': '',
                    'bot': '',
                    'action': 'edit',
                    'title': 'Category:MovedPages',
                    'summary': 'Bot Adding From Page Move. --[[Special:Gadgets|Move Util]]',
                    'contentmodel': 'wikitext',
                    'appendtext': ['\n*', from, '->', (ns == '' ? '' : ns + ':') + to].join(' ')
                });
                api.postWithToken('edit', {
                    'minor': '',
                    'recreate': '',
                    'bot': '',
                    'action': 'edit',
                    'title': 'Category:MovedRelated',
                    'summary': 'Bot Adding From Page Move. Pages linked to moved pages. --[[Special:Gadgets|Move Util]]',
                    'contentmodel': 'wikitext',
                    'appendtext': ['\n', '== Link to ', from, ' ==',
                                   '\n', '{{', 'Special:WhatLinksHere/', from, '|limit=10000', '|stripprefix=1', '}}',
                                   '\n', '== Subpages of ', from, ' ==',
                                   '\n', '{{', 'Special:PrefixIndex/', from, '/|limit=10000', '|stripprefix=1','}}'].join('')
                });
            });
        }
    }
});