Jump to content

User:Dgw/rollbackbits.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* This object holds utility functions for messing with MediaWiki's rollback links */

var RollbackBits = {
    Type: '',   // Defined by an onload function, below
                // @private: Technically, one should always use RollbackBits.GetType()
    CheckType: function() {
        if(document.getElementById('pagehistory')) { return 'hist'; }
        if(document.getElementById('mw-diff-ntitle2')) { return 'diff'; }
        if(wgCanonicalSpecialPageName && wgCanonicalSpecialPageName == 'Contributions') { return 'trib'; }
        else { return false; }
    },
    GetType: function() {
        if(this.Type == '') { this.Type = this.CheckType(); return this.Type; }
        else return this.Type;
    },
    PromptForSummary: function() {  // Designed to be called by the onclick of a rollback link 
        var summary = prompt('Enter a summary for your rollback. To cancel, click Cancel or the X.','');
        if(summary) {
            this.href += '&summary=' + escape(summary).replace(/\+/,'%2B');
            return true;
        } else {
            return false;
        }
    }
};