MediaWiki:Gadget-MoveUtil.js: Difference between revisions

From Elwiki
mNo edit summary
m (Migrate to RLQ)
Line 1: Line 1:
if(mw.config.get('wgNamespaceNumber') == -1 && /MovePage(\/.+)?/.test(mw.config.get('wgTitle'))){
window.RLQ.push(function(){
    if($('#mw-movepage-table').length){
    if(mw.config.get('wgNamespaceNumber') == -1 && /MovePage(\/.+)?/.test(mw.config.get('wgTitle'))){
        $('#wpMovetalk').attr('checked', 'checked');
        if($('#mw-movepage-table').length){
        $('#wpLeaveRedirect').removeAttr('checked');
            $('#wpMovetalk').attr('checked', 'checked');
        $('#wpMovesubpages').attr('checked', 'checked');
            $('#wpLeaveRedirect').removeAttr('checked');
        /* Bind to Submit Event */
            $('#wpMovesubpages').attr('checked', 'checked');
        $('#movepage').submit(function(event){
            /* Bind to Submit Event */
            var from, ns, to, api;
            $('#movepage').submit(function(event){
            api = new mw.Api();
                var from, ns, to, api;
                api = new mw.Api();


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


            /* Add Line in MoveList */
                /* Add Line in MoveList */
            api.postWithToken('edit', {
                api.postWithToken('edit', {
                'minor': '',
                    'minor': '',
                'recreate': '',
                    'recreate': '',
                'bot': '',
                    'bot': '',
                'action': 'edit',
                    'action': 'edit',
                'title': 'Category:MovedPages',
                    'title': 'Category:MovedPages',
                'summary': 'Bot Adding From Page Move. --[[Special:Gadgets|Move Util]]',
                    'summary': 'Bot Adding From Page Move. --[[Special:Gadgets|Move Util]]',
                'contentmodel': 'wikitext',
                    'contentmodel': 'wikitext',
                'appendtext': ['\n*', from, '->', (ns == '' ? '' : ns + ':') + to].join(' ')
                    '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('')
                });
             });
             });
            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('')
            });
         });
     }
     }
}
});

Revision as of 03:15, 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').attr('checked', 'checked');
            $('#wpLeaveRedirect').removeAttr('checked');
            $('#wpMovesubpages').attr('checked', 'checked');
            /* 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('')
                });
            });
        }
    }
});