User:Glen/monobook/deleting.js

//

//Auto AFD Lister-- // This needs to change depending on skin used.

function strip_namespace(target) { var colon = target.indexOf(':'); if (colon != -1) {     var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category'); var ns = target.substring(0, colon); if (ns == '' || ns == 'Talk') return target.substring(colon + 1); else for (var i = 0; i < spaces.length; ++i) {           if (ns == spaces[i]                || ns == spaces[i] + '_talk') return target.substring(colon + 1); }   }

return target; }

function prod { var reason = prompt('Reason:'); document.editform.wpTextbox1.value = '' + reason + '\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'This page has been proposed for deletion and will be deleted in 5 days if no one objects.'; }

function vfd { document.editform.wpTextbox1.value = '\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'afd';

var target = document.title.split('Editing ')[1].split(' - ')[0];

var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date; date = date.getUTCFullYear + '_' + months[date.getUTCMonth] + '_' + date.getUTCDate;

var pagename = strip_namespace(target);

window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/' + URLEncoding(pagename) + '&action=edit&fakeaction=vfdsub&faketarget=' + URLEncoding(target),             'Afd ' + target,              'status,toolbar,location,menubar,directories,resizeable,scrollbars'); window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/Log/' + date + '&action=edit&fakeaction=vfdlist&faketarget=' + URLEncoding(pagename),             'AfdLog ' + target,              'status,toolbar,location,menubar,directories,resizeable,scrollbars'); }

function autovfd { if (document.title.indexOf('Editing ') == 0) {     var action = ''; var target = ''; if (location.search) {         var l = location.search.substring(1).split('&'); for (var i = 0; i < l.length; ++i) {             var eq = l[i].indexOf('='); var name = l[i].substring(0, eq); if (name == 'fakeaction') action = l[i].substring(eq + 1); else if (name == 'faketarget') target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' '); }       }

if (action == 'vfdlist') {         document.editform.wpTextbox1.value += '\n'; document.editform.wpSummary.value = 'Articles for deletion/' + target + ''; }     else if (action == 'vfdsub') {         if (document.editform.wpTextbox1.value.length > 0) {             window.alert("There's an old afd at the default location already.\n\n" +                           'Please either move it out of the way (and update existing links to it), or file the afd by hand in another location (such as ' + target + ' (2)).'); }         else document.editform.wpTextbox1.value += '===' + target + '===\n' + '\n\n' + ':\n' + 'Reason for nom ' + '\n*\n*\n*\n'; }     else ;   } } //END

//AFD Closer //this helps automate AfD closing by adding a 'close' tab to AfD debates //written by User:Johnleemk based on WikiProject User scripts/Scripts/test-n.js by User:Celestianpower

function result { var close = prompt("Result of debate?") var f = document.editform, t = f.wpTextbox1; t.value = " " + close + ". " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value; if (t.value.length > 0) t.value += '\n'; t.value += ""; f.wpSummary.value = "Closing debate; result was " + close; }

function relist { var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += "~" + "~" + "~" + "~"; f.wpSummary.value = "Relisting debate"; }

