跳转到内容

User:Wetittwinkle/modules/twinklexfd.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// <nowiki>
(function($){Twinkle.xfd=function twinklexfd(){if(mw.config.get('wgNamespaceNumber')<0||mw.config.get('wgPageContentModel')==='flow-board'||!mw.config.get('wgArticleId')||(mw.config.get('wgNamespaceNumber')===6&&(document.getElementById('mw-sharedupload')||(!document.getElementById('mw-imagepage-section-filehistory')&&!Morebits.wiki.isPageRedirect())))){return;}
Twinkle.addPortletLink(Twinkle.xfd.callback,wgULS("提删","提刪"),"tw-xfd",wgULS("提交删除讨论","提交刪除討論"));var date=new Date();if(date.getUTCMonth()===3&&date.getUTCDate()===1){Twinkle.addPortletLink(Twinkle.xfd.aprilfool,wgULS("愚人节提删","愚人節提刪"),"tw-xfd-april-fool",wgULS("愚人节提删","愚人節提刪"));}};Twinkle.xfd.currentRationale=null;Twinkle.xfd.printRationale=function twinklexfdPrintRationale(){if(Twinkle.xfd.currentRationale){Morebits.status.printUserText(Twinkle.xfd.currentRationale,wgULS("您的理由已在下方提供,如果您想重新提交,请将其复制到一新窗口中:","您的理由已在下方提供,如果您想重新提交,請將其複製到一新窗口中:"));Twinkle.xfd.currentRationale=null;}};Twinkle.xfd.callback=function twinklexfdCallback(){var Window=new Morebits.simpleWindow(600,350);Window.setTitle(wgULS("提交存废讨论","提交存廢討論"));Window.setScriptName("Twinkle");Window.addFooterLink(wgULS("关于存废讨论","關於存廢討論"),"WP:XFD");Window.addFooterLink(wgULS("Twinkle帮助","Twinkle說明"),"WP:TW/DOC#xfd");var form=new Morebits.quickForm(Twinkle.xfd.callback.evaluate);var categories=form.append({type:'select',name:'category',label:wgULS('提交类型:','提交類別:'),event:Twinkle.xfd.callback.change_category});categories.append({type:'option',label:wgULS('页面存废讨论','頁面存廢討論'),selected:mw.config.get('wgNamespaceNumber')===0,value:'afd'});categories.append({type:'option',label:wgULS('文件存废讨论','檔案存廢討論'),selected:mw.config.get('wgNamespaceNumber')===6,value:'ffd'});form.append({type:'checkbox',list:[{label:wgULS('如可能,通知页面创建者','如可能,通知頁面建立者'),value:'notify',name:'notify',tooltip:wgULS("在页面创建者对话页上放置一通知模板。","在頁面建立者對話頁上放置一通知模板。"),checked:true}]});form.append({type:'field',label:'工作区',name:'work_area'});form.append({type:'submit'});var result=form.render();Window.setContent(result);Window.display();var evt=document.createEvent("Event");evt.initEvent('change',true,true);result.category.dispatchEvent(evt);};Twinkle.xfd.previousNotify=true;Twinkle.xfd.callback.change_category=function twinklexfdCallbackChangeCategory(e){var value=e.target.value;var form=e.target.form;var old_area=Morebits.quickForm.getElements(e.target.form,"work_area")[0];var work_area=null;var oldreasontextbox=form.getElementsByTagName('textarea')[0];var oldreason=(oldreasontextbox?oldreasontextbox.value:'');var appendReasonBox=function twinklexfdAppendReasonBox(xfd_cat){switch(xfd_cat){case'fwdcsd':oldreason=decodeURIComponent($("#delete-reason").text()).replace(/\+/g,' ');break;case'fame':oldreason=Twinkle.getPref('afdFameDefaultReason');break;case'substub':oldreason=Twinkle.getPref('afdSubstubDefaultReason');break;}
work_area.append({type:'textarea',name:'xfdreason',label:wgULS('提删理由:','提刪理由:'),value:oldreason,tooltip:wgULS('您可以使用维基格式,Twinkle将自动为您加入签名。如果您使用批量提删功能,存废讨论页只会使用第一次提交的理由,但您仍需在之后提供以用于删除通告模板的参数。','您可以使用維基格式,Twinkle將自動為您加入簽名。如果您使用批量提刪功能,存廢討論頁只會使用第一次提交的理由,但您仍需在之後提供以用於刪除通告模板的參數。'),placeholder:wgULS('此值亦显示于页面的删除通告模板内,故务必提供此值,避免使用“同上”等用语。','此值亦顯示於頁面的刪除通告模板內,故務必提供此值,避免使用「同上」等用語。')});};switch(value){case'afd':work_area=new Morebits.quickForm.element({type:'field',label:wgULS('页面存废讨论','頁面存廢討論'),name:'work_area'});work_area.append({type:'checkbox',list:[{label:'使用<noinclude>包裹模板',value:'noinclude',name:'noinclude',checked:mw.config.get('wgNamespaceNumber')===10&&mw.config.get('wgPageContentModel')!=='Scribunto',tooltip:wgULS('使其不会在被包含时出现。','使其不會在被包含時出現。'),disabled:mw.config.get('wgPageContentModel')==='Scribunto',}]});var afd_category=work_area.append({type:'select',name:'xfdcat',label:wgULS('选择提删类别:','選擇提刪類別:'),event:Twinkle.xfd.callback.change_afd_category});var afd_cat='delete';if(Twinkle.getPref('afdDefaultCategory')==='same'){if(localStorage['Twinkle_afdCategory']===undefined){localStorage['Twinkle_afdCategory']='delete';}else{afd_cat=localStorage['Twinkle_afdCategory'];}}
afd_category.append({type:'option',label:wgULS('删除','刪除'),value:'delete',selected:(afd_cat==='delete')});afd_category.append({type:'option',label:wgULS('合并','合併'),value:'merge',selected:(afd_cat==='merge')});afd_category.append({type:'option',label:wgULS('移动到维基词典','移動到維基詞典'),value:'vmd',selected:(afd_cat==='vmd')});afd_category.append({type:'option',label:wgULS('移动到维基文库','移動到維基文庫'),value:'vms',selected:(afd_cat==='vms')});afd_category.append({type:'option',label:wgULS('移动到维基教科书','移動到維基教科書'),value:'vmb',selected:(afd_cat==='vmb')});afd_category.append({type:'option',label:wgULS('移动到维基语录','移動到維基語錄'),value:'vmq',selected:(afd_cat==='vmq')});afd_category.append({type:'option',label:wgULS('移动到维基导游','移動到維基導遊'),value:'vmvoy',selected:(afd_cat==='vmvoy')});afd_category.append({type:'option',label:wgULS('移动到维基学院','移動到維基學院'),value:'vmv',selected:(afd_cat==='vmv')});if(Twinkle.getPref('FwdCsdToXfd')){afd_category.append({type:'option',label:wgULS('转交自快速删除候选','轉交自快速刪除候選'),value:'fwdcsd',selected:(afd_cat==='fwdcsd')});}
afd_category.append({type:'option',label:wgULS('批量关注度提删','批量關注度提刪'),value:'fame',selected:(afd_cat==='fame')});afd_category.append({type:'option',label:wgULS('批量小小作品提删','批量小小作品提刪'),value:'substub',selected:(afd_cat==='substub')});afd_category.append({type:'option',label:wgULS('批量其他提删','批量其他提刪'),value:'batch',selected:(afd_cat==='batch')});work_area.append({type:'input',name:'mergeinto',label:wgULS('合并到:','合併到:'),hidden:true});appendReasonBox(afd_cat);work_area.append({type:'textarea',name:'fwdcsdreason',label:wgULS('转交理由:','轉交理由:'),tooltip:wgULS('您可以使用维基格式,Twinkle将自动为您加入签名。','您可以使用維基格式,Twinkle將自動為您加入簽名。'),hidden:true});work_area=work_area.render();old_area.parentNode.replaceChild(work_area,old_area);var evt=document.createEvent("Event");evt.initEvent('change',true,true);form.xfdcat.dispatchEvent(evt);break;case'ffd':work_area=new Morebits.quickForm.element({type:'field',label:wgULS('文件存废讨论','檔案存廢討論'),name:'work_area'});appendReasonBox('ffd');work_area=work_area.render();old_area.parentNode.replaceChild(work_area,old_area);break;default:work_area=new Morebits.quickForm.element({type:'field',label:wgULS('未定义','未定義'),name:'work_area'});work_area=work_area.render();old_area.parentNode.replaceChild(work_area,old_area);break;}
if(value==="cfds"){Twinkle.xfd.previousNotify=form.notify.checked;form.notify.checked=false;form.notify.disabled=true;}else{form.notify.checked=Twinkle.xfd.previousNotify;form.notify.disabled=false;}};Twinkle.xfd.callback.change_afd_category=function twinklexfdCallbackChangeAfdCategory(e){if(e.target.value==='merge'){e.target.form.mergeinto.parentElement.removeAttribute('hidden');e.target.form.fwdcsdreason.parentElement.setAttribute('hidden','');e.target.form.mergeinto.previousElementSibling.innerHTML=wgULS('合并到:','合併到:');}else if(e.target.value==='fwdcsd'){e.target.form.mergeinto.parentElement.removeAttribute('hidden');e.target.form.fwdcsdreason.parentElement.removeAttribute('hidden');e.target.form.mergeinto.previousElementSibling.innerHTML='提交人:';e.target.form.xfdreason.value=decodeURIComponent($("#delete-reason").text()).replace(/\+/g,' ');}else if(e.target.value==='fame'){e.target.form.mergeinto.parentElement.setAttribute('hidden','');e.target.form.fwdcsdreason.parentElement.setAttribute('hidden','');e.target.form.xfdreason.value=Twinkle.getPref('afdFameDefaultReason');}else if(e.target.value==='substub'){e.target.form.mergeinto.parentElement.setAttribute('hidden','');e.target.form.fwdcsdreason.parentElement.setAttribute('hidden','');e.target.form.xfdreason.value=Twinkle.getPref('afdSubstubDefaultReason');}else{e.target.form.mergeinto.parentElement.setAttribute('hidden','');e.target.form.fwdcsdreason.parentElement.setAttribute('hidden','');}
if(Twinkle.getPref('afdDefaultCategory')==='same'){localStorage['Twinkle_afdCategory']=e.target.value;}};Twinkle.xfd.callbacks={afd:{main:function(pageobj){var params=pageobj.getCallbackParameters();var wikipedia_page=new Morebits.wiki.page(params.logpage,wgULS("添加讨论到当日列表","加入討論到當日清單"));wikipedia_page.setFollowRedirect(true);wikipedia_page.setCallbackParameters(params);wikipedia_page.load(Twinkle.xfd.callbacks.afd.todaysList);if(params.usertalk){var initialContrib=pageobj.getCreator();if(initialContrib===mw.config.get('wgUserName')){pageobj.getStatusElement().warn(wgULS("您("+initialContrib+")创建了该页,跳过通知","您("+initialContrib+")建立了該頁,跳過通知"));return;}
var talkPageName='User talk:'+initialContrib;Morebits.wiki.flow.check(talkPageName,function(){var flowpage=new Morebits.wiki.flow(talkPageName,wgULS("通知页面创建者("+initialContrib+")","通知頁面建立者("+initialContrib+")"));flowpage.setTopic("页面[[:"+Morebits.pageNameNorm+"]]存废讨论通知");flowpage.setContent("{{subst:AFDNote|"+Morebits.pageNameNorm+"|flow=yes}}");flowpage.newTopic();},function(){var usertalkpage=new Morebits.wiki.page(talkPageName,wgULS("通知页面创建者("+initialContrib+")","通知頁面建立者("+initialContrib+")"));var notifytext="\n{{subst:AFDNote|"+Morebits.pageNameNorm+"}}--~~~~";usertalkpage.setAppendText(notifytext);usertalkpage.setEditSummary("通知:页面[["+Morebits.pageNameNorm+"]]存废讨论提名"+Twinkle.getPref('summaryAd'));usertalkpage.setTags(Twinkle.getPref('revisionTags'));usertalkpage.setCreateOption('recreate');if(Twinkle.getPref('xfdWatchUser')=='no'){usertalkpage.setWatchlistFromPreferences(false);}
else{usertalkpage.setWatchlistFromPreferences(true);}
usertalkpage.setFollowRedirect(true);usertalkpage.append();});}},taggingArticle:function(pageobj){var text=pageobj.getPageText();var params=pageobj.getCallbackParameters();var tag='{{vfd|'+Morebits.string.formatReasonText(params.reason);switch(params.xfdcat){case'vmd':tag+='|wikt';break;case'vms':tag+='|s';break;case'vmb':tag+='|b';break;case'vmq':tag+='|q';break;case'vmvoy':tag+='|voy';break;case'vmv':tag+='|v';break;default:break;}
if(Morebits.wiki.isPageRedirect()){tag+='|r';}
tag+='|date={{subst:#time:Y/m/d}}}}';if(params.noinclude){tag='<noinclude>'+tag+'</noinclude>';if(text.indexOf('{|')===0){tag+='\n';}}else{tag+='\n';}
var textNoSd=text.replace(/\{\{\s*(db(-\w*)?|d|delete|(?:hang|hold)[- ]?on)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/ig,"");if(text!==textNoSd&&confirm(wgULS("在页面上找到快速删除模板,要移除吗?","在頁面上找到快速刪除模板,要移除嗎?"))){text=textNoSd;}
var textNoNotMandarin=text.replace(/\{\{\s*(NotMandarin|Notchinese|非中文|非現代漢語|非现代汉语|非現代標準漢語|非现代标准汉语)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/ig,"");if(text!==textNoNotMandarin&&confirm(wgULS("在页面上找到非现代标准汉语模板,要移除吗?","在頁面上找到非現代標準漢語模板,要移除嗎?"))){text=textNoNotMandarin;}
if(Twinkle.getPref('markXfdPagesAsPatrolled')){pageobj.patrol();}
pageobj.setPageText(tag+text);pageobj.setEditSummary(wgULS("页面存废讨论:[[","頁面存廢討論:[[")+params.logpage+"#"+Morebits.pageNameNorm+"]]"+Twinkle.getPref('summaryAd'));pageobj.setTags(Twinkle.getPref('revisionTags'));if(Twinkle.getPref('xfdWatchPage')=='no'){pageobj.setWatchlistFromPreferences(false);}
else{pageobj.setWatchlistFromPreferences(true);}
pageobj.save();if(Twinkle.getPref('markXfdPagesAsPatrolled')){pageobj.patrol();}},todaysList:function(pageobj){var text=pageobj.getPageText();var params=pageobj.getCallbackParameters();var type='';var to='';switch(params.xfdcat){case'vmd':case'vms':case'vmb':case'vmq':case'vmvoy':case'vmv':type='vm';to=params.xfdcat;break;case'fwdcsd':case'merge':to=params.mergeinto;default:type=params.xfdcat;break;}
var append=true;switch(type){case'fame':case'substub':case'batch':var commentText="<!-- Twinkle: User:"+mw.config.get('wgUserName')+" 的 "+type+" 提刪插入點,請勿變更或移除此行,除非不再於此頁提刪 -->";var newText="===[["+Morebits.pageNameNorm+"]]===";if(type==="fame"){newText+="\n{{Findsources|"+Morebits.pageNameNorm+"}}";}
if(text.indexOf(commentText)!==-1){text=text.replace(commentText,newText+"\n\n"+commentText);pageobj.setPageText(text);append=false;}else{var appendText="\n{{safesubst:SafeAfdHead}}\n"+
({"fame":"==30天后仍掛有{{tl|notability}}模板的條目==\n"+'<span style="font-size:smaller;">(已掛[[template:notability|關注度模板]]30天)</span>',"substub":"==到期篩選的小小作品==","batch":"==批量提刪=="})[type]+"\n"+
newText+"\n\n"+
commentText+"\n"+"----\n"+"(請不要在橫線下参与讨论,以免出现错误。)\n"+":{{删除}}理據:"+Morebits.string.formatReasonText(params.reason)+"\n"+'提报以上'+({"fame":"<u>关注度不足</u>条目","substub":"<u>小小作品</u>","batch":"頁面"})[type]+'的維基人及時間:<br id="no-new-title" />~~~~';pageobj.setAppendText(appendText);}
break;default:pageobj.setAppendText("\n{{subst:DRItem|Type="+type+"|DRarticles="+Morebits.pageNameNorm+"|Reason="+Morebits.string.formatReasonText(params.reason)+(params.fwdcsdreason.trim()!==""?"<br>\n轉交理由:"+params.fwdcsdreason:"")+"|To="+to+"}}~~~~");break;}
pageobj.setEditSummary(wgULS("添加[[","加入[[")+Morebits.pageNameNorm+"]]"+Twinkle.getPref('summaryAd'));pageobj.setTags(Twinkle.getPref('revisionTags'));if(Twinkle.getPref('xfdWatchDiscussion')=='no'){pageobj.setWatchlistFromPreferences(false);}
else{pageobj.setWatchlistFromPreferences(true);}
pageobj.setCreateOption('recreate');if(append){pageobj.append();}else{pageobj.save();}
Twinkle.xfd.currentRationale=null;},tryTagging:function(pageobj){var statelem=pageobj.getStatusElement();if(!pageobj.exists()&&mw.config.get('wgPageContentModel')!=='Scribunto'){statelem.error(wgULS("页面不存在,可能已被删除","頁面不存在,可能已被刪除"));return;}
var text=pageobj.getPageText();var xfd=/(?:\{\{([rsaiftcmv]fd|md1|proposed deletion)[^{}]*?\}\})/i.exec(text);if(xfd&&!confirm(wgULS("删除相关模板{{"+xfd[1]+"}}已被置于页面中,您是否仍想继续提报?","刪除相關模板{{"+xfd[1]+"}}已被置於頁面中,您是否仍想繼續提報?"))){statelem.error(wgULS('页面已被提交至存废讨论。','頁面已被提交至存廢討論。'));return;}
var copyvio=/(?:\{\{\s*(copyvio)[^{}]*?\}\})/i.exec(text);if(copyvio){statelem.error(wgULS('页面中已有版权验证模板。','頁面中已有版權驗證模板。'));return;}
Twinkle.xfd.callbacks.afd.taggingArticle(pageobj);var wikipedia_page=new Morebits.wiki.page(mw.config.get('wgPageName'));wikipedia_page.setCallbackParameters(pageobj.getCallbackParameters());wikipedia_page.lookupCreator(Twinkle.xfd.callbacks.afd.main);}},ffd:{main:function(pageobj){var params=pageobj.getCallbackParameters();var initialContrib=pageobj.getCreator();params.uploader=initialContrib;var wikipedia_page=new Morebits.wiki.page(params.logpage,wgULS("添加讨论到当日列表","加入討論到當日清單"));wikipedia_page.setFollowRedirect(true);wikipedia_page.setCallbackParameters(params);wikipedia_page.load(Twinkle.xfd.callbacks.ffd.todaysList);if(params.usertalk){if(initialContrib===mw.config.get('wgUserName')){pageobj.getStatusElement().warn(wgULS("您("+initialContrib+")创建了该页,跳过通知","您("+initialContrib+")建立了該頁,跳過通知"));return;}
var talkPageName='User talk:'+initialContrib;Morebits.wiki.flow.check(talkPageName,function(){var flowpage=new Morebits.wiki.flow(talkPageName,wgULS("通知页面创建者("+initialContrib+")","通知頁面建立者("+initialContrib+")"));flowpage.setTopic("文件[[:File:"+mw.config.get('wgTitle')+"]]存废讨论通知");flowpage.setContent("{{subst:idw|File:"+mw.config.get('wgTitle')+"|flow=yes}}");flowpage.newTopic();},function(){var usertalkpage=new Morebits.wiki.page(talkPageName,wgULS("通知页面创建者("+initialContrib+")","通知頁面建立者("+initialContrib+")"));var notifytext="\n{{subst:idw|File:"+mw.config.get('wgTitle')+"}}--~~~~";usertalkpage.setAppendText(notifytext);usertalkpage.setEditSummary("通知:文件[["+Morebits.pageNameNorm+"]]存废讨论提名"+Twinkle.getPref('summaryAd'));usertalkpage.setTags(Twinkle.getPref('revisionTags'));usertalkpage.setCreateOption('recreate');if(Twinkle.getPref('xfdWatchUser')=='no'){usertalkpage.setWatchlistFromPreferences(false);}
else{usertalkpage.setWatchlistFromPreferences(true);}
usertalkpage.setFollowRedirect(true);usertalkpage.append();});}},taggingImage:function(pageobj){var text=pageobj.getPageText();var params=pageobj.getCallbackParameters();pageobj.setPageText("{{ifd|"+Morebits.string.formatReasonText(params.reason)+"|date={{subst:#time:c}}}}\n"+text);pageobj.setEditSummary(wgULS("文件存废讨论:[[","檔案存廢討論:[[")+params.logpage+"#"+Morebits.pageNameNorm+"]]"+Twinkle.getPref('summaryAd'));pageobj.setTags(Twinkle.getPref('revisionTags'));if(Twinkle.getPref('xfdWatchPage')=='no'){pageobj.setWatchlistFromPreferences(false);}
else{pageobj.setWatchlistFromPreferences(true);}
pageobj.setCreateOption('recreate');pageobj.save();},todaysList:function(pageobj){var params=pageobj.getCallbackParameters();pageobj.setAppendText("\n{{subst:IfdItem|Filename="+mw.config.get('wgTitle')+"|Uploader="+params.uploader+"|Reason="+Morebits.string.formatReasonText(params.reason)+"}}--~~~~");pageobj.setEditSummary(wgULS("添加[[","加入[[")+Morebits.pageNameNorm+"]]"+Twinkle.getPref('summaryAd'));pageobj.setTags(Twinkle.getPref('revisionTags'));if(Twinkle.getPref('xfdWatchDiscussion')=='no'){pageobj.setWatchlistFromPreferences(false);}
else{pageobj.setWatchlistFromPreferences(true);}
pageobj.setCreateOption('recreate');pageobj.append(function(){Twinkle.xfd.currentRationale=null;});},tryTagging:function(pageobj){var statelem=pageobj.getStatusElement();if(!pageobj.exists()){statelem.error(wgULS("页面不存在,可能已被删除","頁面不存在,可能已被刪除"));return;}
var text=pageobj.getPageText();var xfd=/(?:\{\{([rsaiftcmv]fd|md1|proposed deletion)[^{}]*?\}\})/i.exec(text);if(xfd&&!confirm(wgULS("删除相关模板{{"+xfd[1]+"}}已被置于页面中,您是否仍想继续提报?","刪除相關模板{{"+xfd[1]+"}}已被置於頁面中,您是否仍想繼續提報?"))){statelem.error(wgULS('页面已被提交至存废讨论。','頁面已被提交至存廢討論。'));return;}
Twinkle.xfd.callbacks.ffd.taggingImage(pageobj);var wikipedia_page=new Morebits.wiki.page(mw.config.get('wgPageName'));wikipedia_page.setCallbackParameters(pageobj.getCallbackParameters());wikipedia_page.lookupCreator(Twinkle.xfd.callbacks.ffd.main);}}};Twinkle.xfd.callback.evaluate=function(e){var type=e.target.category.value;var usertalk=e.target.notify.checked;var reason=e.target.xfdreason.value;var fwdcsdreason,xfdcat,mergeinto,noinclude;if(type==='afd'){fwdcsdreason=e.target.fwdcsdreason.value;noinclude=e.target.noinclude.checked;xfdcat=e.target.xfdcat.value;mergeinto=e.target.mergeinto.value;}
Morebits.simpleWindow.setButtonsEnabled(false);Morebits.status.init(e.target);Twinkle.xfd.currentRationale=reason;Morebits.status.onError(Twinkle.xfd.printRationale);if(!type){Morebits.status.error('错误','未定义的动作');return;}
var wikipedia_page,logpage,params;var dateString;var date=new Date();function twodigits(num){return num<10?'0'+num:num;}
switch(type){case'afd':dateString=date.getUTCFullYear()+'/'+twodigits(date.getUTCMonth()+1)+'/'+twodigits(date.getUTCDate());logpage='Wikipedia:頁面存廢討論/記錄/'+dateString;params={usertalk:usertalk,xfdcat:xfdcat,mergeinto:mergeinto,noinclude:noinclude,reason:reason,fwdcsdreason:fwdcsdreason,logpage:logpage};Morebits.wiki.addCheckpoint();Morebits.wiki.actionCompleted.redirect=logpage;Morebits.wiki.actionCompleted.notice=wgULS("提名完成,重定向到讨论页","提名完成,重定向到討論頁");var isScribunto=mw.config.get('wgPageContentModel')==='Scribunto';wikipedia_page=isScribunto?new Morebits.wiki.page(mw.config.get('wgPageName')+'/doc',wgULS("添加存废讨论模板到模块文档页","加入存廢討論模板到模組文件頁")):new Morebits.wiki.page(mw.config.get('wgPageName'),wgULS("添加存废讨论模板到页面","加入存廢討論模板到頁面"));wikipedia_page.setFollowRedirect(false);wikipedia_page.setCallbackParameters(params);wikipedia_page.load(Twinkle.xfd.callbacks.afd.tryTagging);Morebits.wiki.removeCheckpoint();break;case'ffd':dateString=date.getUTCFullYear()+'/'+twodigits(date.getUTCMonth()+1)+'/'+twodigits(date.getUTCDate());logpage='Wikipedia:檔案存廢討論/記錄/'+dateString;params={usertalk:usertalk,reason:reason,logpage:logpage};Morebits.wiki.addCheckpoint();Morebits.wiki.actionCompleted.redirect=logpage;Morebits.wiki.actionCompleted.notice=wgULS("提名完成,重定向到讨论页","提名完成,重定向到討論頁");wikipedia_page=new Morebits.wiki.page(mw.config.get('wgPageName'),wgULS("添加存废讨论模板到文件描述页","加入存廢討論模板到檔案描述頁"));wikipedia_page.setFollowRedirect(false);wikipedia_page.setCallbackParameters(params);wikipedia_page.load(Twinkle.xfd.callbacks.ffd.tryTagging);Morebits.wiki.removeCheckpoint();break;default:alert("twinklexfd:未定义的类别");break;}};Twinkle.xfd.aprilfool=function twinklexfdCallback(){var Window=new Morebits.simpleWindow(600,350);Window.setTitle("APRIL FOOL");Window.setScriptName("Twinkle");Window.addFooterLink(wgULS("关于愚人节","關於愚人節"),"Wikipedia:愚人節玩笑規範");Window.addFooterLink(wgULS("Twinkle帮助","Twinkle說明"),"WP:TW/DOC#xfd");var form=new Morebits.quickForm(Twinkle.xfd.aprilfool.evaluate);var categories=form.append({type:'select',name:'category',label:wgULS('提交类型:','提交類別:'),event:Twinkle.xfd.callback.change_category});categories.append({type:'option',label:wgULS('页面存废讨论','頁面存廢討論'),selected:mw.config.get('wgNamespaceNumber')===0,value:'afd'});categories.append({type:'option',label:wgULS('文件存废讨论','檔案存廢討論'),selected:mw.config.get('wgNamespaceNumber')===6,value:'ffd'});form.append({type:'checkbox',list:[{label:wgULS('通知还是不通知,这是一个问题','通知還是不通知,這是一個問題'),value:'notify',name:'notify',tooltip:wgULS("无论选还是不选都不通知!","無論選還是不選都不通知!"),checked:true}]});form.append({type:'field',label:'工作区',name:'work_area'});form.append({type:'submit'});var result=form.render();Window.setContent(result);Window.display();var evt=document.createEvent("Event");evt.initEvent('change',true,true);result.category.dispatchEvent(evt);};Twinkle.xfd.aprilfool.evaluate=function(e){var type=e.target.category.value;var reason=e.target.xfdreason.value;var xfdcat,mergeinto,noinclude;if(type==='afd'){noinclude=e.target.noinclude.checked;xfdcat=e.target.xfdcat.value;mergeinto=e.target.mergeinto.value;}
Morebits.simpleWindow.setButtonsEnabled(false);Morebits.status.init(e.target);Twinkle.xfd.currentRationale=reason;Morebits.status.onError(Twinkle.xfd.printRationale);var wikipedia_page,logpage,params;var date=new Date();logpage='Wikipedia:頁面存廢和諧討論/記錄/'+date.getUTCFullYear()+'/04/01';params={xfdcat:xfdcat,mergeinto:mergeinto,noinclude:noinclude,reason:reason,logpage:logpage};Morebits.wiki.addCheckpoint();Morebits.wiki.actionCompleted.redirect=logpage;Morebits.wiki.actionCompleted.notice=wgULS("提名完成,重定向到讨论页","提名完成,重定向到討論頁");wikipedia_page=new Morebits.wiki.page(mw.config.get('wgPageName'),wgULS("假装添加存废讨论模板到页面","假裝加入存廢討論模板到頁面"));wikipedia_page.setFollowRedirect(false);wikipedia_page.setCallbackParameters(params);wikipedia_page.load(Twinkle.xfd.aprilfool.tryTagging);Morebits.wiki.removeCheckpoint();};Twinkle.xfd.aprilfool.todaysList=function(pageobj){var params=pageobj.getCallbackParameters();var type='';var to='';switch(params.xfdcat){case'vmd':case'vms':case'vmb':case'vmq':case'vmvoy':case'vmv':type='vm';to=params.xfdcat;break;case'fwdcsd':case'merge':to=params.mergeinto;default:type=params.xfdcat;break;}
pageobj.setAppendText("\n{{subst:DRItem|Type="+type+"|DRarticles="+Morebits.pageNameNorm+"|Reason="+Morebits.string.formatReasonText(params.reason)+"|To="+to+"}}~~~~");pageobj.setEditSummary("添加[["+Morebits.pageNameNorm+"]]"+Twinkle.getPref('summaryAd'));pageobj.setTags(Twinkle.getPref('revisionTags'));if(Twinkle.getPref('xfdWatchDiscussion')=='no'){pageobj.setWatchlistFromPreferences(false);}
else{pageobj.setWatchlistFromPreferences(true);}
pageobj.setCreateOption('recreate');pageobj.append();Twinkle.xfd.currentRationale=null;};Twinkle.xfd.aprilfool.tryTagging=function(pageobj){var statelem=pageobj.getStatusElement();var params=pageobj.getCallbackParameters();if(!pageobj.exists()){statelem.error(wgULS("页面不存在,可能已被删除","頁面不存在,可能已被刪除"));return;}
var text=pageobj.getPageText();var xfd=/(?:\{\{([rsaiftcmv]fd|md1|proposed deletion)[^{}]*?\}\})/i.exec(text);if(xfd&&!confirm(wgULS("删除相关模板{{"+xfd[1]+"}}已被置于页面中,您是否仍想继续提报?","刪除相關模板{{"+xfd[1]+"}}已被置於頁面中,您是否仍想繼續提報?"))){statelem.error(wgULS('页面已被提交至存废讨论。','頁面已被提交至存廢討論。'));return;}
var copyvio=/(?:\{\{\s*(copyvio)[^{}]*?\}\})/i.exec(text);if(copyvio){statelem.error(wgULS('页面中已有版权验证模板。','頁面中已有版權驗證模板。'));}
var wikipedia_page=new Morebits.wiki.page(params.logpage,wgULS("添加讨论到当日列表","加入討論到當日清單"));wikipedia_page.setFollowRedirect(true);wikipedia_page.setCallbackParameters(params);wikipedia_page.load(Twinkle.xfd.aprilfool.todaysList);};})(jQuery);
// </nowiki>