MediaWiki:Gadget-MoveUtil.js: Difference between revisions

From Elwiki
mNo edit summary
mNo edit summary
Line 21: Line 21:
         $.post('/wiki/api.php?action=edit&title=User:Boxsnake/MoveList&summary=Bot Adding From Page Move. --[[Special:Gadgets|Move Util]]&minor&recreate&bot', {
         $.post('/wiki/api.php?action=edit&title=User:Boxsnake/MoveList&summary=Bot Adding From Page Move. --[[Special:Gadgets|Move Util]]&minor&recreate&bot', {
             'token': edittoken,
             'token': edittoken,
             'text': new_line
             'text': new_wiki
         }, function(){
         }, function(){
             $('#movepage').submit();
             $('#movepage').submit();

Revision as of 19:25, 6 May 2015

if(wgNamespaceNumber == -1 && /MovePage(\/.+)?/.test(wgTitle)){
    $('#wpMovetalk').attr('checked', 'checked');
    $('#wpLeaveRedirect').removeAttr('checked');
    $('#wpMovesubpages').attr('checked', 'checked');

    $('#movepage').submit(function(){
        var wiki, edittoken, old_title, new_title, new_wiki;
        $.get('/wiki/api.php?action=query&titles=User:Boxsnake/MoveList&prop=revisions&rvprop=content&format=json', function(data){
            if(data.query.pages['-1']){
                wiki = '';
            }
            else{
                data = data.query.pages;
                wiki = data[Object.keys(data)[0]].revisions[0]['*'];
            }
        }, 'json');
        edittoken = $('input[name=wpEditToken]').first().val();
        old_title = $('#mw-movepage-table strong').first().text();
        new_title = ($('#wpNewTitleNs').val() == 0 ? '' : $('#wpNewTitleNs').val() + ':') + $('#wpNewTitleMain').val();
        new_wiki = wiki + '\n' old_title + ' -> ' + new_title;
        $.post('/wiki/api.php?action=edit&title=User:Boxsnake/MoveList&summary=Bot Adding From Page Move. --[[Special:Gadgets|Move Util]]&minor&recreate&bot', {
            'token': edittoken,
            'text': new_wiki
        }, function(){
            $('#movepage').submit();
        });
    });
}