MediaWiki:Gadget-MoveUtil.js: Difference between revisions

From Elwiki
mNo edit summary
mNo edit summary
Line 5: Line 5:
         $('#wpMovesubpages').attr('checked', 'checked');
         $('#wpMovesubpages').attr('checked', 'checked');
         /* Bind to Submit Event */
         /* Bind to Submit Event */
         $('form#movepage').submit(function(){
         $('#movepage').submit(function(){
             var from, ns, to, wiki, api, new_wiki;
             var from, ns, to, wiki, api, new_wiki;
             from = $('#mw-movepage-table strong').first().text();
             from = $('#mw-movepage-table strong').first().text();
Line 26: Line 26:
                 'appendtext': from + ' -> ' + (ns == '' ? '' : ns + ':') + to
                 'appendtext': from + ' -> ' + (ns == '' ? '' : ns + ':') + to
             }).done(function(){
             }).done(function(){
                 $('form#movepage').submit();
                 $('#movepage').submit();
             });
             });
         });
         });
     }
     }
}
}

Revision as of 13:25, 7 May 2015

if(wgNamespaceNumber == -1 && /MovePage(\/.+)?/.test(wgTitle)){
    if($('#mw-movepage-table').length){
        $('#wpMovetalk').attr('checked', 'checked');
        $('#wpLeaveRedirect').removeAttr('checked');
        $('#wpMovesubpages').attr('checked', 'checked');
        /* Bind to Submit Event */
        $('#movepage').submit(function(){
            var from, ns, to, wiki, api, new_wiki;
            from = $('#mw-movepage-table strong').first().text();
            ns = mw.config.get('wgNamespaceIds', wgNamespaceIds);
            ns = ns.map(function(e){
                return e.name;
            }).indexOf($('#wpNewTitleNs').val());
            to = $('#wpNewTitleMain').val();

            api = new mw.Api();
            /* Add Line in MoveList */
            api.postWithToken('edit', {
                'minor': '',
                'recreate': '',
                'bot': '',
                'action': 'edit',
                'title': 'User:Boxsnake/MoveList',
                'summary': 'Bot Adding From Page Move. --[[Special:Gadgets|Move Util]]',
                'contentmodel': 'wikitext',
                'appendtext': from + ' -> ' + (ns == '' ? '' : ns + ':') + to
            }).done(function(){
                $('#movepage').submit();
            });
        });
    }
}