FANDOM

2,054,106 Pages

//
// RenameCheck by Bobogoobo
// Works on Special:MovePage to show the state of the intended destination
$(function() {
    if (mw.config.get('wgCanonicalSpecialPageName') !== 'Movepage') {
        return;
    }
 
    $('#wpNewTitleMain').blur(function() {
        $('#rename-check').remove();
        var $this = $(this);
        var newPage = $('#wpNewTitleNs option:selected').text();
        newPage = (newPage === '(Main)' ? '' : newPage + ':') + $this.val();
        newPage = newPage.replace(/ /g, '_');
        $.getJSON('/api.php?action=query&prop=info&titles=' +
            encodeURIComponent(newPage) + '&inprop=redirect' + '&format=json',
            function(data) {
                data = data.query.pages;
                data = data[Object.keys(data)[0]];
                if (data.hasOwnProperty('missing')) {
                    $this.after($('<img />', {
                        'src': 'http://vignette4.wikia.nocookie.net/lyricwiki/images/f/f5/Completed.png',
                        'title': 'Page name is available',
                        'style': 'margin-left:0.5em;',
                        'id': 'rename-check'
                    }));
                } else {
                    $this.after($('<a />', {
                        'style': 'margin-left:0.5em;' +
                            (data.redirectto ? 'font-style:italic;' : ''),
                        'href': '/wiki/' + encodeURIComponent(data.title.replace(/ /g, '_')) +
                            (data.redirectto ? '?redirect=no' : ''),
                        'text': newPage.replace(/_/g, ' '),
                        'id': 'rename-check'
                    }));
                }
            }
        );
    });
 
    if (mw.util.getParamValue('wpNewTitle')) {
        $('#wpNewTitleMain').blur();
    }
});
//
Community content is available under Copyright unless otherwise noted.