User:Cleared as filed/wikipageAfd.js

// User:Quarl/wikipageAfd.js - extra afd-related wikipage functionality

// requires: wikipage.js, datetime.js

//

// 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.afdPage = function { // AFD only applies to main (ignoring Talk) if (!this.nsMainP) return null;

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\/(.*?)(?: \([0-9]+|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)); }

function wikipageAfd_load { window.wpAfdTarget = wikiPage.afdTargetPage; window.wpAfd = wikiPage.afdPageX; window.wpAfdLogDate = wikiPage.afdLogDate;

window.afdP = Boolean(wpAfdTarget); window.afdLogP = Boolean(wpAfdLogDate); }

$(wikipageAfd_load);

//