MediaWiki:Gadget-MoveUtil.js

From Elwiki
Revision as of 15:17, 7 May 2015 by Boxsnake (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
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(event){
            alert('.submit called');
            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();
            });
            event.preventDefault();
        });
    }
}