// ] - extra afd/rfd/tfd/cfd/mfd-related wikipage
// functionality
// TODO: move to wikipageXfd.js
// depends: wikipage.js, datetime.js
// <pre><nowiki>
var wikipageXfd = new Object();
wikipageXfd.ddNames = { 'afd' : 'Wikipedia:Articles for deletion',
'tfd' : 'Wikipedia:Templates for deletion',
'ifd' : 'Wikipedia:Images and media for deletion',
'cfd' : 'Wikipedia:Categories for deletion',
'sfd' : 'Wikipedia:Stub types for deletion',
'rfd' : 'Wikipedia:Redirects for deletion',
'mfd' : 'Wikipedia:Miscellany for deletion' };
wikipageXfd._docIsRedirectP = function(doc) {
var d = doc.getElementById('contentSub');
return Boolean(d && d.textContent == 'Redirect page');
}
wikipageXfd._textIsRedirectP = function(doc) {
var d = doc.getElementById('wpTextbox1');
return Boolean(d && d.value.match(/^#REDIRECT/i));
}
// look at content to see whether this is a RFD
WikiPage.prototype._isRedirectP = function() {
if (this.viewDoc) {
return wikipageXfd._docIsRedirectP(this.viewDoc.doc);
} else if (this.editDoc) {
return wikipageXfd._textIsRedirectP(this.editDoc.doc);
} else {
alert ("## WikiPage._isRedirectP error a2ac8317-fbf3-4995-8041-92a638099adc");
return null;
}
}
// Return deletion debate type depending on page type.
//
// Valid types:
// afd (Articles)
// tfd (Templates)
// ifd (Images and media)
// cfd (Categories)
// sfd (Stub types)
// rfd (Redirects)
// mfd (Miscellaneous)
//
// Note: technically, if this is a Talk page, would have to use MFD; in
// practice if I'm on the talk page, I really mean to do action on non-Talk
// page.
WikiPage.prototype.xfdType = function() {
if (this._xfd_type) {
} else if (this.nsMainP) {
if (this._isRedirectP()) {
this._xfd_type = 'rfd';
} else {
this._xfd_type = 'afd';
}
} else if (this.nsCategoryP) {
this._xfd_type = 'cfd';
} else if (this.nsTemplateP) {
if (this.article.match(/-stub$/)) {
this._xfd_type = 'sfd';
} else {
this._xfd_type = 'tfd';
}
} else if (this.nsImageP) {
this._xfd_type = 'ifd';
} else {
this._xfd_type = 'mfd';
}
return this._xfd_type;
}
// return log page for given date (default today)
function afdLogPage(d) {
d = d || new Date();
return new WikiPage(null,'Wikipedia:Articles for deletion/Log/' + datestampYYYYMonthD(d));
}
WikiPage.prototype.xfdDebateName = function() {
var n = wikipageXfd.ddNames;
if (!n) {
alert("## WikiPage.xfdDebateName error 46d7d9a3-e63e-4749-a393-6de9ed6c87fa");
return null;
}
return n;
}
WikiPage.prototype.afdPage = function() {
if (this.xfdType() != 'afd') return;
return new WikiPage(null, 'Wikipedia:Articles for deletion/' + this.article);
}
WikiPage.prototype.afdPageX = function() {
// already an AFD page?
if (this.afdTargetPage()) return this;
return this.afdPage();
}
WikiPage.prototype.afdTargetPage = function() {
if (!this.page.match(/^Wikipedia:Articles for deletion\/(.*?)(?: \(+|2nd nomination|3rd nomination|4th nomination\))?$/)) return null;
var p = RegExp.$1;
if (p.match(/^Log\//)) return null;
return new WikiPage(null, p);
}
WikiPage.prototype.afdLogDate = function() {
if (!this.page.match(/^Wikipedia:Articles for deletion\/Log\/(.*?)?$/)) return null;
var d = RegExp.$1;
return new Date(Date.parse(d));
}
wikipageXfd._load = function() {
window.wpAfdTarget = wikiPage.afdTargetPage();
window.wpAfd = wikiPage.afdPageX();
window.wpAfdLogDate = wikiPage.afdLogDate();
window.afdP = Boolean(wpAfdTarget);
window.afdLogP = Boolean(wpAfdLogDate);
}
addOnloadHook(wikipageXfd._load);
// </nowiki></pre>