User:Winged Blades of Godric/prodhelper.js

/* ============================================== *\ \* ============================================== */
 * PROD Helper - JavaScript PROD Script
 * for Wikipedia
 * Created originally by Alex Barley User:Ale_jrb as prod HELPER
 * Modified by User:Winged_Blades_of_Godric as prod HELPER
 * You are advised to import this script to your
 * common.js page - AVOID CREATING YOUR OWN
 * VERSION WHERE POSSIBLE.
 * Instructions for this script can be found at
 * User:Ale_jrb/Scripts - refer to this for
 * setting details.
 * Instructions for this script can be found at
 * User:Ale_jrb/Scripts - refer to this for
 * setting details.

// NB. this script relies on User:Ale_jrb/Scripts/waLib.js. // the following settings are used in this script: if (prodhDisplayAlways == null)		var prodhDisplayAlways	= false;		// whether to display prodH even if the page is not tagged if (notifyByDefaultDec == null) 	var notifyByDefaultDec	= true;			// whether to check the 'notify tagger' box by default when declining a speedy deletion request if (notifyByDefaultNew == null) 	var notifyByDefaultNew	= true;			// whether to check the 'use newbie message' box by default if (notifyLimit == null) 			var notifyLimit			= 12;			// how many revisions should be retrieved when determining who tagged the page if (notifyTemplate == null)			var notifyTemplate		= 'User:Ale_jrb/Scripts/csdHelper'; // the template that should be substituted for notification messages

if (prodhDoRedirect == null)			var prodhDoRedirect		= true; if (myDeleteReasons == null)		var myDeleteReasons		= []; 	// any addition speedy deletion reasons to add to the list

if (logOnDecline == null)			var logOnDecline		= false; if (logOnDeclinePath == null)		var logOnDeclinePath	= ''; if (overwriteDeclineReasons == null)var overwriteDeclineReasons	= false; 		// whether to overwrite the in-build decline reasons with the user defined ones if (overwriteDeleteReasons == null)	var overwriteDeleteReasons	= false; 		// whether to overwrite the in-build delete reasons with the user defined ones if (myDeclineReasons == null)		var myDeclineReasons		= []; 	// any addition speedy deletion decline reasons to add to the list if (myDeclineListing == null)		var myDeclineListing		= '%REASON%' // the appearance of the option in the drop-down box if (myDeclineSummary == null)		var myDeclineSummary		= 'Proposed deletion %ACTION%. %REASON%';	// the summary to use when removing a deletion tag from a page because it has been declined or contested if (myDeclineSummarySpecial == null)var myDeclineSummarySpecial	= 'Proposed deletion %ACTION%. %REASON%';	// the summary to use when removing a deletion tag from a page IN A SEPCIAL CASE. NOTE: %CRITERION% will be blank!

// Top-level helpers function isPageTagged { return document.getElementById('delete-criterion') != null;//Any AfD or Prod or CSD has this span-ID, set to be not displayed. }

