User:逆襲的天邪鬼/Twinkle-lzh/friendlytag.js: Difference between revisions

no edit summary
(Created page with "//<nowiki> // vim: set noet sts=0 sw=8: (function($){ /* **************************************** *** friendlytag.js: Tag module ***************************************...")
 
No edit summary
Line 3:
 
 
(function($) {
 
 
Line 17:
 
Twinkle.tag = function friendlytag() {
// redirect tagging
if( Morebits.wiki.isPageRedirect() ) {
Twinkle.tag.mode = '重定向';
Twinkle.addPortletLink( Twinkle.tag.callback, "标记", "friendly-tag", "标记重定向" );
}
// article/draft tagging
else if( !Morebits.wiki.isPageRedirect() && ( ( mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 118 ) && mw.config.get('wgCurRevisionId') ) || ( Morebits.pageNameNorm === 'Wikipedia維基大典:沙盒' ) ) {
Twinkle.addPortletLink( Twinkle.tag.modecallback, ="標", '条"friendly-tag", "標記條'" );
Twinkle.addPortletLink( Twinkle.tag.callback, "标记", "friendly-tag", "标记条目" );
}
};
 
Twinkle.tag.callback = function friendlytagCallback() {
var Window = new Morebits.simpleWindow( 630, (Twinkle.tag.mode === "条目") ? 500 : 400 );
Window.setScriptName( "Twinkle" );
// anyone got a good policy/guideline/info page/instructional page link??
Window.addFooterLink( "Twinkle帮助", "WP:TW/DOC#tag" );
 
var form = new Morebits.quickForm( Twinkle.tag.callback.evaluate );
Line 42 ⟶ 34:
list: [
{
label: '标记页標記頁已巡查',
value: 'patrolPage',
name: 'patrolPage',
Line 51 ⟶ 43:
}
 
Window.setTitle( "條目维护標記" );
switch( Twinkle.tag.mode ) {
case '条目':
Window.setTitle( "条目维护标记" );
 
form.append({
type: 'selectdiv',
nameid: 'sortordertagWorkArea',
labelclassName: '察看列表:morebits-scrollbox',
style: 'max-height: 28em'
tooltip: '您可以在Twinkle参数设置(WP:TWPREFS)中更改此项。',
});
event: Twinkle.tag.updateSortOrder,
list: [
{ type: 'option', value: 'cat', label: '按类别', selected: Twinkle.getFriendlyPref('tagArticleSortOrder') === 'cat' },
{ type: 'option', value: 'alpha', label: '按字母', selected: Twinkle.getFriendlyPref('tagArticleSortOrder') === 'alpha' }
]
});
 
form.append( { type:'submit' } );
type: 'div',
id: 'tagWorkArea',
className: 'morebits-scrollbox',
style: 'max-height: 28em'
});
 
form.append( {
type: 'checkbox',
list: [
{
label: '如可能,合并入{{multiple issues}}',
value: 'group',
name: 'group',
tooltip: '如果添加{{multiple issues}}支持的三个以上的模板,所有支持的模板都会被合并入{{multiple issues}}模板中。',
checked: Twinkle.getFriendlyPref('groupByDefault')
}
]
}
);
 
break;
 
var container = new Morebits.quickForm.element({ type: "fragment" });
case '重定向':
Window.setTitle( "重定向标记" );
 
// function to generate a checkbox, with appropriate subgroup if needed
form.append({ type: 'header', label:'常用模板' });
var makeCheckbox = function(tag, description) {
form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.tag.frequentList });
var checkbox = { value: tag, label: "{{" + tag + "}}: " + description };
if (Twinkle.tag.checkedTags.indexOf(tag) !== -1) {
checkbox.checked = true;
}
switch (tag) {
case "併":
var otherTagName = "併";
checkbox.subgroup = [
{
name: 'mergeTarget',
type: 'input',
label: '目標:',
},
{
name: 'mergeTagOther',
type: 'checkbox',
list: [
{
label: '用{{' + otherTagName + '}}標記其他條目',
checked: true,
}
]
}
];
if (mw.config.get('wgNamespaceNumber') === 0) {
checkbox.subgroup.push({
name: 'mergeReason',
type: 'textarea',
label: '合併理由(會附在條目的討論頁):',
tooltip: '請填寫理由。'
});
}
break;
case "文未準":
checkbox.subgroup = {};
break;
default:
break;
}
return checkbox;
};
 
