User:Dgw/rollbackbits.js
/* 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;
}
}
};