function shouldDisplayprodh { // Always exclude certain pages if (mw.config.get('wgNamespaceNumber') == 10 || 		document.getElementById('noarticletext') ||		document.getElementById('newarticletext')) {		return false; }

// Otherwise perform display checks return prodhDisplayAlways || isPageTagged; }

function launchprodh { if (shouldDisplayprodh) { // Launch controller. this.control = new prodH_controller; this.control.attachLinks; return true; } }

// Core function prodH_controller { prodHController 		= this; prodHController.deleteRegex = /[\s]*\{\{(?:db|speedy ?delet(?:e|ion)|speedy|d|rm|del(?:ete)? ?(?:because)?|prod|nn|[GARFCUTPX][0-9]{1,2})(?:-(?:.+?))?(?:\|(?:.+?))?\}\}[\s]*/gi; prodHController.hangonRegex = /[\s]*\{\{(?:hang|hold)(?: |-)?oo?n(?:\|.+?)?\}\}[\s]*/gi; prodHController.doNotifyDec = ''; prodHController.doNotifyDel = ''; prodHController.doNotifyPrd = '';

if (notifyByDefaultDec == true) prodHController.doNotifyDec = ' checked'; if (notifyByDefaultDel == true) prodHController.doNotifyDel = ' checked'; if (notifyByDefaultPrd == true) prodHController.doNotifyPrd = ' checked'; if (notifyByDefaultNew == true) prodHController.doNotifyNew = ' checked'; if (waUser.isSysop == true) { prodHController.isSysop = 'yes'; prodHController.decAction = 'declined'; } else { prodHController.isSysop = 'no'; prodHController.decAction = 'contested'; }

this.declineReasons = new Array(										['GNG', 		'Passes General Notability Guideline'],										); // Handle user defined content... // declining if (overwriteDeclineReasons == true) { this.declineReasons.length = 0; this.declineReasons = myDeclineReasons; } else { this.declineReasons = this.declineReasons.concat(myDeclineReasons); }

// append necessary options to decline reasons var declineReasonsEnd = new Array(									 	['INVALID', 		'The reason given is not a valid deletion criterion'],	// don't touch this										['DONTPROVIDE', 	'No reason given.'], 						// don't touch this										['OTHER', 			'Other - provide your own reason below']	// don't touch this									); this.declineReasons = this.declineReasons.concat(declineReasonsEnd); // GUI function getStandardElements { if (!(isPageTagged)) { return ''; }

let result = 'Decline Prod ' + '';		return result; }

function getCoreElements { let result = ' ' +				' Handle Speedy Deletion ' + ' What do you want to do to this page? ' +				' ' +					getStandardElements + ' ' +			' ';

return result; }

this.showprodHWindow = function { // grab position of button var offsetL = 0; var offsetT = 0; var thisObject = document.getElementById('ca-speedy');//What's this, for?! if (thisObject.offsetParent) { do { offsetL += thisObject.offsetLeft; offsetT += thisObject.offsetTop; } while (thisObject = thisObject.offsetParent); }		// build window to show user if (this.interface == null) { this.interface = new wa_window(document.getElementById('content')); this.visible = true; this.prodHelperLink.ele_obj.setAttribute('class', 'selected');

this.interface.win_content = getCoreElements; } else { this.interface.win_content = getCoreElements; if (this.visible == true) { this.prodHelperLink.ele_obj.setAttribute('class', ''); this.interface.win_disp = 'none'; this.interface.applyAll; this.visible = false; return true; } else { this.prodHelperLink.ele_obj.setAttribute('class', 'selected'); this.interface.win_disp = 'block'; this.interface.win_height = 170; this.interface.applyAll; this.visible = true; return true; }		}		if ( mw.config.get ( 'skin' ) == 'vector' ) { this.interface.win_left = offsetL - 17; this.interface.win_top = offsetT + 39; } else { this.interface.win_left = document.getElementById('ca-speedy').offsetLeft - 17; this.interface.win_top = -1; }		this.interface.win_width = 600; this.interface.win_height = 170; this.interface.win_bg = '#fff'; this.interface.win_bd = '#aaaaaa'; this.interface.win_bd_wd = 1; this.interface.applyAll; }	this.declinePage = function { // build the selection options var declineOptions = ''; var optionSelected = false; for (var i = 0; i < this.declineReasons.length; i++) { var selected = ''; // determine whether this option should be selected if (optionSelected == false) { if (document.getElementById('delete-criterion') != null) { // if this matches the criterion provided, select it. if (document.getElementById('delete-criterion').innerHTML == this.declineReasons[i][0]) { selected = ' selected '; optionSelected = true; } if ( (this.declineReasons[i][0] == 'INVALID') && (optionSelected == false) ) { selected = ' selected '; optionSelected = true; } } else { // if no criterion was selected, wait until 'other' is selected. if (this.declineReasons[i][0] == 'OTHER') { selected = ' selected '; optionSelected = true; } }			}			// build the visible message for use in the drop-down. var tempVisible = myDeclineListing.replace(/%CRITERION%/gi, this.declineReasons[i][0]); tempVisible = tempVisible.replace(/%REASON%/gi, this.declineReasons[i][1]); declineOptions += ''+tempVisible+' '; }		if ( mw.config.get ( 'skin' ) == 'vector' ) { var skinPos = '3'; } else { var skinPos = '10'; } this.interface.win_content = ''+ ' Decline Speedy Deletion '+ ' Select the reason for declining the deletion from the list. This text will be used as the edit summary. '+								''+declineOptions+' '+ ' Or provide your own reason and summary below. '+								''+ ' -- decline speedy deletion -- '+ 'notify tagger  '+ 'use newbie message  '+ ' '+								'';		this.interface.applyAll; }	this.declineDo = function(callback) { // get page content if (!callback) var callback = 0; switch (callback) { default: // main vars prodHController.declineText = 	document.getElementById('declineText').value; prodHController.declineSel = 	document.getElementById('declineReason').selectedIndex; prodHController.declineNotify = 	document.getElementById('notifyTagger').checked; prodHController.notifyNewbie = 	document.getElementById('notifyNewbie').checked; if ((prodHController.declineText == '') && (prodHController.declineSel == prodHController.declineReasons.length-1)) { // if no reason is typed, byt 'Other' is selected, use the 'No reason provided' option. prodHController.declineSel = prodHController.declineReasons.length - 2; }				prodHController.declineCategory 	= 	prodHController.declineReasons[prodHController.declineSel][0]; prodHController.declineReason 	=	prodHController.declineReasons[prodHController.declineSel][1]; // build all messages if ( (prodHController.declineCategory == 'INVALID') || (prodHController.declineCategory == 'DONTPROVIDE') ) { // if it's a 'special' case, use the 'special' summary var tempSummary = myDeclineSummarySpecial; tempSummary = tempSummary.replace(/%ACTION%/gi, prodHController.decAction); tempSummary = tempSummary.replace(/%REASON%/gi, prodHController.declineReason); prodHController.editSummary = tempSummary; } else if (prodHController.declineCategory == 'OTHER') { // if they've typed a reason, use that var tempSummary = myDeclineSummarySpecial; tempSummary = tempSummary.replace(/%ACTION%/gi, prodHController.decAction); tempSummary = tempSummary.replace(/%REASON%/gi, prodHController.declineText); prodHController.editSummary = tempSummary; } else { // otherwise, use the 'normal' summary var tempSummary = myDeclineSummary; tempSummary = tempSummary.replace(/%ACTION%/gi, prodHController.decAction); tempSummary = tempSummary.replace(/%CRITERION%/gi, prodHController.declineCategory); tempSummary = tempSummary.replace(/%REASON%/gi, prodHController.declineReason); prodHController.editSummary = tempSummary; }				prodHController.editSummary += ' (prodH)'; // start this.interface.win_content = ''+ ' Working... '+								' Please wait while prodHelper performs the requested operations. This can take several seconds. '+								' - Retrieving existing content... '+								' '+								'';				this.interface.applyAll; prodHController.pageReq = new wa_mediawikiApi; prodHController.pageReq.onCompleteAction = function { prodHController.declineDo('1'); }; prodHController.pageReq.getPage(mw.config.get('wgPageName'), notifyLimit, 'user|content'); break; case '1': document.getElementById('workingStatus').innerHTML += '- Removing tags... ';				prodHController.pageContent = prodHController.pageReq.data['page']['revisions'][0]['content']; var regReplace = prodHController.deleteRegex; prodHController.pageContent = prodHController.pageContent.replace(regReplace, ''); var regReplace = prodHController.hangonRegex; prodHController.pageContent = prodHController.pageContent.replace(regReplace, ''); prodHController.newContent = prodHController.pageContent; // grab a record of that document.getElementById('workingStatus').innerHTML += '- Updating page... ';				prodHController.editReq = new wa_mediawikiApi; prodHController.editReq.onCompleteAction = function { prodHController.declineDo('2'); }; prodHController.editReq.editPage(mw.config.get('wgPageName'), prodHController.newContent, prodHController.editSummary, false, 'text'); break; case '2': // check for notify if ( (prodHController.declineNotify == true) || (logOnDecline == true) ) { document.getElementById('workingStatus').innerHTML += '- Determining user who tagged page... ';					var tags = 0; prodHController.tagger = ''; var revisionCount = prodHController.pageReq.data['page']['revisions'].length; var limit = Math.min(notifyLimit, revisionCount); for (var i = 0; i < limit; i++) { var thisPage = prodHController.pageReq.data['page']['revisions'][i]['content']; // count tags var regTest = prodHController.deleteRegex; var k = 1; var count = 0; while (k != null) { k = regTest.exec(thisPage); if (k != null) count++; }						regTest.lastIndex = 0; // check if we have fewer than last time (1 was added on that rev) if (count < tags) { prodHController.tagger = prodHController.pageReq.data['page']['revisions'][i - 1]['user']; break; } else { tags = count; }					}					if (prodHController.tagger == '') { document.getElementById('workingStatus').innerHTML += '- Could not determine tagger: will not log or notify. Finished. '; break; } for (var i = 0; i < prodHController.notifyExempt.length; i++) { if (prodHController.tagger == prodHController.notifyExempt[i]) { document.getElementById('workingStatus').innerHTML += '- Tagger ('+prodHController.tagger+') is on the tagger exempt list, and will not be notified. Finished. ';							if (logOnDecline == true) { prodHController.declineNotify = false; prodHController.declineDo('3'); } else { return true; } }					}					if ( (logOnDecline == true) && (logOnDeclinePath != '') ) { prodHController.declineDo('3'); } else { prodHController.declineDo('5'); } } else { window.location.reload(true); prodHController.showprodHWindow; } break; case '3': // log decline action where relevant document.getElementById('workingStatus').innerHTML += '- Logging decline action to \''+logOnDeclinePath+'\' - retrieving page... ';				prodHController.pageReq = new wa_mediawikiApi; prodHController.pageReq.onCompleteAction = function { prodHController.declineDo('4'); }; prodHController.pageReq.getPage(logOnDeclinePath, 1, 'content'); break; case '4': // we have retrieved the data regarding the log page; move to edit it document.getElementById('workingStatus').innerHTML += 'modifying page... ';				//var logOnDeclinePath = logOnDeclinePath.replace(/ /g,'_'); // check whether there is existing content var pageData = prodHController.pageReq.data['page']; if (pageData['status'] == 'OK') { var oldContent = pageData['revisions'][0]['content']; if ( oldContent === '' ) oldContent = "{| class=\"sortable wikitable\" style=\"font-size: 80%;\" border=\"2\" cellpadding=\"1\" background:#f9f9f9;\"|\n|-\n! style=\"text-align: left\" | Article\n! Tagger\n! Criterion\n! Decline reason\n! Date\n|}";				} else {					var oldContent = "{| class=\"sortable wikitable\" style=\"font-size: 80%;\" border=\"2\" cellpadding=\"1\" background:#f9f9f9;\"|\n|-\n! style=\"text-align: left\" | Article\n! Tagger\n! Criterion\n! Decline reason\n! Date\n|}"; }				// message var pageName = mw.config.get('wgPageName').replace(/_/g, ' '); var reason = (prodHController.declineCategory == 'OTHER') ? prodHController.declineText : prodHController.declineReason; var crit = document.getElementById('delete-criterion').innerHTML; var message = "|-\n| " + pageName + " || " + prodHController.tagger + " || prod " + crit + " || " +reason + " || " + "" + "" + "~\n"; // add the new row to the table var newContent = oldContent.replace('|}', message + '|}'); // build vars var editSummary = 'Adding ' + pageName + ' to speedy decline log (prodH)'; // perform the edit prodHController.editReq = new wa_mediawikiApi; prodHController.editReq.onCompleteAction = function { prodHController.declineDo('5'); }; prodHController.editReq.editPage(logOnDeclinePath, newContent, editSummary, true, 'text'); break; case '5': // check notify if (prodHController.declineNotify != true) { window.location.reload(true); prodHController.showprodHWindow; break; } // output document.getElementById('workingStatus').innerHTML += '- Tagged by \''+prodHController.tagger+'\' - notifying user... ';				// edit summary prodHController.editSummary = 'Notifying about '+prodHController.decAction+' speedy deletion (prodH)'; // decide whether to use newbie message if (prodHController.notifyNewbie) { var useNewbie = 'yes'; } else { var useNewbie = 'no'; } // fix message - handle other special case if (prodHController.declineCategory == 'OTHER') prodHController.declineReason = prodHController.declineText; // fix message - handle punctuation at the end of the message (it must be added if absent). var p = prodHController.declineReason.substr(prodHController.declineReason.length - 1); if ( (p != '.') && (p != '!') && (p != '?') ) prodHController.declineReason += '.'; // message var message = '== Speedy deletion '+prodHController.decAction+': '+mw.config.get('wgPageName').replace(/_/g, ' ')+' =='+"\n"+' '+''; prodHController.saveReq = new wa_mediawikiApi; prodHController.saveReq.onCompleteAction = function { window.location.reload(true); prodHController.showprodHWindow; }; prodHController.saveReq.editPage('User_talk:'+prodHController.tagger, message, prodHController.editSummary, false, 'appendtext'); break; }	}	this.prodPage = function { var prodOptions = ''; var content = document.getElementById('bodyContent'); var regTest = /criteria for speedy deletion<\/a><\/i> because (.*?)\.<\/b> For valid criteria,/i var rationale = regTest.exec(content); if (rationale != null) { rationale = rationale[1]; } else { rationale = ''; } this.interface.win_content = ''+ ' Convert to PROD '+ ' You are asserting that the page cannot be speedy deleted, but can be deleted by proposed deletion. '+								'Enter the reason for deletion below - if the tagger provided one, it will be filled automatically. '+								''+ 'notify tagger of conversion  '+								'use newbie message  '+ ' -- convert to PROD</a> -- '+ ' '+								'';		this.interface.applyAll; }	this.prodDo = function(callback) { if (!callback) var callback = 0; switch (callback) { default: prodHController.prodReason = document.getElementById('prodReason').value; prodHController.prodNotify = document.getElementById('notifyTagger').checked; prodHController.notifyNewbie = document.getElementById('notifyNewbie').checked; this.interface.win_content = ''+ ' Working... '+								' Please wait while prodHelper performs the requested operations. This can take several seconds. '+								' '+								' '+								'';				this.interface.applyAll; if (prodHController.prodNotify == true) { document.getElementById('workingStatus').innerHTML += '- Searching for tagger... ';					if (notifyLimit > 15) notifyLimit = 15; prodHController.pageReq = new wa_mediawikiApi; prodHController.pageReq.onCompleteAction = function { prodHController.prodDo('1'); }; prodHController.pageReq.getPage(mw.config.get('wgPageName'), notifyLimit + 1, 'content|user'); } else { prodHController.pageReq = new wa_mediawikiApi; prodHController.pageReq.onCompleteAction = function { prodHController.prodDo('3'); }; prodHController.pageReq.getPage(mw.config.get('wgPageName'), 1, 'content|user'); }				break; case '1': var tags = 0; prodHController.tagger = ''; var revisionCount = prodHController.pageReq.data['page']['revisions'].length; var limit = Math.min(notifyLimit, revisionCount); for (var i = 0; i < limit; i++) { var thisPage = prodHController.pageReq.data['page']['revisions'][i]['content']; // count tags var regTest = prodHController.deleteRegex; var k = 1; var count = 0; while (k != null) { k = regTest.exec(thisPage); if (k != null) count ++; }					regTest.lastIndex = 0; // check if we have fewer than last time (1 was added on that rev) if (count < tags) { prodHController.tagger = prodHController.pageReq.data['page']['revisions'][i - 1]['user']; break; } else { tags = count; }				}				if (prodHController.tagger == '') { document.getElementById('workingStatus').innerHTML += '- Could not determine tagger. Moving to tag page... '; prodHController.prodDo('3'); break; } for (var i = 0; i < prodHController.notifyExempt.length; i ++) { if (prodHController.tagger == prodHController.notifyExempt[i]) { document.getElementById('workingStatus').innerHTML += '- Tagger ('+prodHController.tagger+') is on the tagger exempt list, and will not be notified. Moving to tag page... ';						prodHController.prodDo('3'); return true; }				}				prodHController.prodDo('2'); break; case '2': // notify tagger document.getElementById('workingStatus').innerHTML += '- Tagged by \''+prodHController.tagger+'\' - notifying user... ';				// edit summary prodHController.editSummary = 'Notifying about speedy deletion converted to PROD (prodH)'; // decide whether to use newbie message if (prodHController.notifyNewbie) { var useNewbie = 'yes'; } else { var useNewbie = 'no'; } // message var message = '== Speedy deletion converted to PROD: '+mw.config.get('wgPageName').replace(/_/g, ' ')+' =='+"\n"+' '+''; prodHController.notifyReq = new wa_mediawikiApi; prodHController.notifyReq.onCompleteAction = function { prodHController.prodDo('3'); }; prodHController.notifyReq.editPage('User_talk:'+prodHController.tagger, message, prodHController.editSummary, false, 'appendtext'); break; case '3': document.getElementById('workingStatus').innerHTML += '- Converting tags... ';				prodHController.pageContent = prodHController.pageReq.data['page']['revisions'][0]['content']; var regReplace = prodHController.deleteRegex; prodHController.pageContent = prodHController.pageContent.replace(regReplace, ''); var regReplace = prodHController.hangonRegex; prodHController.pageContent = prodHController.pageContent.replace(regReplace, ''); if (prodHController.prodReason != 'nn') { prodHController.pageContent = '{'+'{subst:prod|'+prodHController.prodReason+'}'+'}\n' + prodHController.pageContent; } else { prodHController.pageContent = '{'+'{subst:prod-nn}'+'}\n' + prodHController.pageContent; } prodHController.newContent = prodHController.pageContent; // grab a record of that prodHController.editSummary = 'Speedy deletion converted to PROD (prodH)'; document.getElementById('workingStatus').innerHTML += '- Updating page... ';				prodHController.editReq = new wa_mediawikiApi; prodHController.editReq.onCompleteAction = function { window.location.reload(true); prodHController.showprodHWindow; }; prodHController.editReq.editPage(mw.config.get('wgPageName'), prodHController.newContent, prodHController.editSummary, false, 'text'); break; }	}	this.deletePage = function { // build the selection options var deleteOptions = ''; var optionSelected = false; for (var i = 0; i < this.deleteReasons.length; i++) { var selected = ''; if ( (document.getElementById('delete-criterion') != null) && (optionSelected == false) ) { if (document.getElementById('delete-criterion').innerHTML == this.deleteReasons[i][0]) { prodHController.initialRationale = this.deleteReasons[i][0]; selected = ' selected'; optionSelected = true; } } else { if (this.deleteReasons[i][0] == 'N/A') { selected = ' selected '; optionSelected = true; } }			// general var visibleReasoning = this.deleteReasons[i][1].replace(/\[\[(?:.*?\|)(.+?)\]\]/g, '$1'); deleteOptions += '<option value="'+i+'"'+selected+'>'+this.deleteReasons[i][0]+': '+visibleReasoning+' '; }		if (document.getElementById('delete-criterion') == null) { var displayTagCommand = 'display: none;'; } else { var displayTagCommand = 'display: block;'; } this.interface.win_content = ''+ ' Perform Speedy Deletion '+ ' Select the reason for deletion from the list. The rationale specified by the tagger is automatically selected. If you select a reason that does not '+ 'match the tag, will be given the option of notifying the tagger. '+								'<select id="deleteReason" style="font-size: 11px; margin-left: 9px; width: 576px;" onchange="'+									'if (document.getElementById(\'delete-criterion\') != null) {'+										'if (prodHController.deleteReasons[document.getElementById(\'deleteReason\').selectedIndex][0] != document.getElementById(\'delete-criterion\').innerHTML) { '+											'if (prodHController.deleteReasons[document.getElementById(\'deleteReason\').selectedIndex][0] == \'N/A\') { document.getElementById(\'notifyTaggerDiv\').style.display = \'none\'; } else { document.getElementById(\'notifyTaggerDiv\').style.display = \'block\'; }'+										'} else {'+											'document.getElementById(\'notifyTaggerDiv\').style.display = \'none\'; '+										'}'+									'} else { document.getElementById(\'notifyTaggerDiv\').style.display = \'none\'; }'+									'if (prodHController.deleteReasons[document.getElementById(\'deleteReason\').selectedIndex][0] == \'N/A\') {'+ 'document.getElementById(\'performDeletionDiv\').style.display = \'none\'; '+ '} else {'+ 'document.getElementById(\'performDeletionDiv\').style.display = \'block\'; '+ '}'+								'">'+deleteOptions+' '+								'<div id="notifyTaggerDiv" style="display: none; margin-top: 10px; font-size: 11px; margin-left: 20px; float: left; vertical-align: middle;">notify tagger of rationale change <input id="notifyTagger"'+prodHController.doNotifyDel+' style="position: relative; top: 3px; " type="checkbox" /> '+								'use newbie message <input id="notifyNewbie"'+prodHController.doNotifyNew+' style="position: relative; top: 3px; " type="checkbox" /> '+								'<div id="performDeletionDiv" style="margin: auto; margin-top: 13px; font-size: 11px; width: 200px; text-align: center; '+displayTagCommand+'">-- <a href="#" onclick="prodHController.deleteDo;">perform speedy deletion</a> -- '+								' '+								'';		this.interface.applyAll;	}	this.deleteDo = function(callback) {		if (!callback) var callback = 0;		switch (callback) {			default:				prodHController.deleteSel 		= document.getElementById('deleteReason').selectedIndex; prodHController.deleteNotify 	= document.getElementById('notifyTagger').checked; prodHController.notifyNewbie		= document.getElementById('notifyNewbie').checked; if (document.getElementById('delete-criterion') == null) { prodHController.allowDelNotify = false; } else { prodHController.allowDelNotify = (prodHController.deleteReasons[prodHController.deleteSel][0] != document.getElementById('delete-criterion').innerHTML); } this.interface.win_content = ''+ ' Working... '+								' Please wait while prodHelper performs the requested operations. This can take several seconds. '+								' '+								' '+								'';				this.interface.applyAll; if ((prodHController.deleteNotify == true) && (prodHController.allowDelNotify == true)) { document.getElementById('workingStatus').innerHTML += '- Searching for tagger... ';					if (notifyLimit > 15) notifyLimit = 15; prodHController.pageReq = new wa_mediawikiApi; prodHController.pageReq.onCompleteAction = function { prodHController.deleteDo('1'); }; prodHController.pageReq.getPage(mw.config.get('wgPageName'), notifyLimit + 1, 'content|user'); } else { prodHController.deleteDo('3'); } break; case '1': var tags = 0; prodHController.tagger = ''; var revisionCount = prodHController.pageReq.data['page']['revisions'].length; var limit = Math.min(notifyLimit, revisionCount); for (var i = 0; i < limit; i++) { var thisPage = prodHController.pageReq.data['page']['revisions'][i]['content']; // count tags var regTest = prodHController.deleteRegex; var k = 1; var count = 0; while (k != null) { k = regTest.exec(thisPage); if (k != null) count ++; }					regTest.lastIndex = 0; // check if we have fewer than last time (1 was added on that rev) if (count < tags) { prodHController.tagger = prodHController.pageReq.data['page']['revisions'][i - 1]['user']; break; } else { tags = count; }				}				if (prodHController.tagger == '') { document.getElementById('workingStatus').innerHTML += '- Could not determine tagger. Moving to deletion... '; prodHController.deleteDo('3'); break; } for (var i = 0; i < prodHController.notifyExempt.length; i ++) { if (prodHController.tagger == prodHController.notifyExempt[i]) { document.getElementById('workingStatus').innerHTML += '- Tagger ('+prodHController.tagger+') is on the tagger exempt list, and will not be notified. Moving to deletion... ';						prodHController.deleteDo('3'); return true; }				}				prodHController.deleteDo('2'); break; case '2': // notify tagger document.getElementById('workingStatus').innerHTML += '- Tagged by \''+prodHController.tagger+'\' - notifying user... ';				// edit summary prodHController.editSummary = 'Notifying about altered speedy deletion rationale (prodH)'; // decide whether to use newbie message if (prodHController.notifyNewbie) { var useNewbie = 'yes'; } else { var useNewbie = 'no'; } // message var message = '== Altered speedy deletion rationale: '+mw.config.get('wgPageName').replace(/_/g, ' ')+' =='+"\n"+' '+''; prodHController.notifyReq = new wa_mediawikiApi; prodHController.notifyReq.onCompleteAction = function { prodHController.deleteDo('3'); }; prodHController.notifyReq.editPage('User_talk:'+prodHController.tagger, message, prodHController.editSummary, false, 'appendtext'); break; case '3': // perform the edit document.getElementById('workingStatus').innerHTML += '- Deleting page... ';				var deleteReason = ''+prodHController.deleteReasons[prodHController.deleteSel][0]+': ' + prodHController.deleteReasons[prodHController.deleteSel][1] + ' (prodH)'; prodHController.deleteReq = new wa_mediawikiApi; prodHController.deleteReq.onCompleteAction = function(callback) { if ((callback == null) || (callback == false) || (mw.config.get('wgNamespaceNumber') != 0)) { // No talk page if (prodhDoRedirect) { window.location = redirectAfterDel; } else { window.location.reload(true); }						prodHController.showprodHWindow; } else { // Talk page exists prodHController.talkpageId = callback; document.getElementById('workingStatus').innerHTML = ''+ ' Warning: this page now has an orphaned talk page. Do you wish to delete it under G8?

'+							' <a href="#" onclick="document.getElementById(\'workingStatus\').innerHTML = \'- Deleting talk page... \'; prodHController.deleteDo(\'4\');">Delete</a> | <a href="#" onclick="window.location = redirectAfterDel; prodHController.showprodHWindow; ">Ignore</a> '+ '';					}				};				prodHController.deleteReq.performAction('delete', mw.config.get('wgPageName'), deleteReason); break; case '4': // delete the talk page - get the title var talkPage = 'Talk:' + mw.config.get('wgPageName'); prodHController.deleteReq = new wa_mediawikiApi; prodHController.deleteReq.onCompleteAction = function { window.location = redirectAfterDel; prodHController.showprodHWindow; }; prodHController.deleteReq.performAction('delete', talkPage, 'G8: Talk page of deleted page. (prodH)'); break; }	}	this.displayError = function { this.interface.win_content = ''+ ' An error occurred... '+								' '+								'';		this.interface.applyAll; }	this.attachLinks = function { this.prodHelperLink 						= new wa_element('li'); this.prodHelperLink.ele_obj.id			= 'ca-speedy'; this.prodHelperLink.addScriptEvent('click', function { prodHController.showprodHWindow; }); if ( mw.config.get ( 'skin' ) == 'vector' ) { this.prodHelperLink.ele_obj.innerHTML	= ' <a href="#" title="handle speedy deletion">Speedy</a> '; this.prodHelperLink.attach(document.getElementById('ca-talk'), 'after'); } else { this.prodHelperLink.ele_obj.innerHTML	= '<a href="#" title="handle speedy deletion">speedy</a>'; this.prodHelperLink.attach(document.getElementById('ca-move'), 'before'); }	}; }

// -- run program function launchprodHelper { // lib proto wa_window.prototype = new wa_document; wa_element.prototype = new wa_document; // run launchprodh; }

$.getScript("https://en.wikipedia.org/w/index.php?title=User:Ale_jrb/Scripts/waLib.js&type=text/javascript&action=raw", function {	$(document).ready(launchprodHelper); });