var checkboxes = [];
form.append({ type: 'header', label:'偶用模板' });
$.each(Twinkle.tag.article.tags, function(tag, description) {
form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.tag.lessFrequentList });
checkboxes.push(makeCheckbox(tag, description));
});
container.append({
type: "checkbox",
name: "articleTags",
list: checkboxes
});
 
// append any custom tags
form.append({ type: 'header', label:'鲜用模板' });
if (Twinkle.getFriendlyPref('customTagList').length) {
form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.tag.rareList });
container.append({ type: 'header', label: '自定義模板' });
break;
container.append({ type: 'checkbox', name: 'articleTags', list: Twinkle.getFriendlyPref('customTagList') });
 
default:
alert("Twinkle.tag:未知模式 " + Twinkle.tag.mode);
break;
}
 
var $workarea = $(form).find("div#tagWorkArea");
form.append( { type:'submit' } );
var rendered = container.render();
$workarea.empty().append(rendered);
 
// style adjustments
$workarea.find("h5").css({ 'font-size': '110%' });
$workarea.find("h5:not(:first-child)").css({ 'margin-top': '1em' });
$workarea.find("div").filter(":has(span.quickformDescription)").css({ 'margin-top': '0.4em' });
 
// add a link to each template's description page
$.each(Morebits.quickForm.getElements(form, "articleTags"), function(index, checkbox) {
var $checkbox = $(checkbox);
var link = Morebits.htmlNode("a", ">");
link.setAttribute("class", "tag-template-link");
link.setAttribute("href", mw.util.getUrl("Template:" +
Morebits.string.toUpperCaseFirstChar(checkbox.values)));
link.setAttribute("target", "_blank");
$checkbox.parent().append(["\u00A0", link]);
});
 
 
var result = form.render();
Line 114 ⟶ 143:
Window.display();
 
// fake a change event on the sort dropdown, to initialize the tag list
if (Twinkle.tag.mode === "条目") {
var evt = document.createEvent("Event");
// fake a change event on the sort dropdown, to initialize the tag list
evt.initEvent("change", true, true);
var evt = document.createEvent("Event");
evt.initEvent("change", true, true);
result.sortorder.dispatchEvent(evt);
}
};
 
Line 141 ⟶ 167:
}
switch (tag) {
case "merge":
case var "mergeotherTagName from= "併":;
case "merge to":
var otherTagName = "merge";
switch (tag)
{
case "merge from":
otherTagName = "merge to";
break;
case "merge to":
otherTagName = "merge from";
break;
}
checkbox.subgroup = [
{
name: 'mergeTarget',
type: 'input',
label: '其他条:',
tooltip: '如指定多个条目,请用管道符分隔:条目甲|条目乙'
},
{
Line 166 ⟶ 180:
list: [
{
label: '用{{' + otherTagName + '}}标记標記其他目',
checked: true,
tooltip: '仅在只输入了一个条目名时可用'
}
]
Line 177 ⟶ 190:
name: 'mergeReason',
type: 'textarea',
label: '合理由(会被贴上會附在條目的討論頁):' +,
tooltip: '請填寫理由。'
(tag === "merge to" ? '其他' : '这') + '条目的讨论页):',
tooltip: '可选,但强烈推荐。如不需要请留空。仅在只输入了一个条目名时可用。'
});
}
break;
case "notability文未準":
checkbox.subgroup = {};
name: 'notability',
type: 'select',
list: [
{ label: "{{notability}}:通用的关注度指引", value: "none" },
{ label: "{{notability|Biographies}}:人物传记", value: "Biographies" },
{ label: "{{notability|Book}}:书籍", value: "Book" },
{ label: "{{notability|Number}}:数字", value: "Number" },
{ label: "{{notability|Fiction}}:虚构事物", value: "Fiction" },
{ label: "{{notability|Neologisms}}:发明、研究", value: "Neologisms" },
{ label: "{{notability|Web}}:网站、网络内容", value: "Web"}
]
};
break;
default:
Line 204:
};
 
