User:Cdip150/customEdittools.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/*
// 更換「短簽名」按鈕
mwCustomEditButtons.remove(mwCustomEditButtons['btnSigOnly']);
mwCustomEditButtons.insert( createEditButton('btnMyShortSign',{
src : 'd/d8/Button_sig_zh.png',
tagOpen : '—{\{subst:User:Cdip150\/sign|short}\} ~~\~~\~',
sampleText : '',
tagClose : '',
speedTip : '短簽名',
width : 12
}) , mwCustomEditButtons['btnSignature']);
*/
// 載入「澳門條目專用編輯工具」
importScript('User:Cdip150/工具/介面/MacauEditTool.js');
// 載入「個人化的下拉選單」
importScript('User:Cdip150/工具/介面/customEditMenu.js');
function myinst(tagOpen, tagClose){
var textarea = document.editform.wpTextbox1;
var len = textarea.value.length;
var start = textarea.selectionStart;
var end = textarea.selectionEnd;
var sel = textarea.value.substring(start, end);
var sTop=textarea.scrollTop;
var replace = tagOpen + sel + tagClose;
textarea.value = textarea.value.substring(0,start) + replace + textarea.value.substring(end,len);
textarea.scrollTop=sTop;
textarea.selectionStart=start;
textarea.selectionEnd=start+replace.length;
textarea.focus();
}
$( function(){
// 延長編輯摘要的字數限制
var setLongSummary=function(){
document.editform.wpSummary.maxLength=10000;
}
setLongSummary();
setTimeout(setLongSummary,1000);
if(document.editform) if(document.editform.wpTextbox1 && window.createElement) {
window.getSelfStr=function(){
return (document.editform.chkSelf.checked)?"\|type=self":"";
}
var chkSelf=[
createElement("input", null, {
name:"chkSelf",
id:"chkSelf",
type:"checkbox"
}) ,
createElement("label", "自己", {
for:"chkSelf"
})
]
var btnSdeeSock=createElement("input", null, {
name:"btnSdeeSock",
id:"btnSdeeSock",
type:"button",
value:"Sdee傀儡",
events: {
click: function(){
myinst("\{\{sockvoteduph\}\}", "\{\{sockvotedupf\|Sdee"+getSelfStr()+"\}\}");
}
}
});
var btnInhinsSelf=createElement("input", null, {
name:"btnInhinsSelf",
id:"btnInhinsSelf",
type:"button",
value:"Inhins本體",
events: {
click: function(){
myinst("\{\{sockvoteduph\}\}", "\{\{sockvotedupf\|sockfirst=1\|Inhins"+getSelfStr()+"\}\}");
}
}
});
var btnRonochenSelf=createElement("input", null, {
name:"btnRonochenSelf",
id:"btnRonochenSelf",
type:"button",
value:"Ronochen本體",
events: {
click: function(){
myinst("\{\{sockvoteduph\}\}", "\{\{sockvotedupf\|sockfirst=1\|Ronochen"+getSelfStr()+"\}\}");
}
}
});
var btnInhins=createElement("input", null, {
name:"btnInhins",
id:"btnInhins",
type:"button",
value:"Inhins先投",
events: {
click: function(){
myinst("\{\{sockvoteduph\}\}", "\{\{sockvotedupf\|Sdee\|another=Inhins"+getSelfStr()+"\}\}");
}
}
});
var btnRonochen=createElement("input", null, {
name:"btnRonochen",
id:"btnRonochen",
type:"button",
value:"Ronochen先投",
events: {
click: function(){
myinst("\{\{sockvoteduph\}\}", "\{\{sockvotedupf\|Sdee\|another=Ronochen"+getSelfStr()+"\}\}");
}
}
});
var btnNote=createElement("input", null, {
name:"btnNote",
id:"btnNote",
type:"button",
value:"注意",
events: {
click: function(){
var textarea=document.editform.wpTextbox1;
var sTop=textarea.scrollTop;
textarea.value=textarea.value.replace(/\s*$/ , "\n----\n:;\{\{注意\}\}:事後發現,\[\[User:Sdee\]\]在以上投票中行使傀儡,是故相關傀儡投票將被換算為Sdee所投,"+((document.editform.chkSelf.checked)?"而由於本投票的被提名人為Sdee,且本項不能對自己投票,故其傀儡所投出的票均一律作廢":"而其所作的票將祇視第一票為有效,第二票及以後均視為無效")+"。參見\[\[Wikipedia:傀儡\/Sdee事件\]\]。\n");
textarea.scrollTop=sTop;
textarea.selectionStart=document.editform.wpTextbox1.value.length;
textarea.focus();
document.editform.wpSummary.value="";
}
}
});
elementMoveto([chkSelf," ",btnNote," ",btnSdeeSock," ",btnInhinsSelf,btnRonochenSelf," ",btnInhins,btnRonochen], document.editform.wpTextbox1, "after");
}
});
//importScript('User:Cdip150/工具/介面/ConvertRefNoteTag.js');