Jump to content

User:Dgw/rollbackbits.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dgw (talk | contribs) at 04:58, 12 January 2008 (So, this is something to use as a sort of library of rollback-related functions...). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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
    SetType: function() {
        if(document.getElementById('pagehistory')) RollbackBits.rollbackType = 'hist';
        if(document.getElementById('mw-diff-ntitle2')) RollbackBits.rollbackType = 'diff';
        if(wgCanonicalSpecialPageName && wgCanonicalSpecialPageName == 'Contributions') RollbackBits.rollbackType = 'trib';
        else RollbackBits.rollbackType = false;
    },
    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);
            return true;
        } else {
            return false;
        }
    }
};

addOnloadHook(RollbackBits.SetType);