var checkboxes = [];
// categorical sort order
$.each(Twinkle.tag.article.tags, function(tag, description) {
if (sortorder === "cat") {
checkboxes.push(makeCheckbox(tag, description));
// function to iterate through the tags and create a checkbox for each one
});
var doCategoryCheckboxes = function(subdiv, array) {
container.append({
var checkboxes = [];
type: "checkbox",
$.each(array, function(k, tag) {
name: "articleTags",
var description = Twinkle.tag.article.tags[tag];
list: checkboxes
checkboxes.push(makeCheckbox(tag, description));
});
subdiv.append({
type: "checkbox",
name: "articleTags",
list: checkboxes
});
};
 
var i = 0;
// go through each category and sub-category and append lists of checkboxes
$.each(Twinkle.tag.article.tagCategories, function(title, content) {
container.append({ type: "header", id: "tagHeader" + i, label: title });
var subdiv = container.append({ type: "div", id: "tagSubdiv" + i++ });
if ($.isArray(content)) {
doCategoryCheckboxes(subdiv, content);
} else {
$.each(content, function(subtitle, subcontent) {
subdiv.append({ type: "div", label: [ Morebits.htmlNode("b", subtitle) ] });
doCategoryCheckboxes(subdiv, subcontent);
});
}
});
}
// alphabetical sort order
else {
var checkboxes = [];
$.each(Twinkle.tag.article.tags, function(tag, description) {
checkboxes.push(makeCheckbox(tag, description));
});
container.append({
type: "checkbox",
name: "articleTags",
list: checkboxes
});
}
 
// append any custom tags
if (Twinkle.getFriendlyPref('customTagList').length) {
container.append({ type: 'header', label: '自定模板' });
container.append({ type: 'checkbox', name: 'articleTags', list: Twinkle.getFriendlyPref('customTagList') });
}
Line 284 ⟶ 250:
 
Twinkle.tag.article.tags = {
'文白相雜': '文白相雜',
"advert": "类似广告或宣传性内容",
'繁簡相雜': '繁簡相雜',
"autobiography": "类似一篇自传,或内容主要由条目描述的当事人或组织撰写、编辑",
'遷': '議遷',
"blpdispute": "可能违反了维基百科关于生者传记的方针",
'併': '議併',
"blpsources": "生者传记需要补充更多可供查证的来源",
'無據': '是文無引據',
"blpunsourced": "生者传记没有列出任何参考或来源",
'文未準': '是文未準,須辨真偽、正文辭'
"catimprove": "需要更多页面分类",
"citation style": "引用需要进行清理",
"citecheck": "可能包含不适用或被曲解的引用资料,部分内容的准确性无法被证实",
"cleanup": "可能需要进行清理,以符合维基百科的质量标准",
"cleanup-jargon": "包含过多行话或专业术语,可能需要简化或提出进一步解释",
"coi": "主要贡献者与本条目所宣扬的内容可能存在利益冲突",
"copypaste": "内容可能是从某个来源处拷贝后贴上",
"contradict": "内容自相矛盾",
"copyedit": "需要编修,以确保文法、用词、语气、格式、标点等使用恰当",
"dead end": "需要更多内部连接以构筑百科全书的链接网络",
"disputed": "内容疑欠准确,有待查证",
"expand": "需要扩充",
"expert": "需要精通或熟悉本主题的专业人士参与及协助编辑",
"external links": "使用外部链接的方式可能不符合维基百科的方针或指引",
"fansite": "类似爱好者网页",
"globalize": "仅具有一部分地区的信息或观点",
"hoax": "真实性被质疑",
"howto": "包含指南或教学内容",
"in-universe": "使用小说故事内的观点描述一个虚构事物",
"inappropriate person": "使用不适当的第一人称和第二人称",
"inappropriate tone": "语调或风格可能不适合百科全书的写作方式",
"lead section": "导言部分也许不足以概括其内容",
"lead section too long": "导言部分也许过于冗长",
"merge": "建议此页面与页面合并",
"merge from": "建议将页面并入本页面",
"merge to": "建议将此页面并入页面",
"newsrelease": "阅读起来像是新闻稿及包含过度的宣传性语调",
"no footnotes": "因为没有内文引用而来源仍然不明",
"non-free": "可能过多或不当地使用了受版权保护的文字、图像或/及多媒体文件",
"notability": "可能不符合通用关注度指引",
"notmandarin": "包含过多不是现代标准汉语的内容",
"onesource": "极大或完全地依赖于某个单一的来源",
"original research": "可能包含原创研究或未查证内容",
"orphan": "没有或只有很少链入页面",
"overlinked": "含有过多、重复、或不必要的内部链接",
"overly detailed": "包含太多过度细节内容",
"plot": "可能包含过于详细的剧情摘要",
"pov": "中立性有争议。内容、语调可能带有明显的个人观点或地方色彩",
"primarysources": "依赖第一手来源",
"prose": "使用了日期或时间列表式记述,需要改写为连贯的叙述性文字",
"refimprove": "需要补充更多来源",
"review": "阅读起来类似评论,需要清理",
"rewrite": "不符合维基百科的质量标准,需要完全重写",
"roughtranslation": "翻译品质不佳",
"substub": "过于短小",
"trivia": "应避免有陈列杂项、琐碎资料的部分",
"uncategorized": "缺少页面分类",
"unencyclopedic": "可能不适合写入百科全书",
"unreferenced": "没有列出任何参考或来源",
"update": "当前条目或章节需要更新",
"verylong": "可能过于冗长",
"weasel": "语意模棱两可而损及其中立性或准确性"
};
 
Twinkle.tag.article.dispute = {
// A list of tags in order of category
'引據未準,須審讀': '引用的準確性無法核實',
// Tags should be in alphabetical order within the categories
'需纂以維基碼': '需要維基化',
// Add new categories with discretion - the list is long enough as is!
'文辭未準,須辨真偽': '真實性存疑',
 
'文中存纂者己見': '包含編者個人想法、原創研究等',
Twinkle.tag.article.tagCategories = {
'非中立': '中立性有問題'
"清理和维护模板": {
"常规清理": [
"cleanup",
"cleanup-jargon",
"copyedit"
],
"可能多余的内容": [
"copypaste",
"external links",
"non-free"
],
"结构和导言": [
"lead section",
"lead section too long",
"verylong"
],
"虚构作品相关清理": [
"in-universe",
"plot"
]
},
"常规条目问题": {
"重要性和知名度": [
"notability" // has subcategories and special-cased code
],
"写作风格": [
"advert",
"fansite",
"howto",
"inappropriate person",
"inappropriate tone",
"newsrelease",
"prose",
"review"
],
"内容": [
"expand",
"substub",
"unencyclopedic"
],
"信息和细节": [
"expert",
"overly detailed",
"trivia"
],
"时间性": [
"update"
],
"中立、偏见和事实准确性": [
"autobiography",
"coi",
"contradict",
"disputed",
"globalize",
"hoax",
"pov",
"weasel"
],
"可供查证和来源": [
"blpdispute",
"blpsources",
"blpunsourced",
"citecheck",
"no footnotes",
"onesource",
"original research",
"primarysources",
"refimprove",
"unreferenced"
]
},
"具体内容问题": {
"语言": [
"notmandarin",
"roughtranslation"
],
"链接": [
"dead end",
"orphan",
"overlinked"
],
"参考技术": [
"citation style"
],
"分类": [
"catimprove",
"uncategorized"
]
},
"合并": [ // these three have a subgroup with several options
"merge",
"merge from",
"merge to"
]
};
 
// Tags for REDIRECTS start here
 
Twinkle.tag.frequentList = [
{
label: '{{合并重定向}}:保持页面题名至相应主条目,令页面内容在合并后仍能保存其编辑历史',
value: '合并重定向'
},
{
label: '{{简繁重定向}}:引导简体至繁体,或繁体至简体',
value: '简繁重定向'
},
{
label: '{{模板重定向}}:指向模板的重定向页面',
value: '模板重定向'
},
{
label: '{{别名重定向}}:标题的其他名称、笔名、绰号、同义字等',
value: '别名重定向'
},
{
label: '{{译名重定向}}:人物、作品等各项事物的其他翻译名称',
value: '译名重定向'
},
{
label: '{{缩写重定向}}:标题缩写',
value: '缩写重定向'
},
{
label: '{{拼写重定向}}:标题的其他不同拼写',
value: '拼写重定向'
},
{
label: '{{错字重定向}}:纠正标题的常见错误拼写或误植',
value: '错字重定向'
},
{
label: '{{旧名重定向}}:将事物早前的名称引导至更改后的主题',
value: '旧名重定向'
},
{
label: '{{历史名称重定向}}:具有历史意义的别名、笔名、同义词',
value: '历史名称重定向'
},
{
label: '{{全名重定向}}:标题的完整或更完整名称',
value: '全名重定向'
},
{
label: '{{短名重定向}}:完整标题名称或人物全名的部分、不完整的名称或简称',
value: '短名重定向'
},
{
label: '{{姓氏重定向}}:人物姓氏',
value: '姓氏重定向'
},
{
label: '{{名字重定向}}:人物人名',
value: '名字重定向'
},
{
label: '{{本名重定向}}:人物本名',
value: '本名重定向'
},
{
label: '{{非中文重定向}}:非中文标题',
value: '非中文重定向'
},
{
label: '{{日文重定向}}:日语名称',
value: '日文重定向'
}
];
 
Twinkle.tag.lessFrequentList = [
{
label: '{{角色重定向}}:电视剧、电影、书籍等作品的角色',
value: '角色重定向'
},
{
label: '{{章节重定向}}:导向至较高密度组织的页面',
value: '章节重定向'
},
{
label: '{{列表重定向}}:导向至低密度的列表',
value: '列表重定向'
},
{
label: '{{可能性重定向}}:导向至当前提供内容更为详尽的目标页面',
value: '可能性重定向'
},
{
label: '{{关联字重定向}}:标题名称关联字',
value: '关联字重定向'
},
{
label: '{{条目请求重定向}}:需要独立条目的页面',
value: '条目请求重定向'
},
{
label: '{{快捷方式重定向}}:维基百科快捷方式',
value: '快捷方式重定向'
}
];
 
Twinkle.tag.rareList = [
{
label: '{{词组重定向}}:将词组/词组/成语指向切题的条目及恰当章节',
value: '词组重定向'
},
{
label: '{{消歧义页重定向}}:指向消歧义页',
value: '消歧义页重定向'
},
{
label: '{{域名重定向}}:网域名称',
value: '域名重定向'
},
{
label: '{{年代重定向}}:于年份条目导向至年代条目',
value: '年代重定向'
},
{
label: '{{用户框模板重定向}}:用户框模板',
value: '用户框模板重定向'
},
{
label: '{{重定向模板用重定向}}:导向至重定向模板',
value: '重定向模板用重定向'
},
{
label: '{{EXIF重定向}}:JPEG图像包含EXIF信息',
value: 'EXIF重定向'
}
];
 
 
// Contains those article tags that *do not* work inside {{multiple issues}}.
Twinkle.tag.multipleIssuesExceptions = [
'catimprove',
'merge',
'merge from',
'merge to',
'notability',
'notmandarin',
"substub",
'uncategorized'
];
 
 
Twinkle.tag.callbacks = {
Line 604 ⟶ 277:
var addTag = function friendlytagAddTag( tagIndex, tagName ) {
var currentTag = "";
if( tagName === 'uncategorized' || tagName === 'catimprove文白相雜' ) {
pageText += '\n\n{{' + tagName + '|~~~~}}\n';
'|time={{subst:#time:c}}}}';
} else {
currentTag += ( Twinkle.tag.mode === '重定向' ? '\n' : '' ) + '{{' + tagName;
 
if( tagName === 'notability' && params.tagParameters.notability !== 'none' ) {
currentTag += '|||' + params.tagParameters.notability;
}
 
// prompt for other parameters, based on the tag
Line 632 ⟶ 300:
// nonDiscussArticle is the article which won't have the discussion
params.nonDiscussArticle = (tagName === "merge to" ? mw.config.get('wgTitle') : params.mergeTarget);
params.talkDiscussionTitle = '请求与' + params.nonDiscussArticle + '合';
}
currentTag += '|discuss=Talk:' + params.discussArticle + '#' + params.talkDiscussionTitle;
Line 642 ⟶ 310:
}
 
currentTag += (Twinkle.tag.mode === '重定向') ? '}}' : '|time={{subst:#time:c}}}}\n';
tagText += currentTag;
}
Line 648 ⟶ 316:
if ( tagIndex > 0 ) {
if( tagIndex === (totalTags - 1) ) {
summaryText += '';
} else if ( tagIndex < (totalTags - 1) ) {
summaryText += '、';
Line 659 ⟶ 327:
};
 
// Check for preexisting tags and separate tags into groupable and non-groupable arrays
if( Twinkle.tag.mode !== '重定向' ) {
for( i = 0; i < params.tags.length; i++ ) {
// Check for preexisting tags and separate tags into groupable and non-groupable arrays
tagRe = new RegExp( '(\\{\\{' + params.tags[i] + '(\\||\\}\\})|\\|\\s*' + params.tags[i] + '\\s*=[a-z ]+\\d+)', 'im' );
for( i = 0; i < params.tags.length; i++ ) {
if( !tagRe.exec( pageText ) ) {
tagRe = new RegExp( '(\\{\\{' + params.tags[i] + '(\\||\\}\\})|\\|\\s*' + params.tags[i] + '\\s*=[a-z ]+\\d+)', 'im' );
if( Twinkle.tag.multipleIssuesExceptions.indexOf(params.tags[i]) === -1 ) {
if( !tagRe.exec( pageText ) ) {
ifgroupableTags = groupableTags.concat( params.tags[i] == 'notability' ) {;
wikipedia_page = new Morebits.wiki.page("Wikipedia:关注度/提报", "添加关注度记录项");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.tag.callbacks.notabilityList);
}
if( Twinkle.tag.multipleIssuesExceptions.indexOf(params.tags[i]) === -1 ) {
groupableTags = groupableTags.concat( params.tags[i] );
} else {
tags = tags.concat( params.tags[i] );
}
} else {
Morebits.status.warn(tags '信息',= '在页面上找到{{' +tags.concat( params.tags[i] +);
'}}…跳过' );
// don't do anything else with merge tags
if (params.tags[i] === "merge" || params.tags[i] === "merge from" ||
params.tags[i] === "merge to") {
params.mergeTarget = params.mergeReason = params.mergeTagOther = false;
}
}
}
 
var miTest = /\{\{(multiple ?issues|article ?issues|mi)[^}]+\{/im.exec(pageText);
var miOldStyleRegex = /\{\{(multiple ?issues|article ?issues|mi)\s*\|([^{]+)\}\}/im;
var miOldStyleTest = miOldStyleRegex.exec(pageText);
 
if( ( miTest || miOldStyleTest ) && groupableTags.length > 0 ) {
Morebits.status.info( '信息', '添加支持的标记入已存在的{{multiple issues}}' );
 
groupableTags.sort();
tagText = "";
 
totalTags = groupableTags.length;
$.each(groupableTags, addTag);
 
summaryText += '标记' + '(在{{[[T:multiple issues|multiple issues]]}}内)';
if( tags.length > 0 ) {
summaryText += '和';
}
 
if( miOldStyleTest ) {
// convert tags from old-style to new-style
var split = miOldStyleTest[2].split("|");
$.each(split, function(index, val) {
split[index] = val.replace("=", "|time=").trim();
});
pageText = pageText.replace(miOldStyleRegex, "{{$1|\n{{" + split.join("}}\n{{") + "}}\n" + tagText + "}}\n");
} else {
var miRegex = new RegExp("(\\{\\{\\s*" + miTest[1] + "\\s*(?:\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?)\\}\\}\\s*", "im");
pageText = pageText.replace(miRegex, "$1" + tagText + "}}\n");
}
tagText = "";
} else if( params.group && groupableTags.length >= 3 ) {
Morebits.status.info( '信息', '合并支持的模板入{{multiple issues}}' );
 
groupableTags.sort();
tagText += '{{multiple issues|\n';
 
totalTags = groupableTags.length;
$.each(groupableTags, addTag);
 
summaryText += '等标记({{[[T:multiple issues|multiple issues]]}})';
if( tags.length > 0 ) {
summaryText += '及';
}
tagText += '}}\n';
} else {
Morebits.status.warn( '信息', '在頁面上找到{{' + params.tags[i] +
tags = tags.concat( groupableTags );
'}}…跳过' );
}
// don't do anything else with merge tags
} else {
if (params.tags[i] === "merge" || params.tags[i] === "merge from" ||
// Redirect tagging: Check for pre-existing tags
params.tags[i] === "merge to") {
for( i = 0; i < params.tags.length; i++ ) {
params.mergeTarget = params.mergeReason = params.mergeTagOther = false;
tagRe = new RegExp( '(\\{\\{' + params.tags[i] + '(\\||\\}\\}))', 'im' );
if( !tagRe.exec( pageText ) ) {
tags = tags.concat( params.tags[i] );
} else {
Morebits.status.warn( '信息', '在重定向上找到{{' + params.tags[i] +
'}}…跳过' );
}
}
}
 
var miTest = /\{\{(multiple ?issues|article ?issues|mi)[^}]+\{/im.exec(pageText);
var miOldStyleRegex = /\{\{(multiple ?issues|article ?issues|mi)\s*\|([^{]+)\}\}/im;
var miOldStyleTest = miOldStyleRegex.exec(pageText);
 
tags = tags.concat( groupableTags );
 
tags.sort();
Line 750 ⟶ 357:
$.each(tags, addTag);
 
// smartly insert the new tags after any hatnotes. Regex is a bit more
if( Twinkle.tag.mode === '重定向' ) {
// complicated than it'd need to be, to allow templates as parameters,
pageText += tagText;
// and to handle whitespace properly.
} else {
pageText = pageText.replace(/^\s*(?:((?:\s*\{\{\s*(?:about|correct title|dablink|distinguish|for|other\s?(?:hurricaneuses|people|persons|places|uses(?:of)?)|redirect(?:-acronym)?|see\s?(?:also|wiktionary)|selfref|the)\d*\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\})+(?:\s*\n)?)\s*)?/i,
// smartly insert the new tags after any hatnotes. Regex is a bit more
// complicated than it'd need to be, to allow templates as parameters,
// and to handle whitespace properly.
pageText = pageText.replace(/^\s*(?:((?:\s*\{\{\s*(?:about|correct title|dablink|distinguish|for|other\s?(?:hurricaneuses|people|persons|places|uses(?:of)?)|redirect(?:-acronym)?|see\s?(?:also|wiktionary)|selfref|the)\d*\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\})+(?:\s*\n)?)\s*)?/i,
"$1" + tagText);
 
}
summaryText += ( tags.length > 0 ? '标记標記' : '' ) +
'至文章';
'到' + Twinkle.tag.mode;
 
// avoid truncated summaries
Line 776 ⟶ 380:
if (params.mergeReason) {
// post the rationale on the talk page (only operates in main namespace)
var talkpageText = "\n\n== 请求与議與[[" + params.nonDiscussArticle + "]]合 ==\n\n";
talkpageText += params.mergeReason.trim() + "--~~~~";
 
var talkpage = new Morebits.wiki.page("Talk:" + params.discussArticle, "理由讨论页討論頁");
talkpage.setAppendText(talkpageText);
talkpage.setEditSummary('请求将議將[[' + params.nonDiscussArticle + ']]' +
'' + '[[' + params.discussArticle + ']]合并' +
Twinkle.getPref('summaryAd'));
talkpage.setWatchlist(Twinkle.getFriendlyPref('watchMergeDiscussions'));
Line 802 ⟶ 406:
talkDiscussionTitle: params.talkDiscussionTitle
};
var otherpage = new Morebits.wiki.page(params.mergeTarget, "标记標記其他面(" +
params.mergeTarget + ")");
otherpage.setCallbackParameters(newParams);
Line 812 ⟶ 416:
pageobj.patrol();
}
},
 
notabilityList: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
 
pageobj.setAppendText("\n{{subst:Wikipedia:关注度/提报/item|title=" + Morebits.pageNameNorm + "}}");
pageobj.setEditSummary("添加[[" + Morebits.pageNameNorm + "]]" + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('recreate');
pageobj.append();
}
};
Line 832 ⟶ 426:
}
 
params.tags = form.getChecked( 'articleTags' );
switch (Twinkle.tag.mode) {
params.group = form.group.checked;
case '条目':
params.tagParameters = {
params.tags = form.getChecked( 'articleTags' );
notability: form["articleTags.notability"] ? form["articleTags.notability"].value : null
params.group = form.group.checked;
};
params.tagParameters = {
// common to {{merge}}, {{merge from}}, {{merge to}}
notability: form["articleTags.notability"] ? form["articleTags.notability"].value : null
params.mergeTarget = form["articleTags.mergeTarget"] ? form["articleTags.mergeTarget"].value : null;
};
params.mergeReason = form["articleTags.mergeReason"] ? form["articleTags.mergeReason"].value : null;
// common to {{merge}}, {{merge from}}, {{merge to}}
params.mergeTargetmergeTagOther = form["articleTags.mergeTargetmergeTagOther"] ? form["articleTags.mergeTargetmergeTagOther"].valuechecked : nullfalse;
params.mergeReason = form["articleTags.mergeReason"] ? form["articleTags.mergeReason"].value : null;
params.mergeTagOther = form["articleTags.mergeTagOther"] ? form["articleTags.mergeTagOther"].checked : false;
break;
case '重定向':
params.tags = form.getChecked( 'redirectTags' );
break;
default:
alert("Twinkle.tag:未知模式 " + Twinkle.tag.mode);
break;
}
 
// form validation
if( !params.tags.length ) {
alert( '必须选择至少一个标记標記!' );
return;
}
if( ((params.tags.indexOf("merge") !== -1) + (params.tags.indexOf("merge from") !== -1) +
(params.tags.indexOf("merge to") !== -1)) > 1 ) {
alert( '请在{{merge}}、{{merge from}}和{{merge to}}中选择一个。如果需要多次合,请使用{{merge}}并用管道符分隔目名(但在这种情形中Twinkle不能自动标记標記其他目)。' );
return;
}
if( (params.mergeTagOther || params.mergeReason) && params.mergeTarget.indexOf('|') !== -1 ) {
alert( '目前还不支持在一次合标记標記多个目,与开启关于多个目的讨论。请不要勾选“标记標記其他目”和/或清理“理由”框,并重试。' );
return;
}
Line 871 ⟶ 455:
 
Morebits.wiki.actionCompleted.redirect = Morebits.pageNameNorm;
Morebits.wiki.actionCompleted.notice = "标记標記完成,在几秒内刷新面";
if (Twinkle.tag.mode === '重定向') {
Morebits.wiki.actionCompleted.followRedirect = false;
}
 
var wikipedia_page = new Morebits.wiki.page(Morebits.pageNameNorm, "正在标记標記條目" + Twinkle.tag.mode);
wikipedia_page.setCallbackParameters(params);
switch wikipedia_page.load(Twinkle.tag.modecallbacks.main) {;
case '条目':
/* falls through */
case '重定向':
wikipedia_page.load(Twinkle.tag.callbacks.main);
return;
default:
alert("Twinkle.tag:未知模式 " + Twinkle.tag.mode);
break;
}
};
})(jQuery);