User:Liangent/Gadgets/Toolkit/afd.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// '''Compressed version''' // [[User:Liangent/Gadgets/Toolkit/afd.uncompressed.js|Uncompressed version]] //
require(['jquery','jqueryui','mediawiki'],function(){(function($){if(wgNamespaceNumber==6||wgArticleId==0)return;$(function(){$('#p-tb ul').append('<li id="t-afd">'+'<a title="Nominate this page for deletion" href="#">Nominate for deletion</a></li>').find('#t-afd a').click(function(event){event.preventDefault();$('#afd-options').remove();$('<div id="afd-options" title="Nominating for deletion">'+'<div id="afd-options-type-div"><label for="afd-options-type">Type:</label> '+'<select id="afd-options-type">'+'<option value="delete" selected="selected">Delete</option>'+'<option value="merge">Merge</option>'+'<option value="vm">Move (to another Wikimedia project)</option>'+'</select></div>'+'<div id="afd-options-to-div"><span id="afd-options-to-page-span">'+'<label for="afd-options-to-page">To:</label> '+'<input id="afd-options-to-page" /></span>'+'<span id="afd-options-to-project-span"><label for="afd-options-to-project">To:</label> '+'<select id="afd-options-to-project">'+'<option value="vmd" selected="selected">Wiktionary</option>'+'<option value="vms">Wikisource</option>'+'<option value="vmb">Wikibooks</option>'+'<option value="vmq">Wikiquote</option>'+'</select></span></div>'+'<div id="afd-options-reason-div"><label for="afd-options-reason">Reason:</label></div>'+'<textarea id="afd-options-reason"></textarea>'+'<div id="afd-messages"></div></div>').dialog({buttons:{'Nominate':function(){$('#afd-messages').empty();var page=new MediaWiki.Page();$('#afd-messages').append('<div id="afd-messages-patrolling">Patrolling ... </div>');page.patrol({},function(){$('#afd-messages-patrolling').append('Done');},function(){$('#afd-messages-patrolling').append('Failed');});$('#afd-messages').append('<div id="afd-messages-getting-time">Getting time ... </div>');MediaWiki.currentTime({},function(date){$('#afd-messages-getting-time').append('Done');function twodigits(num){return num<10?'0'+num:num;}
var afdpagename='Wikipedia:頁面存廢討論/記錄/'+
date.getUTCFullYear()+'/'+twodigits(date.getUTCMonth()+1)+'/'+twodigits(date.getUTCDate());$('#afd-messages').append('<div id="afd-messages-nominating">Nominating page ... </div>');var afdpage=new MediaWiki.Page(afdpagename);var afdtext='{\{subst:DRItem|Type='+$('#afd-options-type').attr('value')+'|DRarticles='+wgPageName.replace(/_/g,' ')+'|Reason='+$('#afd-options-reason').attr('value')+'|To='+($('#afd-options-type').attr('value')=='vm'?$('#afd-options-to-project').attr('value'):$('#afd-options-to-page').attr('value'))+'}}~~\~~';afdpage.newSection({text:afdtext},function(){$('#afd-messages-nominating').append('Done');},function(){$('#afd-messages-nominating').append('Failed');});$('#afd-messages').append('<div id="afd-messages-tagging">Tagging page ... Checking for redirect ... </div>');page.redirect({},function(r){var isredir=(r!=undefined);if(isredir){$('#afd-messages-tagging').append('Yes ... Loading text ... ');}else{$('#afd-messages-tagging').append('No ... Loading text ... ');}
page.text({},function(text){$('#afd-messages-tagging').append('Done ... Tagging ... ');if(isredir&&$('#afd-options-type').attr('value')!='vm'){text='{\{subst:vfd/auto|'+$('#afd-options-reason').attr('value')+'|r}}\n'+text;}else if($('#afd-options-type').attr('value')=='vm'){text='{\{subst:vfd/auto|'+$('#afd-options-reason').attr('value')+'|'+
{'vmd':'wikt','vms':'s','vmb':'b','vmq':'q'}
[$('#afd-options-to-project').attr('value')]+'}}\n'+text;}else{text='{\{subst:vfd/auto|'+$('#afd-options-reason').attr('value')+'}}\n'+text;}
page.text({text:text,summary:'[[Wikipedia:DP|Deletion]]: Nominating for deletion ([['+
afdpagename+'#'+wgPageName.replace(/_/g,' ')+'|discussion]])'},function(){$('#afd-messages-tagging').append('Done');},function(){$('#afd-messages-tagging').append('Failed');});},function(){$('#afd-messages-tagging').append('Failed');});},function(){$('#afd-messages-tagging').append('Failed');});},function(){$('#afd-messages-getting-time').append('Failed');});}}});$('#afd-options-to-page-span, #afd-options-to-project-span').hide();$('#afd-options-type').change(function(){if(this.value=='merge'){$('#afd-options-to-project-span').hide();$('#afd-options-to-page-span').show();}else if(this.value=='vm'){$('#afd-options-to-page-span').hide();$('#afd-options-to-project-span').show();}else{$('#afd-options-to-page-span, #afd-options-to-project-span').hide();}});});});})(jQuery);});