User:Fdcn/vfd.js
维基百科,自由的百科全书
注意:在保存以后,您必须清除浏览器的缓存才能看到所作出的改变:
- Mozilla: 点击刷新(或ctrl-r), IE / Opera: ctrl-f5, Safari: cmd-r, Konqueror ctrl-r。
// Articles for deletion Template Selecter // Original by Tietew@jawiki // This script is under public domain, and comes with ABSOLUTELY NO WARRANTY. // You can use/modify/redistribute without any permission. //Chinese Localize by Alexsh@zhwiki //refactoring by Fdcn@zhwiki //Warning: You must disable WikEd( by Cacycle@enwiki) before you use this script //已装WikEd的,必须临时禁用。 /** * 创建一个下拉选单 * 返回一个对象,包含该选单的id、select元素、增加项目方法、删除项目方法 * */ function createDropdownMenu(title,id){ if(!document.getElementById('editform')) return false; var action={}; var menu=document.createElement("select"); menu.setAttribute("size",1); menu.setAttribute("id",id); function add(text,value,pre,sampletext,post,summary,minor,fn){// 参数为该选单项的 显示文字、值、前缀、示例文字、后缀、摘要文字、是否小修改、附加处理 if(typeof value=="string"){ action[value]={ 'text':[pre,sampletext,post], 'summary':summary, 'minor':minor, 'afterInsert':fn }; } else {value=text;} return menu.options[menu.options.length]=new Option(text,value); } add(title); menu.onchange=function(){ var e = document.getElementById('editform'); var cv=action[menu.options[menu.selectedIndex].value]; if(!cv){menu.selectedIndex=0;return;} insertTags(cv.text[0], cv.text[2],cv.text[1]); e.wpSummary.value += cv.summary; e.wpMinoredit.checked = cv.minor; menu.selectedIndex=0; if(typeof cv.afterInsert=="function"){cv.afterInsert();} } var listTools=document.getElementById('dropdownListEditTools'); if(listTools){listTools.appendChild(menu);} else{document.getElementById('toolbar').appendChild(menu);} return { 'id':id, 'element':menu, 'add':add, 'remove':function remove(value){ if(typeof value=='number'){return menu.remove(value);} if(typeof value=='string'){ for(var i=0;i<menu.options.length;i++){ if(menu.options[i].value==value){return menu.remove(i);} } } if(typeof value=='object'){ for(var i=0;i<menu.options.length;i++){ if(menu.options[i]==value){return menu.remove(i);} } } return false; } }; } /** * 插入光标所在的分段前后 */ function addSect(menu,sectReg,text,value,pre,post,summary,minor){ var txtarea = document.editform.wpTextbox1; var reg=/<sectins><\/sectins>/g; menu.add( text, value, '<sectins>', '', "</sectins>", summary, minor, function(){ var text=txtarea.value; var scrollTop = txtarea.scrollTop; var index=-1; text=text.replace(reg,function(m,i){index=i;return '';}); if(index>-1){ sectReg.lastIndex=0; var currentIndex=0,startIndex=0,endIndex=0; while(true){ var item= sectReg.exec(text); if(!item){ endIndex=text.length; break; } currentIndex=item.index; if(currentIndex<index){ startIndex=sectReg.lastIndex; continue; }else{ endIndex=currentIndex; break; } } txtarea.value=text.substring(0, startIndex)+pre+text.substring(startIndex,endIndex)+post+text.substr(endIndex); }else{ txtarea.value=text.replace(/<sectins>/g,pre).replace(/<\/sectins>/g,post); } txtarea.scrollTop = scrollTop; } ); } /** * 创建vfd菜单 */ if(!window.customSignature){var customSignature='--~~\~~';}//允许定制签名 function createVfd(){ var menu=createDropdownMenu(wgULS('删除管理','刪除管理'),"vfdInsertSel" ); if(!menu){return;} var sectReg=/(^|\r?\n)===[^=]+=== *\r?\n/g; function addSectDel(text,value,pre,post,summary,min){ addSect(menu,sectReg,text,value,pre,post,summary,min); } addSectDel(wgULS('删除','刪除'), "vfdDeleted", "{\{delh|d}\}\n", "{\{subst:deleted}\}"+customSignature+"\n{\{delf}\}", "處理.刪除", false ); addSectDel(wgULS('保留','保留'), "vfdKept", "{\{delh|k}\}\n", "{\{subst:kept}\}"+customSignature+"\n{\{delf}\}", "結束.保存", false ); addSectDel(wgULS('快速删除','快速刪除'), "vfdSpeedlyDeleted", "{\{delh|sd}\}\n", "{\{subst:SpeedyDeleted}\}"+customSignature+"\n{\{delf}\}", "處理.速刪", false ); addSectDel(wgULS('快速保留','快速保留'), "vfdSpeedlyKept", "{\{delh|sk}\}\n", "----\n快速保留"+customSignature+"\n{\{delf}\}", "處理.速留", false ); addSectDel(wgULS('移动','移動'), "vfdMoved", "{\{delh|m}\}\n", "----\n已移動"+customSignature+"\n{\{delf}\}", "處理.移動", false ); addSectDel(wgULS('无来源版权','無來源版權'), "vfdLSSD", "{\{delh|lssd}\}\n", "----\n無來源或版權"+customSignature+"\n{\{delf}\}", "處理.LSSD", false ); addSectDel(wgULS("图片侵权删除","圖片侵權刪除"), "vfdImageCopyvio", "{\{delh|ic}\}\n", "----\n本圖片已確認侵權,刪除。"+customSignature+"\n{\{delf}\}", "確認侵權,刪除", false ); addSectDel(wgULS("讨论无共识","討論無共識"), "vfdNoConsensus", "{\{delh|nc}\}\n", "{\{subst:nc}\}"+customSignature+"\n{\{delf}\}", "無共識", false ); addSectDel(wgULS("条目重定向","條目重定向"), "vfdRedirected", "{\{delh|r}\}\n", "----\n已重定向"+customSignature+"\n{\{delf}\}", "條目重定向", false ); addSectDel(wgULS("类别重定向","類別重定向"), "vfdCategoryRedirected", "{\{delh|cr}\}\n", "----\n已重定向"+customSignature+"\n{\{delf}\}", "類別重定向", false ); addSectDel("已在共享提供", "vfdNowCommons", "{\{delh|nowcommons}\}\n", "----\n已在共享資源提供,快速刪除"+customSignature+"\n{\{delf}\}", "NowCommons", false ); addSectDel(wgULS("应在共享提请","應在共享提請"), "vfdRequestInCommons", "{\{delh|commons}\}\n", "----此圖像於[[維基共享資源]],請至[[commons:COM:AFD|共享的刪除請求]]提出。"+customSignature+"\n{\{delf}\}", "此圖在Commons,無法處理", false ); addSectDel(wgULS("转交侵权投票","轉交侵權投票"), "vfdTransferToCopyvio", "{\{delh|c}\}\n", "----\n轉交[[Wikipedia:刪除投票/侵權|侵權投票]]。"+customSignature+"\n{\{delf}\}", "轉交侵權投票", false ); addSectDel(wgULS("请求无效","請求無效"), "vfdIneffectualRequest", "{\{delh|ir}\}\n", "----\n請求無效。"+customSignature+"\n{\{delf}\}", "無效", false ); addSectDel(wgULS("请求理由消失","請求理由消失"), "vfdReasonDisappear", "{\{delh|rr}\}\n", "----\n請求理由消失"+customSignature+"\n{\{delf}\}", "請求理由消失", false ); addSectDel(wgULS("重复请求","重覆請求"), "vfdRepeatRequest", "{\{delh|rep}\}\n", "----\n重覆提出"+customSignature+"\n{\{delf}\}", "重覆", false ); addSectDel(wgULS("锁定条目","鎖定條目"), "vfdRepeatDeleted", "{\{delh|drep}\}\n", "----\n刪除+白紙保護"+customSignature+"\n{\{delf}\}", "刪除+白紙保護", false ); addSectDel(wgULS("图片已转SVG","圖片已轉SVG"), "vfdImageConvertedSVG", "{\{delh|svg}\}\n", "----\n此圖片已轉成SVG,快速刪除"+customSignature+"\n{\{delf}\}", "已轉SVG", false ); addSectDel(wgULS("移至新闻","移至新聞"), "vfdTransWN", "{\{delh|twn}\}\n", "----\n已移動至維基新聞"+customSignature+"\n{\{delf}\}", "移至維基新聞", false ); addSectDel(wgULS("移至文库","移至文庫"), "vfdTransWS", "{\{delh|tws}\}\n", "----\n已移動至維基文庫"+customSignature+"\n{\{delf}\}", "移至維基文庫", false ); addSectDel(wgULS("移至教科书","移至教科書"), "vfdTransWB", "{\{delh|twb}\}\n", "----\n已移動至維基教科書"+customSignature+"\n{\{delf}\}", "移至維基教科書", false ); addSectDel(wgULS("移至语录","移至語錄"), "vfdTransWQ", "{\{delh|twq}\}\n", "----\n已移動至維基語錄"+customSignature+"\n{\{delf}\}", "移至維基語錄", false ); addSectDel(wgULS("移至词典","移至詞典"), "vfdTransWS", "{\{delh|twt}\}\n", "----\n已移動至維基詞典"+customSignature+"\n{\{delf}\}", "移至維基詞典", false ); addSectDel(wgULS("移至其他计划","移至其他計劃"), "vfdTransOther", "{\{delh|two}\}\n", "----\n已移動至其他維基計劃"+customSignature+"\n{\{delf}\}", "移至其他計劃", false ); addSectDel("其他", "vfdOther", "{\{delh|請在此輸入處理結果}\}\n", "----\n請在此輸入處理結果"+customSignature+"\n{\{delf}\}", "處理", false ); /** * 投票资格 */ menu.add('--'+wgULS('投票资格','投票資格')+'--'); menu.add(wgULS('无签名','無簽名'), "voteNosigh", "{\{nosignh}\}\n", '', "{\{nosignf}\}", false, " " ); menu.add(wgULS('资格不符','資格不符'), "voteNotqualified", "{\{Notqualifiedh}\}\n", '', "{\{Notqualifiedf}\}", false, " " ); menu.add(wgULS('重覆投票','重覆投票'), "voteVotedup", "{\{Voteduph}\}\n", '', "{\{Votedupf}\}", false, " " ); return menu; } /** * 创建zhc菜单 */ function createZhc(){ var menu=createDropdownMenu(wgULS('繁简转换','繁簡轉換'),"zhcInsertSel" ); if(!menu){return;} var sectReg=/(^|\r?\n)==[^=]+== *\r?\n|(^|\r?\n) *\{\{Wikipedia:(繁簡體轉換請求|繁简体转换请求)\/[^\}]*\}\} */g; function addSectZhc(text,value,pre,post,summary,min){ addSect(menu,sectReg,text,value,'\n'+pre,post,summary,min); } addSectZhc('添加', "zhcAdd", "{\{ConverH|c}\}\n", "\n----\n該請求添加至轉換表。"+customSignature+"\n{\{ConverF}\}", "已添加請求", false ); addSectZhc('未添加', "zhcCancel", "{\{ConverH|nc}\}\n", "\n----\n該請求未能進入轉換表。"+customSignature+"\n{\{ConverF}\}", "未添加請求", false ); return menu; } /** * 创建rfb菜单 */ function createRfb(){ var menu=createDropdownMenu(wgULS('用户封禁','用戶封禁'),"rfbInsertSel" ); if(!menu){return;} return menu; } addOnloadHook(function(){ if(/^Wikipedia:删除投票和请求\//i.test(wgPageName)) {return createVfd();} if(/^Wikipedia:繁简体转换请求\//i.test(wgPageName)){return createZhc();} if(/^Wikipedia:用戶封禁請求\//i.test(wgPageName)){return createRfb();} return false; });