function keep { var date = prompt("Nomination was made when?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1;

// If default votepage... if (votepage=="d") {       var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; }

t.value = "" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD"; }

function tagnote(string) { if (!string){return;} var f = document.editform, t = f.wpTextbox1; t.value = "" + "\n" + t.value; f.wpSummary.value = "Tagged: " + string; document.getElementById('wpMinoredit').checked=true; }

function no_consensus { var date = prompt("Nomination was made when?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1;

// If default votepage... if (votepage=="d") {       var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; }

t.value = "" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD with no consensus"; }

function redirect { var date = prompt("Nomination was made when?") var redirect = prompt("Redirect to?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1;

// If default votepage... if (votepage=="d") {       var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; }

t.value = "" + '\n' + '\n' + t.value; f.wpSummary.value = "Article redirected to " + redirect + " as per AfD"; }

function merge { var date = prompt("Nomination was made when?") var redirect = prompt("Merge and redirect to?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1;

// If default votepage... if (votepage=="d") {       var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; }

t.value = "" + '\n' + '\n' + t.value; f.wpSummary.value = "Article merged and redirected to " + redirect + " as per AfD"; }

function other { var date = prompt("Nomination was made when?") var result = prompt("Result was?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1;

// If default votepage... if (votepage=="d") {       var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; }

t.value = "" + '\n' + '\n' + t.value; f.wpSummary.value = "AfDed; result was " + result; } $(add_afd_tabs) function add_afd_tabs { var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

// Only add for pages with the right string somewhere in the title if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1) {     addTab("javascript:result","close", "ca-afdcl", "Close AfD", ""); addTab("javascript:relist","relist", "ca-afdrl", "Re-list AfD", ""); } if (document.title.indexOf("Editing Talk:") != -1) {     var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlimenu(tabs, '(AfD)', 'afdtfunc'); var afdtfun = document.getElementById('afdtfunc').getElementsByTagName('ul')[0]; addlilink(afdtfun, 'javascript:keep',"K", ''); addlilink(afdtfun, 'javascript:no_consensus','NC', ''); addlilink(afdtfun, 'javascript:redirect',"R", ''); addlilink(afdtfun, 'javascript:merge',"M", ''); if(document.getElementById('ca-delete')) {       document.getElementById('ca-delete').firstChild.innerHTML = ' [d] '; }       if(document.getElementById('ca-move')) {     document.getElementById('ca-move').firstChild.innerHTML = '[m]'; }      if(document.getElementById('ca-watch')) {     document.getElementById('ca-watch').firstChild.innerHTML = '[w]'; }       if(document.getElementById('ca-unwatch')) {     document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]'; }   } } //END

function autocopyvio { if (document.title.indexOf('Editing ') == 0) {     var action = ''; var target = ''; if (location.search) {         var l = location.search.substring(1).split('&'); for (var i = 0; i < l.length; ++i) {             var eq = l[i].indexOf('='); var name = l[i].substring(0, eq); if (name == 'fakeaction') action = l[i].substring(eq + 1); else if (name == 'faketarget') target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' '); }       }

if (action == 'copyviolist') { //         var index = document.editform.wpTextbox1.value.lastIndexOf("\n==Footer=="); /*           if (index == -1) {           window.alert("Couldn't find footer\n\n"); }          else { */ //           var firsthalf = document.editform.wpTextbox1.value.substr(0,index); //           var secondhalf = document.editform.wpTextbox1.value.substr(index); document.editform.wpTextbox1.value += '*' + target + ' (history &middot; last edit) ' + ' from [' + '] ~' + '' + '~'; document.editform.wpSummary.value = 'Copyvio ' +  + target + ; } //       }    } }

function copyvio { document.editform.wpTextbox1.value = '{' + '{' + 'copyvio|url=}}'; document.editform.wpSummary.value = 'copyvio';

var target = document.editform.action; target = target.substring(target.indexOf('title=') + 6,                           target.lastIndexOf('&action=submit'));

var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date; // date = months[date.getUTCMonth] + '_' + date.getUTCDate; var datestring = date.getUTCFullYear + '_' + months[date.getUTCMonth] + '_' + date.getUTCDate;

var pagename = strip_namespace(target);

window.open('/w/index.php?title=Wikipedia:Copyright_problems/' + datestring + '/Articles' + '&action=edit&fakeaction=copyviolist&faketarget=' + pagename,             'status,toolbar,location,menubar,directories,resizeable,scrollbars'); } //END

$(createtabs) function createtabs { if (document.title.search(/Editing Wikipedia:Articles for creation\/.+ \(section\)/) ==0) { addTab("javascript:AfCresult(0)","acc", "ca-afc1", "Close AfC", ""); addTab("javascript:AfCresult(1)","rej", "ca-afc2", "Close AfC", ""); } }

function AfCresult(type) { if (type==0) var add = 'accept'; else var add = ''; var txt = document.editform.wpTextbox1.value; if (txt.search('==\n') !=-1) { document.editform.wpTextbox1.value = txt.substring(0,txt.indexOf('==\n')) + '==\n' + add + '\n' + txt.substring(txt.indexOf('==\n') + 4); } else { document.editform.wpTextbox1.value = add + '\n' + document.editform.wpTextbox1.value; } txt = document.editform.wpTextbox1.value; if (txt.indexOf('') !=-1) { document.editform.wpTextbox1.value = txt.split('')[0] + '\n' + '\n'; } else { document.editform.wpTextbox1.value += '\n'; } }

$(deltabs) function deltabs { if (document.title.indexOf('Editing ') == -1 || document.title.indexOf('User:') != -1 || document.title.indexOf(' talk:') != -1 || document.title.indexOf('MediaWiki:') != -1 || document.title.indexOf('Portal:') != -1 || document.title.indexOf('Help:') != -1 || document.title.indexOf('Wikipedia:') != -1 || document.title.indexOf('Image:') != -1 || document.title.indexOf('Template:') != -1 || document.title.indexOf('Category:') != -1){return;} var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlimenu(tabs, '', 'delfunc'); var delfunc = document.getElementById('delfunc').getElementsByTagName('ul')[0]; addlilink(delfunc, 'javascript:tagnote("WPBiography|living=yes")', 'BLP', ''); addlilink(delfunc, 'javascript:tagnote("cleanup")', 'Clean', ''); addlilink(delfunc, 'javascript:tagnote("tone")', 'Tone', ''); addlilink(delfunc, 'javascript:tagnote("verify")', 'Verify', ''); addlilink(delfunc, 'javascript:tagnote("unreferenced")', 'Cite', ''); addlilink(delfunc, 'javascript:tagnote("POV-check")', 'POV', ''); addlilink(delfunc, 'javascript:tagnote("accuracy")', 'Acc.', ''); addlilink(delfunc, 'javascript:tagnote("advert")', 'Adv.', ''); addlilink(delfunc, 'javascript:prod', 'PfD', ''); addlilink(delfunc, 'javascript:vfd', 'AfD', ''); addlilink(delfunc, 'javascript:copyvio', 'c-vio', ''); }

if (window.addEventListener) window.addEventListener('load', autovfd, false); else if (window.attachEvent) window.attachEvent('onload', autovfd);

$(morelinks);

/*** Make old AfD's appear or disappear - from AmiDaniel's monobook ***/

function hideafd {	var divs = document.getElementsByTagName("div"); for(var x = 0; x < divs.length; ++x) if(divs[x].className.indexOf("vfd") != -1) divs[x].style.display = "none"; document.getElementById('footer').style.display = 'none'; } function showafd {	var divs = document.getElementsByTagName("div"); for(var x = 0; x < divs.length; ++x) if(divs[x].className.indexOf("vfd") != -1) divs[x].style.display = ""; document.getElementById('footer').style.display = ''; }

function morelinks { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(document.title.indexOf("Wikipedia:Articles for deletion") == 0 && location.href.indexOf('&action=') == -1) {		addlilink(tabs, 'javascript:hideafd', 'hide closed', 'ca-hide'); ta['ca-hide'] = ['', 'Hide closed AFDs']; addlilink(tabs, 'javascript:showafd', 'show closed', 'ca-show'); ta['ca-show'] = ['', 'Show closed AFDs']; } }

// end AfD closing script