MediaWiki:Gadget-friendlytag.js:修订间差异

MediaWiki系统消息页面
(撤销Zorua Fox讨论)的版本4077)
标签撤销
(Git更新:([https://github.com/TopRealm/Twinkle/commit/262b727344bb9060f6d9cf509dda4075faf5e39a 262b727]) fix: namespaces' numbers)
 
(未显示2个用户的10个中间版本)
第3行: 第3行:
* _addText: '{{Twinkle Header}}'
* _addText: '{{Twinkle Header}}'
*
*
* @source https://git.qiuwen.wiki/InterfaceAdmin/Twinkle
* @base <https://git.qiuwen.wiki/InterfaceAdmin/Twinkle>
* @source https://git.qiuwen.wiki/Mirror/xiplus-twinkle
* @source <https://github.com/TopRealm/Twinkle>
*/
* @author © 2011-2022 English Wikipedia Contributors
/**
* @author © 2021-2023 Chinese Wikipedia Contributors
* +--------------------------------------------------------+
* @author © 2021-2023 Qiuwen Baike Contributors
* | === WARNING: GLOBAL GADGET FILE === |
* @license <https://creativecommons.org/licenses/by-sa/4.0/>
* +--------------------------------------------------------+
* | All changes should be made in the repository, |
* | otherwise they will be lost. |
* +--------------------------------------------------------+
* | Changes to this page may affect many users. |
* | Please discuss changes at talk page before editing. |
* +--------------------------------------------------------+
*/
*/
/* Twinkle.js - friendlytag.js */
/* <nowiki> */
/* <nowiki> */
/* Twinkle.js - friendlytag.js */
(function ($) {
(function ($) {
/**
/**
* friendlytag.js: Tag module
* friendlytag.js: Tag module
* Mode of invocation: Tab ("Tag")
* Mode of invocation: Tab ("Tag")
* Active on: Existing articles and drafts; file pages with a corresponding file
* Active on: Existing articles and drafts; file pages with a corresponding file
* which is local (not on Share); all redirects
* which is local (not on Share); all redirects
*/
*/
Twinkle.tag = function () {
Twinkle.tag = function () {
// redirect tagging
// redirect tagging
if (Morebits.isPageRedirect()) {
if (Morebits.isPageRedirect()) {
Twinkle.tag.mode = '重定向';
Twinkle.tag.mode = wgULS('重定向', '重新導向');
Twinkle.addPortletLink(Twinkle.tag.callback, '标记', 'friendly-tag', '标记重定向');
Twinkle.tag.modeEn = 'redirect';
Twinkle.addPortletLink(Twinkle.tag.callback, wgULS('标记', '標記'), 'friendly-tag', wgULS('标记重定向', '標記重新導向'));
// file tagging
// file tagging
} else if (mw.config.get('wgNamespaceNumber') === 6 && !document.querySelector('#mw-sharedupload') && document.querySelector('#mw-imagepage-section-filehistory')) {
Twinkle.tag.mode = '文件';
}
else if (mw.config.get('wgNamespaceNumber') === 6 &&
Twinkle.addPortletLink(Twinkle.tag.callback, '标记', 'friendly-tag', '为文件添加或移除标记');
!document.getElementById('mw-sharedupload') &&
// article/draft tagging
document.getElementById('mw-imagepage-section-filehistory')) {
} else if ([0, 118].includes(mw.config.get('wgNamespaceNumber')) && mw.config.get('wgCurRevisionId') || Morebits.pageNameNorm === Twinkle.getPref('sandboxPage')) {
Twinkle.tag.mode = '条目';
Twinkle.tag.mode = wgULS('文件', '檔案');
Twinkle.tag.modeEn = 'file';
// Can't remove tags when not viewing current version
Twinkle.addPortletLink(Twinkle.tag.callback, wgULS('标记', '標記'), 'friendly-tag', wgULS('标记文件', '標記檔案'));
Twinkle.tag.canRemove = mw.config.get('wgCurRevisionId') === mw.config.get('wgRevisionId') &&
// article/draft tagging
// Disabled on latest diff because the diff slider could be used to slide
}
// away from the latest diff without causing the script to reload
!mw.config.get('wgDiffNewId');
else if (([0, 302].includes(mw.config.get('wgNamespaceNumber')) && mw.config.get('wgCurRevisionId')) ||
Morebits.pageNameNorm === Twinkle.getPref('sandboxPage')) {
Twinkle.addPortletLink(Twinkle.tag.callback, '标记', 'friendly-tag', '为条目或移除添加标记');
Twinkle.tag.mode = wgULS('条目', '條目');
}
Twinkle.tag.modeEn = 'article';
};
// Can't remove tags when not viewing current version
Twinkle.tag.checkedTags = [];
Twinkle.tag.callback = function () {
Twinkle.tag.canRemove =
mw.config.get('wgCurRevisionId') === mw.config.get('wgRevisionId') &&
var Window = new Morebits.simpleWindow(630, Twinkle.tag.mode === '条目' ? 500 : 400);
// Disabled on latest diff because the diff slider could be used to slide
Window.setScriptName('Twinkle');
// away from the latest diff without causing the script to reload
// anyone got a good policy/guideline/info page/instructional page link?
!mw.config.get('wgDiffNewId');
Window.addFooterLink('参数设置', 'H:TW/PREF#tag');
Twinkle.addPortletLink(Twinkle.tag.callback, wgULS('标记', '標記'), 'friendly-tag', wgULS('标记条目', '標記條目'));
Window.addFooterLink('帮助文档', 'H:TW/DOC#tag');
}
Window.addFooterLink('问题反馈', 'HT:TW');
};
var form = new Morebits.quickForm(Twinkle.tag.callback.evaluate);
Twinkle.tag.checkedTags = [];
form.append({
Twinkle.tag.callback = function () {
type: 'input',
var Window = new Morebits.simpleWindow(630, Twinkle.tag.modeEn === 'article' ? 500 : 400);
label: '筛选标记列表:',
Window.setScriptName('Twinkle');
name: 'quickfilter',
Window.addFooterLink(wgULS('标记设置', '標記設定'), 'H:TW/PREF#tag');
size: '30',
Window.addFooterLink(wgULS('Twinkle帮助', 'Twinkle說明'), 'H:TW/DOC#tag');
event: function event() {
var form = new Morebits.quickForm(Twinkle.tag.callback.evaluate);
// flush the DOM of all existing underline spans
form.append({
$allCheckboxDivs.find('.search-hit').each(function (_i, e) {
var label_element = e.parentElement;
type: 'input',
label: wgULS('筛选标记列表:', '篩選標記列表:'),
// This would convert <label>Hello <span class=search-hit>wo</span>rld</label>
// to <label>Hello world</label>
name: 'quickfilter',
size: '30',
label_element.innerHTML = label_element.textContent;
event: function twinkletagquickfilter() {
// flush the DOM of all existing underline spans
$allCheckboxDivs.find('.search-hit').each(function (i, e) {
var label_element = e.parentElement;
// This would convert <label>Hello <span class=search-hit>wo</span>rld</label>
// to <label>Hello world</label>
label_element.innerHTML = label_element.textContent;
});
if (this.value) {
$allCheckboxDivs.hide();
$allHeaders.hide();
var searchString_1 = this.value;
var searchRegex_1 = new RegExp(mw.util.escapeRegExp(searchString_1), 'i');
$allCheckboxDivs.find('label').each(function (_index, element) {
var label_text = element.textContent;
var searchHit = searchRegex_1.exec(label_text);
if (searchHit) {
var range = document.createRange();
var textnode = element.childNodes[0];
range.selectNodeContents(textnode);
range.setStart(textnode, searchHit.index);
range.setEnd(textnode, searchHit.index + searchString_1.length);
var underline_span = $('<span>')
.addClass('search-hit')
.css('text-decoration', 'underline')[0];
range.surroundContents(underline_span);
element.parentElement.style.display = 'block'; // show
}
});
}
else {
$allCheckboxDivs.show();
$allHeaders.show();
}
},
});
});
if (this.value) {
switch (Twinkle.tag.modeEn) {
$allCheckboxDivs.hide();
case 'article':
Window.setTitle(wgULS('条目维护标记', '條目維護標記'));
$allHeaders.hide();
// Build sorting and lookup object flatObject, which is always
var searchString = this.value;
// needed but also used to generate the alphabetical list
var searchRegex = new RegExp(mw.util.escapeRegExp(searchString), 'i');
// Would be infinitely better with Object.values, but, alas, IE 11
$allCheckboxDivs.find('label').each(function () {
var label_text = this.textContent;
Twinkle.tag.article.flatObject = {};
var searchHit = searchRegex.exec(label_text);
Twinkle.tag.article.tagList.forEach(function (group) {
if (searchHit) {
group.value.forEach(function (subgroup) {
var range = document.createRange();
if (subgroup.value) {
var textnode = this.childNodes[0];
subgroup.value.forEach(function (item) {
Twinkle.tag.article.flatObject[item.tag] = {
range.selectNodeContents(textnode);
description: item.description,
range.setStart(textnode, searchHit.index);
excludeMI: !!item.excludeMI,
range.setEnd(textnode, searchHit.index + searchString.length);
};
var underline_span = $('<span>').addClass('search-hit').css('text-decoration', 'underline')[0];
range.surroundContents(underline_span);
});
this.parentElement.style.display = 'block'; // show
}
else {
Twinkle.tag.article.flatObject[subgroup.tag] = {
description: subgroup.description,
excludeMI: !!subgroup.excludeMI,
};
}
});
});
form.append({
type: 'select',
name: 'sortorder',
label: wgULS('查看列表:', '檢視列表:'),
tooltip: wgULS('您可以在Twinkle参数设置(H:TW/PREF)中更改此项。', '您可以在Twinkle偏好設定(H:TW/PREF)中更改此項。'),
event: Twinkle.tag.updateSortOrder,
list: [
{
type: 'option',
value: 'cat',
label: wgULS('按类型', '按類別'),
selected: Twinkle.getPref('tagArticleSortOrder') === 'cat',
},
{
type: 'option',
value: 'alpha',
label: '按字母',
selected: Twinkle.getPref('tagArticleSortOrder') === 'alpha',
},
],
});
if (!Twinkle.tag.canRemove) {
var divElement = document.createElement('div');
divElement.innerHTML = wgULS('要移除现有维护标记,请从当前条目版本中打开“标记”菜单', '要移除現有維護標記,請從目前條目版本中打開「標記」選單');
form.append({
type: 'div',
name: 'untagnotice',
label: divElement,
});
}
form.append({
type: 'div',
id: 'tagWorkArea',
className: 'morebits-scrollbox',
style: 'max-height: 28em',
});
form.append({
type: 'checkbox',
list: [
{
label: wgULS('如可能,合并入{{multiple issues}}', '如可能,合併入{{multiple issues}}'),
value: 'group',
name: 'group',
tooltip: wgULS('若加入{{multiple issues}}支持的三个以上的模板,所有支持的模板都会被合并入{{multiple issues}}模板中。', '若加入{{multiple issues}}支援的三個以上的模板,所有支援的模板都會被合併入{{multiple issues}}模板中。'),
checked: Twinkle.getPref('groupByDefault'),
},
],
});
form.append({
type: 'input',
label: '理由:',
name: 'reason',
tooltip: wgULS('附加于编辑摘要的可选理由,例如指出条目内容的哪些部分有问题或移除模板的理由,但若理由很长则应该发表在讨论页。', '附加於編輯摘要的可選理由,例如指出條目內容的哪些部分有問題或移除模板的理由,但若理由很長則應該發表在討論頁。'),
size: '80',
});
break;
case 'file':
Window.setTitle(wgULS('文件维护标记', '檔案維護標記'));
Twinkle.tag.fileList.forEach(function (group) {
if (group.buildFilename) {
group.value.forEach(function (el) {
el.subgroup = {
type: 'input',
label: wgULS('替换的文件:', '替換的檔案:'),
tooltip: wgULS('输入替换此文件的文件名称(必填)', '輸入替換此檔案的檔案名稱(必填)'),
name: "".concat(el.value.replace(/ /g, '_'), "File"),
};
});
}
form.append({
type: 'header',
label: group.key,
});
form.append({
type: 'checkbox',
name: 'tags',
list: group.value,
});
});
if (Twinkle.getPref('customFileTagList').length) {
form.append({
type: 'header',
label: wgULS('自定义模板', '自訂模板'),
});
form.append({
type: 'checkbox',
name: 'tags',
list: Twinkle.getPref('customFileTagList'),
});
}
break;
case 'redirect': {
Window.setTitle(wgULS('重定向标记', '重新導向標記'));
var i_1 = 1;
Twinkle.tag.redirectList.forEach(function (group) {
form.append({
type: 'header',
id: "tagHeader".concat(i_1),
label: group.key,
});
form.append({
type: 'checkbox',
name: 'tags',
list: group.value.map(function (item) { return ({
value: item.tag,
label: "{{".concat(item.tag, "}}\uFF1A").concat(item.description),
subgroup: item.subgroup,
}); }),
});
});
if (Twinkle.getPref('customRedirectTagList').length) {
form.append({
type: 'header',
label: wgULS('自定义模板', '自訂模板'),
});
form.append({
type: 'checkbox',
name: 'tags',
list: Twinkle.getPref('customRedirectTagList'),
});
}
break;
}
}
});
default:
mw.notify("Twinkle.tag\uFF1A\u672A\u77E5\u6A21\u5F0F ".concat(Twinkle.tag.mode), {
} else {
$allCheckboxDivs.show();
type: 'warn',
$allHeaders.show();
tag: 'friendlytag',
}
}
});
switch (Twinkle.tag.mode) {
case '条目':
{
Window.setTitle('条目维护标记');
// Build sorting and lookup object flatObject, which is always
// needed but also used to generate the alphabetical list
// Would be infinitely better with Object.values, but, alas, IE 11
Twinkle.tag.article.flatObject = {};
Twinkle.tag.article.tagList.forEach(function (group) {
group.value.forEach(function (subgroup) {
if (subgroup.value) {
subgroup.value.forEach(function (item) {
Twinkle.tag.article.flatObject[item.tag] = {
description: item.description,
excludeMI: !!item.excludeMI
};
});
});
} else {
break;
}
Twinkle.tag.article.flatObject[subgroup.tag] = {
if (document.getElementsByClassName('patrollink').length) {
description: subgroup.description,
excludeMI: !!subgroup.excludeMI
};
}
});
});
form.append({
type: 'select',
name: 'sortorder',
label: '查看列表:',
tooltip: '您可以在Twinkle参数设置(H:TW/PREF)中更改此项。',
event: Twinkle.tag.updateSortOrder,
list: [{
type: 'option',
value: 'cat',
label: '按类型',
selected: Twinkle.getPref('tagArticleSortOrder') === 'cat'
}, {
type: 'option',
value: 'alpha',
label: '按字母顺序',
selected: Twinkle.getPref('tagArticleSortOrder') === 'alpha'
}]
});
if (!Twinkle.tag.canRemove) {
var divElement = document.createElement('div');
divElement.innerHTML = '要移除现有维护标记,请从当前条目版本中打开“标记”菜单';
form.append({
form.append({
type: 'div',
type: 'checkbox',
name: 'untagnotice',
list: [
label: divElement
{
label: wgULS('标记页面为已巡查', '標記頁面為已巡查'),
value: 'patrol',
name: 'patrol',
checked: Twinkle.getPref('markTaggedPagesAsPatrolled'),
},
],
});
});
}
form.append({
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.getPref('groupByDefault')
}]
});
form.append({
type: 'input',
label: '理由:',
name: 'reason',
tooltip: '附加于编辑摘要的可选理由,例如指出条目内容的哪些部分有问题或移除模板的理由,但若理由很长则应该发表在讨论页。',
size: '80'
});
break;
}
}
case '文件':
form.append({
{
type: 'submit',
Window.setTitle('文件维护标记');
className: 'tw-tag-submit',
});
Twinkle.tag.fileList.forEach(function (group) {
if (group.buildFilename) {
var result = form.render();
group.value.forEach(function (el) {
Window.setContent(result);
el.subgroup = {
Window.display();
type: 'input',
// for quick filter:
$allCheckboxDivs = $(result).find('[name$=tags]').parent();
label: '替换的文件:',
$allHeaders = $(result).find('h5');
tooltip: '输入替换此文件的文件名称(必填)',
result.quickfilter.focus(); // place cursor in the quick filter field as soon as window is opened
name: "".concat(el.value.replace(/ /g, '_'), "File")
result.quickfilter.autocomplete = 'off'; // disable browser suggestions
};
result.quickfilter.addEventListener('keypress', function (e) {
});
if (e.keyCode === 13) {
// prevent enter key from accidentally submitting the form
e.preventDefault();
return false;
}
}
form.append({
});
type: 'header',
if (Twinkle.tag.modeEn === 'article') {
label: group.key
Twinkle.tag.alreadyPresentTags = [];
if (Twinkle.tag.canRemove) {
// Look for existing maintenance tags in the lead section and put them in array
// All tags are HTML table elements that are direct children of .mw-parser-output,
// except when they are within {{multiple issues}}
$('.mw-parser-output')
.children()
.each(function (i, e) {
// break out on encountering the first heading, which means we are no
// longer in the lead section
if (e.tagName === 'H2') {
return false;
}
// The ability to remove tags depends on the template's {{ambox}} |name=
// parameter bearing the template's correct name (preferably) or a name that at
// least redirects to the actual name
// All tags have their first class name as "box-" + template name
if (e.className.indexOf('box-') === 0) {
if (e.classList[0] === 'box-问题条目') {
$(e)
.find('.ambox')
.each(function (idx, e) {
if (e.classList[0].indexOf('box-') === 0) {
var tag_1 = e.classList[0].slice('box-'.length).replace(/_/g, ' ');
Twinkle.tag.alreadyPresentTags.push(tag_1);
}
});
return true; // continue
}
var tag = e.classList[0].slice('box-'.length).replace(/_/g, ' ');
Twinkle.tag.alreadyPresentTags.push(tag);
}
});
// {{Uncategorized}} and {{Improve categories}} are usually placed at the end
if ($('.box-Uncategorized').length) {
Twinkle.tag.alreadyPresentTags.push('Uncategorized');
}
if ($('.box-Improve_categories').length) {
Twinkle.tag.alreadyPresentTags.push('Improve categories');
}
}
// Add status text node after Submit button
var statusNode = document.createElement('span');
statusNode.style.fontSize = '90%';
statusNode.id = 'tw-tag-status';
Twinkle.tag.status = {
// initial state; defined like this because these need to be available for reference
// in the click event handler
numAdded: 0,
numRemoved: 0,
};
$('button.tw-tag-submit').after(statusNode);
// fake a change event on the sort dropdown, to initialize the tag list
var evt = document.createEvent('Event');
evt.initEvent('change', true, true);
result.sortorder.dispatchEvent(evt);
}
else {
// Redirects and files: Add a link to each template's description page
Morebits.quickForm.getElements(result, 'tags').forEach(generateLinks);
}
};
// $allCheckboxDivs and $allHeaders are defined globally, rather than in the
// quickfilter event function, to avoid having to recompute them on every keydown
var $allCheckboxDivs;
var $allHeaders;
Twinkle.tag.updateSortOrder = function (e) {
var form = e.target.form;
var sortorder = e.target.value;
Twinkle.tag.checkedTags = form.getChecked('tags');
var container = new Morebits.quickForm.element({
type: 'fragment',
});
// function to generate a checkbox, with appropriate subgroup if needed
var makeCheckbox = function (tag, description) {
var checkbox = {
value: tag,
label: "{{".concat(tag, "}}: ").concat(description),
};
if (Twinkle.tag.checkedTags.includes(tag)) {
checkbox.checked = true;
}
switch (tag) {
case 'Merge':
case 'Merge from':
case 'Merge to': {
var otherTagName = 'Merge';
switch (tag) {
case 'Merge from':
otherTagName = 'Merge to';
break;
case 'Merge to':
otherTagName = 'Merge from';
break;
// no default
}
checkbox.subgroup = [
{
name: 'mergeTarget',
type: 'input',
label: wgULS('其他条目:', '其他條目:'),
tooltip: wgULS('如指定多个条目,请用管道符分隔:条目甲|条目乙', '如指定多個條目,請用管道符分隔:條目甲|條目乙'),
},
{
type: 'checkbox',
list: [
{
name: 'mergeTagOther',
label: "\u7528{{".concat(otherTagName).concat(wgULS('}}标记其他条目', '}}標記其他條目')),
checked: true,
tooltip: wgULS('仅在只输入了一个条目名时可用', '僅在只輸入了一個條目名時可用'),
},
],
},
];
if (mw.config.get('wgNamespaceNumber') === 0) {
checkbox.subgroup.push({
name: 'mergeReason',
type: 'textarea',
label: wgULS("\u5408\u5E76\u7406\u7531\uFF08\u4F1A\u88AB\u8D34\u4E0A".concat(tag === 'Merge to' ? '其他' : '这', "\u6761\u76EE\u7684\u8BA8\u8BBA\u9875\uFF09\uFF1A"), "\u5408\u4F75\u7406\u7531\uFF08\u6703\u88AB\u8CBC\u4E0A".concat(tag === 'Merge to' ? '其他' : '這', "\u689D\u76EE\u7684\u8A0E\u8AD6\u9801\uFF09\uFF1A")),
tooltip: wgULS('可选,但强烈推荐。如不需要请留空。仅在只输入了一个条目名时可用。', '可選,但強烈推薦。如不需要請留空。僅在只輸入了一個條目名時可用。'),
});
}
break;
}
case 'Missing information':
checkbox.subgroup = {
name: 'missingInformation',
type: 'input',
label: wgULS('缺少的内容(必填):', '缺少的內容(必填):'),
tooltip: wgULS('必填,显示为“缺少有关……的信息。”', '必填,顯示為「缺少有關……的資訊。」'),
};
break;
case 'Requested move':
checkbox.subgroup = [
{
name: 'moveTarget',
type: 'input',
label: wgULS('新名称:', '新名稱:'),
},
{
name: 'moveReason',
type: 'textarea',
label: wgULS('移动理由(会被粘贴该条目的讨论页):', '移動理由(會被貼上該條目的討論頁):'),
tooltip: wgULS('可选,但强烈推荐。如不需要请留空。', '可選,但強烈推薦。如不需要請留空。'),
},
];
break;
case 'Split':
checkbox.subgroup = [
{
name: 'target1',
type: 'input',
label: wgULS('页面名1:', '頁面名1:'),
tooltip: wgULS('可选。', '可選。'),
},
{
name: 'target2',
type: 'input',
label: wgULS('页面名2:', '頁面名2:'),
tooltip: wgULS('可选。', '可選。'),
},
{
name: 'target3',
type: 'input',
label: wgULS('页面名3:', '頁面名3:'),
tooltip: wgULS('可选。', '可選。'),
},
];
break;
case 'Cleanup':
checkbox.subgroup = [
{
name: 'cleanupReason',
type: 'input',
label: '需要清理的理由',
tooltip: wgULS('可选,但强烈推荐。如不需要请留空。', '可選,但強烈推薦。如不需要請留空。'),
},
];
break;
default:
break;
}
return checkbox;
};
var makeCheckboxesForAlreadyPresentTags = function () {
container.append({
type: 'header',
id: 'tagHeader0',
label: wgULS('已放置的维护标记', '已放置的維護標記'),
});
});
form.append({
var subdiv = container.append({
type: 'checkbox',
type: 'div',
name: 'tags',
id: 'tagSubdiv0',
list: group.value
});
});
});
var checkboxes = [];
var unCheckedTags = e.target.form.getUnchecked('existingTags');
if (Twinkle.getPref('customFileTagList').length) {
form.append({
Twinkle.tag.alreadyPresentTags.forEach(function (tag) {
type: 'header',
var checkbox = {
label: '自定义模板'
value: tag,
label: "{{".concat(tag, "}}").concat(Twinkle.tag.article.flatObject[tag]
? ": ".concat(Twinkle.tag.article.flatObject[tag].description)
: ''),
checked: !unCheckedTags.includes(tag),
};
checkboxes.push(checkbox);
});
});
form.append({
subdiv.append({
type: 'checkbox',
type: 'checkbox',
name: 'tags',
name: 'existingTags',
list: Twinkle.getPref('customFileTagList')
list: checkboxes,
});
};
if (sortorder === 'cat') {
// categorical sort order
// function to iterate through the tags and create a checkbox for each one
var doCategoryCheckboxes_1 = function (subdiv, subgroup) {
var checkboxes = [];
$.each(subgroup, function (k, item) {
if (!Twinkle.tag.alreadyPresentTags.includes(item.tag)) {
checkboxes.push(makeCheckbox(item.tag, item.description));
}
});
subdiv.append({
type: 'checkbox',
name: 'tags',
list: checkboxes,
});
};
if (Twinkle.tag.alreadyPresentTags.length > 0) {
makeCheckboxesForAlreadyPresentTags();
}
var i_2 = 1;
// go through each category and sub-category and append lists of checkboxes
Twinkle.tag.article.tagList.forEach(function (group) {
container.append({
type: 'header',
id: "tagHeader".concat(i_2),
label: group.key,
});
var subdiv = container.append({
type: 'div',
id: "tagSubdiv".concat(i_2++),
});
if (group.value[0].tag) {
doCategoryCheckboxes_1(subdiv, group.value);
}
else {
group.value.forEach(function (subgroup) {
subdiv.append({
type: 'div',
label: [Morebits.htmlNode('b', subgroup.key)],
});
doCategoryCheckboxes_1(subdiv, subgroup.value);
});
}
});
});
}
break;
}
}
case '重定向':
else {
{
// alphabetical sort order
if (Twinkle.tag.alreadyPresentTags.length > 0) {
Window.setTitle('重定向标记');
var i = 1;
makeCheckboxesForAlreadyPresentTags();
container.append({
Twinkle.tag.redirectList.forEach(function (group) {
form.append({
type: 'header',
type: 'header',
id: 'tagHeader1',
label: wgULS('可用的维护标记', '可用的維護標記'),
id: "tagHeader".concat(i),
label: group.key
});
}
// Avoid repeatedly resorting
Twinkle.tag.article.alphabeticalList =
Twinkle.tag.article.alphabeticalList || Object.keys(Twinkle.tag.article.flatObject).sort();
var checkboxes_1 = [];
Twinkle.tag.article.alphabeticalList.forEach(function (tag) {
if (!Twinkle.tag.alreadyPresentTags.includes(tag)) {
checkboxes_1.push(makeCheckbox(tag, Twinkle.tag.article.flatObject[tag].description));
}
});
});
form.append({
container.append({
type: 'checkbox',
type: 'checkbox',
name: 'tags',
name: 'tags',
list: group.value.map(function (item) {
list: checkboxes_1,
return {
value: item.tag,
label: "{{".concat(item.tag, "}}\uFF1A").concat(item.description),
subgroup: item.subgroup
};
})
});
});
});
}
// append any custom tags
if (Twinkle.getPref('customRedirectTagList').length) {
form.append({
if (Twinkle.getPref('customTagList').length) {
type: 'header',
container.append({
label: '自定义模板'
type: 'header',
label: wgULS('自定义模板', '自訂模板'),
});
});
form.append({
container.append({
type: 'checkbox',
type: 'checkbox',
name: 'tags',
name: 'tags',
list: Twinkle.getPref('customRedirectTagList')
list: Twinkle.getPref('customTagList').map(function (el) {
el.checked = Twinkle.tag.checkedTags.includes(el.value);
return el;
}),
});
});
}
break;
}
}
var $workarea = $(form).find('#tagWorkArea');
default:
var rendered = container.render();
{
$workarea.empty().append(rendered);
alert("Twinkle.tag\uFF1A\u672A\u77E5\u6A21\u5F0F ".concat(Twinkle.tag.mode));
break;
// for quick filter:
$allCheckboxDivs = $workarea.find('[name=tags], [name=existingTags]').parent();
}
$allHeaders = $workarea.find('h5, .quickformDescription');
}
form.quickfilter.value = ''; // clear search, because the search results are not preserved over mode change
if (document.querySelectorAll('.patrollink').length) {
form.append({
form.quickfilter.focus();
type: 'checkbox',
// style adjustments
list: [{
$workarea.find('h5').css({
label: '标记页面为已巡查',
'font-size': '110%',
value: 'patrol',
});
$workarea.find('h5:not(:first-child)').css({
name: 'patrol',
'margin-top': '1em',
checked: Twinkle.getPref('markTaggedPagesAsPatrolled')
}]
});
$workarea.find('div').filter(':has(span.quickformDescription)').css({
});
'margin-top': '0.4em',
}
form.append({
});
Morebits.quickForm.getElements(form, 'existingTags').forEach(generateLinks);
type: 'submit',
Morebits.quickForm.getElements(form, 'tags').forEach(generateLinks);
className: 'tw-tag-submit'
// tally tags added/removed, update statusNode text
});
var result = form.render();
var statusNode = document.getElementById('tw-tag-status');
$('[name=tags], [name=existingTags]').on('click', function () {
Window.setContent(result);
if (this.name === 'tags') {
Window.display();
Twinkle.tag.status.numAdded += this.checked ? 1 : -1;

// for quick filter:
$allCheckboxDivs = $(result).find('[name$=tags]').parent();
$allHeaders = $(result).find('h5');
result.quickfilter.focus(); // place cursor in the quick filter field as soon as window is opened
result.quickfilter.autocomplete = 'off'; // disable browser suggestions
result.quickfilter.addEventListener('keypress', function (e) {
if (e.keyCode === 13) {
// prevent enter key from accidentally submitting the form
e.preventDefault();
return false;
}
});
if (Twinkle.tag.mode === '条目') {
Twinkle.tag.alreadyPresentTags = [];
if (Twinkle.tag.canRemove) {
// Look for existing maintenance tags in the lead section and put them in array
// All tags are HTML table elements that are direct children of .mw-parser-output,
// except when they are within {{multiple issues}}
$('.mw-parser-output').children().each(function (_i, e) {
// break out on encountering the first heading, which means we are no
// longer in the lead section
if (e.tagName === 'H2') {
return false;
}

// The ability to remove tags depends on the template's {{ambox}} |name=
// parameter bearing the template's correct name (preferably) or a name that at
// least redirects to the actual name
// All tags have their first class name as "box-" + template name
if (e.className.indexOf('box-') === 0) {
if (e.classList[0] === 'box-问题条目') {
$(e).find('.ambox').each(function (_idx, e) {
if (e.classList[0].indexOf('box-') === 0) {
var _tag = e.classList[0].slice('box-'.length).replace(/_/g, ' ');
Twinkle.tag.alreadyPresentTags.push(_tag);
}
});
return true; // continue
}
}
else if (this.name === 'existingTags') {

var tag = e.classList[0].slice('box-'.length).replace(/_/g, ' ');
Twinkle.tag.status.numRemoved += this.checked ? -1 : 1;
Twinkle.tag.alreadyPresentTags.push(tag);
}
var firstPart = "\u52A0\u5165".concat(Twinkle.tag.status.numAdded).concat(wgULS('个标记', '個標記'));
}
var secondPart = "\u79FB\u9664".concat(Twinkle.tag.status.numRemoved).concat(wgULS('个标记', '個標記'));
statusNode.textContent =
(Twinkle.tag.status.numAdded ? " ".concat(firstPart) : '') +
(Twinkle.tag.status.numRemoved ? (Twinkle.tag.status.numAdded ? ';' : ' ') + secondPart : '');
});
});
};

/**
// {{Uncategorized}} and {{Improve categories}} are usually placed at the end
* Adds a link to each template's description page
if ($('.box-Uncategorized').length) {
*
Twinkle.tag.alreadyPresentTags.push('Uncategorized');
* @param {Morebits.quickForm.element} checkbox associated with the template
}
*/
if ($('.box-Improve_categories').length) {
var generateLinks = function (checkbox) {
Twinkle.tag.alreadyPresentTags.push('Improve categories');
var link = Morebits.htmlNode('a', '>');
}
link.setAttribute('class', 'tag-template-link');
}
var tagname = checkbox.values;

link.setAttribute('href', mw.util.getUrl((!tagname.includes(':') ? 'Template:' : '') +
// Add status text node after Submit button
(!tagname.includes('|') ? tagname : tagname.slice(0, tagname.indexOf('|')))));
var statusNode = document.createElement('small');
link.setAttribute('target', '_blank');
statusNode.id = 'tw-tag-status';
$(checkbox).parent().append(['\u00A0', link]);
Twinkle.tag.status = {
};
// initial state; defined like this because these need to be available for reference
// in the click event handler
// Tags for ARTICLES start here
Twinkle.tag.article = {};
numAdded: 0,
// Tags arranged by category; will be used to generate the alphabetical list,
numRemoved: 0
// but tags should be in alphabetical order within the categories
};
// excludeMI: true indicate a tag that *does not* work inside {{multiple issues}}
$('button.tw-tag-submit').after(statusNode);
// Add new categories with discretion - the list is long enough as is!

Twinkle.tag.article.tagList = [
// fake a change event on the sort dropdown, to initialize the tag list
{
var evt = document.createEvent('Event');
key: wgULS('清理和维护模板', '清理和維護模板'),
evt.initEvent('change', true, true);
value: [
result.sortorder.dispatchEvent(evt);
} else {
// Redirects and files: Add a link to each template's description page
Morebits.quickForm.getElements(result, 'tags').forEach(generateLinks);
}
};

// $allCheckboxDivs and $allHeaders are defined globally, rather than in the
// quickfilter event function, to avoid having to recompute them on every keydown
var $allCheckboxDivs, $allHeaders;
Twinkle.tag.updateSortOrder = function (e) {
var form = e.target.form;
var sortorder = e.target.value;
Twinkle.tag.checkedTags = form.getChecked('tags');
var container = new Morebits.quickForm.element({
type: 'fragment'
});

// function to generate a checkbox, with appropriate subgroup if needed
var makeCheckbox = function makeCheckbox(tag, description) {
var checkbox = {
value: tag,
label: "{{".concat(tag, "}}: ").concat(description)
};
if (Twinkle.tag.checkedTags.includes(tag)) {
checkbox.checked = true;
}
switch (tag) {
/* case 'Expand language': {
checkbox.subgroup = [
{
name: 'expandLanguage',
type: 'input',
label: '外语版本语言代码(必填):'
},
{
type: 'checkbox',
list: [
{
name: 'highQualityArticle',
label: '高品质条目'
}
]
},
{
name: 'expandLanguage2',
type: 'input',
label: '外语版本语言代码:'
},
{
type: 'checkbox',
list: [
{
name: 'highQualityArticle2',
label: '高品质条目'
}
]
},
{
name: 'expandLanguage3',
type: 'input',
label: '外语版本语言代码:'
},
{
type: 'checkbox',
list: [
{
name: 'highQualityArticle3',
label: '高品质条目'
}
]
}
];
break;
} */
case 'Expert needed':
{
checkbox.subgroup = [{
name: 'expert',
type: 'input',
label: '哪个领域的专家(必填):',
tooltip: '必填,可参考 Category:需要专业人士关注的页面 使用现存的分类。'
}, {
name: 'expert2',
type: 'input',
label: '哪个领域的专家:',
tooltip: '可选,可参考 Category:需要专业人士关注的页面 使用现存的分类。'
}, {
name: 'expert3',
type: 'input',
label: '哪个领域的专家:',
tooltip: '可选,可参考 Category:需要专业人士关注的页面 使用现存的分类。'
}];
break;
}
case 'Merge':
case 'Merge from':
case 'Merge to':
{
var otherTagName = 'Merge';
switch (tag) {
case 'Merge from':
{
{
otherTagName = 'Merge to';
key: wgULS('常规清理', '常規清理'),
break;
value: [
}
{
case 'Merge to':
tag: 'Cleanup',
description: wgULS('可能需要进行清理,以符合有兽档案馆的质量标准', '可能需要進行清理,以符合有獸檔案館的質量標準'),
},
{
tag: '需要整改',
description: wgULS('此条目不符合一般的格式要求,需要大规模整改', '此條目不符合一般的格式要求,需要大規模整改'),
},
],
},
{
key: wgULS('可能多余的内容', '可能多餘的內容'),
value: [
{
tag: 'Copypaste',
description: wgULS('内容可能是从某个来源处拷贝后粘贴', '內容可能是從某個來源處拷貝後貼上'),
},
{
tag: 'External links',
description: wgULS('使用外部链接的方式可能不符合有兽档案馆的条例', '使用外部連結的方式可能不符合有獸檔案館的條例'),
},
{
tag: 'Non-free',
description: wgULS('可能过多或不当地使用了受著作权保护的文字、图像或多媒体文件', '可能過多或不當地使用了受版權保護的文字、圖像或多媒體檔案'),
},
],
},
{
key: wgULS('结构和导言', '結構和導言'),
value: [
{
tag: 'Lead too long',
description: wgULS('导言部分也许过于冗长', '導言部分也許過於冗長'),
},
{
tag: '序言太短',
description: wgULS('此条目序言太短', '此條目序言太短'),
},
{
tag: '没有序言',
description: wgULS('此条目没有序言', '此條目沒有序言'),
},
],
},
],
},
{
key: wgULS('常规条目问题', '常規條目問題'),
value: [
{
key: wgULS('写作风格', '寫作風格'),
value: [
{
tag: 'Advert',
description: wgULS('类似广告或宣传性内容', '類似廣告或宣傳性內容'),
},
{
tag: 'Inappropriate person',
description: wgULS('使用不适当的第一人称和第二人称', '使用不適當的第一人稱和第二人稱'),
},
{
tag: 'Tone',
description: wgULS('语调或风格可能不适合百科全书的写作方式', '語調或風格可能不適合百科全書的寫作方式'),
},
{
tag: 'Tone',
description: wgULS('语调或风格可能不适合百科全书的写作方式', '語調或風格可能不適合百科全書的寫作方式'),
},
],
},
{
key: wgULS('信息和细节', '資訊和細節'),
value: [
{
tag: 'Expert needed',
description: wgULS('需要更了解本部分内容的编者参与及协助编辑', '需要更了解本部分內容的編者參與及協助編輯'),
},
{
tag: 'Trivia',
description: wgULS('应避免有陈列杂项、琐碎资料的部分', '應避免有陳列雜項、瑣碎資料的部分'),
},
],
},
{
key: wgULS('时间性', '時間性'),
value: [
{
tag: 'Current',
description: wgULS('记述新闻动态', '記述新聞動態'),
excludeMI: true,
},
{
tag: 'Update',
description: wgULS('当前条目或章节需要更新', '當前條目或章節需要更新'),
},
],
},
{
key: wgULS('中立、偏见和事实准确性', '中立、偏見和事實準確性'),
value: [
{
tag: 'Disputed',
description: wgULS('内容疑欠准确,有待查证', '內容疑欠準確,有待查證'),
},
{
tag: 'Hoax',
description: wgULS('真实性被质疑', '真實性被質疑'),
},
{
tag: 'POV',
description: wgULS('中立性有争议。内容、语调可能带有过度的个人观点', '中立性有爭議。內容、語調可能帶有過度的個人觀點'),
},
{
tag: 'Self-contradictory',
description: wgULS('内容自相矛盾', '內容自相矛盾'),
},
{
tag: 'Weasel',
description: wgULS('语义模棱两可而损及其中立性或准确性', '語意模棱兩可而損及其中立性或準確性'),
},
],
},
{
key: wgULS('可供查证和来源', '可供查證和來源'),
value: [
{
tag: 'BLPdispute',
description: wgULS('可能违反了有兽档案馆关于生者传记的条例', '可能違反了有獸檔案館關於生者傳記的條例'),
},
{
tag: 'BLPsources',
description: wgULS('生者传记需要补充更多可供查证的来源', '生者傳記需要補充更多可供查證的來源'),
},
{
tag: 'BLP unsourced',
description: wgULS('生者传记没有列出任何参考或来源', '生者傳記沒有列出任何參考或來源'),
},
{
tag: 'Citecheck',
description: wgULS('可能包含不适用或被曲解的引用资料,部分内容的准确性无法被证实', '可能包含不適用或被曲解的引用資料,部分內容的準確性無法被證實'),
},
{
tag: 'More footnotes needed',
description: wgULS('因为文内引用不足,部分字句的来源仍然不明', '因為文內引用不足,部分字句的來源仍然不明'),
},
{
tag: 'No footnotes',
description: wgULS('因为没有内文引用而来源仍然不明', '因為沒有內文引用而來源仍然不明'),
},
{
tag: 'Original research',
description: wgULS('可能包含未查证内容', '可能包含未查證內容'),
},
{
tag: 'Refimprove',
description: wgULS('需要补充更多来源', '需要補充更多來源'),
},
{
tag: 'Unreferenced',
description: wgULS('没有列出任何参考或来源', '沒有列出任何參考或來源'),
},
],
},
],
},
{
key: wgULS('具体内容问题', '具體內容問題'),
value: [
{
key: wgULS('语言', '語言'),
value: [
{
tag: 'NotMandarin',
description: wgULS('包含过多不是现代标准汉语的内容', '包含過多不是現代標準漢語的內容'),
excludeMI: true,
},
],
},
{
key: wgULS('链接', '連結'),
value: [
{
tag: 'Dead end',
description: wgULS('需要加上内部链接以构筑百科全书的链接网络', '需要加上內部連結以構築百科全書的連結網絡'),
},
{
tag: '孤立页面',
description: wgULS('没有或只有很少链入页面', '沒有或只有很少連入頁面'),
},
{
tag: 'Overlinked',
description: wgULS('含有过多、重复、或不必要的内部链接', '含有過多、重複、或不必要的內部連結'),
},
{
tag: 'Underlinked',
description: wgULS('需要更多内部链接以构筑百科全书的链接网络', '需要更多內部連結以構築百科全書的連結網絡'),
},
],
},
{
key: wgULS('参考技术', '參考技術'),
value: [
{
tag: 'Citation style',
description: wgULS('引用需要进行清理', '引用需要進行清理'),
},
],
},
{
key: wgULS('分类', '分類'),
value: [
{
tag: 'Improve categories',
description: wgULS('需要更多页面分类', '需要更多頁面分類'),
excludeMI: true,
},
{
tag: 'Uncategorized',
description: wgULS('缺少页面分类', '缺少頁面分類'),
excludeMI: true,
},
],
},
],
},
{
key: wgULS('合并、拆分、移动', '合併、拆分、移動'),
value: [
{
tag: 'Merge from',
description: wgULS('建议将页面并入此页面', '建議將頁面併入此頁面'),
excludeMI: true,
},
{
tag: 'Merge to',
description: wgULS('建议将此页面并入页面', '建議將此頁面併入頁面'),
excludeMI: true,
},
{
tag: 'Merge',
description: wgULS('建议此页面与页面合并', '建議此頁面與頁面合併'),
excludeMI: true,
},
{
tag: 'Requested move',
description: wgULS('建议将此页面移动到新名称', '建議將此頁面移動到新名稱'),
excludeMI: true,
},
{
tag: 'Split',
description: wgULS('建议将此页面分割为多个页面', '建議將此頁面分割為多個頁面'),
excludeMI: true,
},
],
},
];
// Tags for REDIRECTS start here
// Not by policy, but the list roughly approximates items with >500
// transclusions from Template:R template index
Twinkle.tag.redirectList = [
{
key: '常用模板',
value: [
{
tag: wgULS('合并重定向', '合併重定向'),
description: wgULS('保持页面题名至相应主条目,令页面内容在合并后仍能保存其编辑历史', '保持頁面題名至相應主條目,令頁面內容在合併後仍能儲存其編輯歷史'),
},
{
tag: wgULS('简繁重定向', '簡繁重定向'),
description: wgULS('引导简体至繁体,或繁体至简体', '引導簡體至繁體,或繁體至簡體'),
},
{
tag: '模板重定向',
description: wgULS('指向模板的重定向页面', '指向模板的重定向頁面'),
},
{
tag: wgULS('别名重定向', '別名重定向'),
description: wgULS('标题的其他名称、笔名、绰号、同义字等', '標題的其他名稱、筆名、綽號、同義字等'),
},
{
tag: wgULS('译名重定向', '譯名重定向'),
description: wgULS('人物、作品等各项事物的其他翻译名称', '人物、作品等各項事物的其他翻譯名稱'),
},
{
tag: wgULS('缩写重定向', '縮寫重定向'),
description: wgULS('标题缩写', '標題縮寫'),
},
{
tag: wgULS('拼写重定向', '拼寫重定向'),
description: wgULS('标题的其他不同拼写', '標題的其他不同拼寫'),
},
{
tag: wgULS('错字重定向', '錯字重定向'),
description: wgULS('纠正标题的常见错误拼写或误植', '糾正標題的常見錯誤拼寫或誤植'),
},
{
tag: wgULS('旧名重定向', '舊名重定向'),
description: wgULS('将事物早前的名称引导至更改后的主题', '將事物早前的名稱引導至更改後的主題'),
},
{
tag: '全名重定向',
description: wgULS('标题的完整或更完整名称', '標題的完整或更完整名稱'),
},
{
tag: '短名重定向',
description: wgULS('完整标题名称或人物全名的部分、不完整的名称或简称', '完整標題名稱或人物全名的部分、不完整的名稱或簡稱'),
},
{
tag: '姓氏重定向',
description: '人物姓氏',
},
{
tag: '名字重定向',
description: '人物人名',
},
{
tag: '本名重定向',
description: '人物本名',
},
{
tag: '非中文重定向',
description: wgULS('非中文标题', '非中文標題'),
subgroup: [
{
name: 'altLangFrom',
type: 'input',
label: '本重新導向的語言(可選)',
tooltip: '輸入重新導向名稱所使用語言的ISO 639代碼,例如en代表英語,代碼可參見 Template:ISO_639_name',
},
],
},
{
tag: '日文重定向',
description: wgULS('日语名称', '日語名稱'),
},
],
},
{
key: '偶用模板',
value: [
{
tag: wgULS('章节重定向', '章節重定向'),
description: wgULS('导向至较高密度组织的页面', '導向至較高密度組織的頁面'),
},
{
tag: '列表重定向',
description: wgULS('导向至低密度的列表', '導向至低密度的列表'),
},
{
tag: '可能性重定向',
description: wgULS('导向至当前提供内容更为详尽的目标页面', '導向至當前提供內容更為詳盡的目標頁面'),
},
{
tag: wgULS('关联字重定向', '關聯字重定向'),
description: wgULS('标题名称关联字', '標題名稱關聯字'),
},
{
tag: wgULS('条目请求重定向', '條目請求重定向'),
description: wgULS('需要独立条目的页面', '需要獨立條目的頁面'),
subgroup: [
{
name: 'reqArticleLang',
type: 'input',
label: '外語語言代碼:',
tooltip: '使用ISO 639代碼,可參見 Template:ISO_639_name',
},
{
name: 'reqArticleTitle',
type: 'input',
label: '外語頁面名稱:',
size: 60,
},
],
},
{
tag: wgULS('快捷方式重定向', '捷徑重定向'),
description: wgULS('有兽档案馆快捷方式', '有獸檔案館快捷方式'),
},
],
},
{
key: wgULS('鲜用模板', '鮮用模板'),
value: [
{
tag: wgULS('词组重定向', '詞組重定向'),
description: wgULS('将词组/词组/成语指向切题的条目及恰当章节', '將詞組/詞組/成語指向切題的條目及恰當章節'),
},
{
tag: wgULS('消歧义页重定向', '消歧義頁重定向'),
description: wgULS('指向消歧义页', '指向消歧義頁'),
},
{
tag: '域名重定向',
description: wgULS('域名', '網域名稱'),
},
{
tag: '年代重定向',
description: wgULS('于年份条目导向至年代条目', '於年份條目導向至年代條目'),
},
{
tag: wgULS('用户框模板重定向', '用戶框模板重定向'),
description: wgULS('用户框模板', '用戶框模板'),
},
{
tag: '重定向模板用重定向',
description: wgULS('导向至重定向模板', '導向至重定向模板'),
},
{
tag: 'EXIF重定向',
description: wgULS('JPEG图像文件包含EXIF信息', 'JPEG圖檔包含EXIF資訊'),
},
],
},
];
// maintenance tags for FILES start here
Twinkle.tag.fileList = [
{
key: wgULS('著作权和来源问题标签', '著作權和來源問題標籤'),
value: [
{
label: "{{Non-free reduce}}\uFF1A".concat(wgULS('非低分辨率的合理使用图像(或过长的音频剪辑等)', '非低解析度的合理使用圖像(或過長的音頻剪輯等)')),
value: 'Non-free reduce',
},
],
},
{
key: wgULS('清理标签', '清理標籤'),
value: [
{
label: "{{Watermark}}\uFF1A".concat(wgULS('图像包含了水印', '圖像包含了浮水印')),
value: 'Watermark',
},
{
label: "{{Rename media}}\uFF1A".concat(wgULS('文件应该根据文件名称指引被重命名', '檔案應該根據檔案名稱指引被重新命名')),
value: 'Rename media',
subgroup: [
{
type: 'input',
name: 'renamemediaNewname',
label: wgULS('新名称:', '新名稱:'),
tooltip: wgULS('输入图像的新名称(可选)', '輸入圖像的新名稱(可選)'),
},
{
type: 'input',
name: 'renamemediaReason',
label: '原因:',
tooltip: wgULS('输入重命名的原因(可选)', '輸入重新命名的原因(可選)'),
},
],
},
{
label: "{{Should be SVG}}\uFF1A".concat(wgULS('PNG、GIF、JPEG文件应该重制成矢量图形', 'PNG、GIF、JPEG檔案應該重製成向量圖形')),
value: 'Should be SVG',
},
],
},
{
key: wgULS('文件取代标签', '檔案取代標籤'),
value: [
{
label: "{{Obsolete}}\uFF1A".concat(wgULS('有新版本可用的过时文件', '有新版本可用的過時檔案')),
value: 'Obsolete',
},
{
{
label: "{{Vector version available}}\uFF1A".concat(wgULS('有矢量图形可用的非矢量图形文件', '有向量圖形可用的非向量圖形檔案')),
otherTagName = 'Merge from';
break;
value: 'Vector version available',
},
],
buildFilename: true,
},
];
Twinkle.tag.callbacks = {
article: function (pageobj) {
// Remove tags that become superfluous with this action
var pageText = pageobj
.getPageText()
.replace(/\{\{\s*([Nn]ew unreviewed article|[Uu]nreviewed|[Uu]serspace draft)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/g, '');
var params = pageobj.getCallbackParameters();
/**
* Saves the page following the removal of tags if any. The last step.
* Called from removeTags()
*/
var postRemoval = function () {
if (params.tagsToRemove.length) {
// Remove empty {{multiple issues}} if found
pageText = pageText.replace(/\{\{(multiple ?issues|article ?issues|mi|ai|issues|多個問題|多个问题|問題條目|问题条目|數個問題|数个问题)\s*\|\s*\}\}\n?/im, '');
// Remove single-element {{multiple issues}} if found
pageText = pageText.replace(/\{\{(?:multiple ?issues|article ?issues|mi|ai|issues|多個問題|多个问题|問題條目|问题条目|數個問題|数个问题)\s*\|\s*(\{\{(?:\{\{[^{}]*\}\}|[^{}])+\}\})\s*\}\}/im, '$1');
}
}
// no default
// Build edit summary
}
var makeSentence = function (array) {
if (array.length < 3) {

checkbox.subgroup = [{
return array.join('和');
name: 'mergeTarget',
}
type: 'input',
var last = array.pop();
return "".concat(array.join('、'), "\u548C").concat(last);
label: '其他条目:',
};
tooltip: '如指定多个条目,请用管道符分隔:条目甲|条目乙'
}, {
var makeTemplateLink = function (tag) {
type: 'checkbox',
var text = '{{[[';
list: [{
// if it is a custom tag with a parameter
name: 'mergeTagOther',
if (tag.includes('|')) {
label: "\u7528{{".concat(otherTagName, "}}\u6807\u8BB0\u5176\u4ED6\u6761\u76EE"),
tag = tag.slice(0, tag.indexOf('|'));
checked: true,
}
text += tag.includes(':') ? tag : "Template:".concat(tag, "|").concat(tag);
tooltip: '仅在只输入了一个条目名时可用'
}]
return "".concat(text, "]]}}");
}];
};
if (mw.config.get('wgNamespaceNumber') === 0) {
var summaryText;
checkbox.subgroup.push({
var addedTags = params.tags.map(makeTemplateLink);
name: 'mergeReason',
var removedTags = params.tagsToRemove.map(makeTemplateLink);
type: 'textarea',
if (addedTags.length) {
summaryText = "\u52A0\u5165".concat(makeSentence(addedTags));
label: "\u5408\u5E76\u7406\u7531\uFF08\u4F1A\u88AB\u8D34\u4E0A".concat(tag === 'Merge to' ? '其他' : '这', "\u6761\u76EE\u7684\u8BA8\u8BBA\u9875\uFF09\uFF1A"),
summaryText += removedTags.length ? "\u4E26\u79FB\u9664".concat(makeSentence(removedTags)) : '';
tooltip: '可选,但强烈推荐。如不需要请留空。仅在只输入了一个条目名时可用。'
});
}
else {
summaryText = "\u79FB\u9664".concat(makeSentence(removedTags));
}
summaryText += wgULS('标记', '標記');
if (params.reason) {
summaryText += "\uFF1A".concat(params.reason);
}
// avoid truncated summaries
if (summaryText.length > 499) {
summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)\]\]/g, '$1');
}
pageobj.setPageText(pageText);
pageobj.setEditSummary(summaryText);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
pageobj.setCreateOption('nocreate');
pageobj.save(function () {
// special functions for merge tags
if (params.mergeReason) {
// post the rationale on the talk page (only operates in main namespace)
var talkpage = new Morebits.wiki.page("Talk:".concat(params.discussArticle), wgULS('将理由贴进讨论页', '將理由貼進討論頁'));
talkpage.setNewSectionText("".concat(params.mergeReason.trim(), " ~~~~"));
talkpage.setNewSectionTitle("\u8BF7\u6C42\u4E0E[[".concat(params.nonDiscussArticle, "]]\u5408\u5E76"));
talkpage.setChangeTags(Twinkle.changeTags);
talkpage.setWatchlist(Twinkle.getPref('watchMergeDiscussions'));
talkpage.setCreateOption('recreate');
talkpage.newSection();
}
if (params.mergeTagOther) {
// tag the target page if requested
var otherTagName = 'Merge';
if (params.mergeTag === 'Merge from') {
otherTagName = 'Merge to';
}
else if (params.mergeTag === 'Merge to') {
otherTagName = 'Merge from';
}
var newParams = {
tags: [otherTagName],
tagsToRemove: [],
tagsToRemain: [],
mergeTarget: Morebits.pageNameNorm,
discussArticle: params.discussArticle,
talkDiscussionTitle: params.talkDiscussionTitle,
talkDiscussionTitleLinked: params.talkDiscussionTitleLinked,
};
var otherpage = new Morebits.wiki.page(params.mergeTarget, "".concat(wgULS('标记其他页面(', '標記其他頁面(') + params.mergeTarget, "\uFF09"));
otherpage.setCallbackParameters(newParams);
otherpage.load(Twinkle.tag.callbacks.article);
}
// special functions for requested move tags
if (params.moveReason) {
// post the rationale on the talk page (only operates in main namespace)
var moveTalkpageText = "\n\n{{subst:RM|1=".concat(params.moveReason.trim());
if (params.moveTarget) {
moveTalkpageText += "|2=".concat(params.moveTarget);
}
moveTalkpageText += '}}';
var moveTalkpage = new Morebits.wiki.page("Talk:".concat(params.discussArticle), wgULS('将理由贴进讨论页', '將理由貼進討論頁'));
moveTalkpage.setAppendText(moveTalkpageText);
moveTalkpage.setEditSummary(wgULS('请求移动', '請求移動') + (params.moveTarget ? "\u81F3[[".concat(params.moveTarget, "]]") : ''));
moveTalkpage.setChangeTags(Twinkle.changeTags);
moveTalkpage.setCreateOption('recreate');
moveTalkpage.append();
}
});
if (params.patrol) {
pageobj.patrol();
}
};
/**
* Removes the existing tags that were deselected (if any)
* Calls postRemoval() when done
*/
var removeTags = function () {
if (params.tagsToRemove.length === 0) {
postRemoval();
return;
}
Morebits.status.info(wgULS('信息', '資訊'), wgULS('移除取消选择的已存在标记', '移除取消選擇的已存在標記'));
var getRedirectsFor = [];
// Remove the tags from the page text, if found in its proper name,
// otherwise moves it to `getRedirectsFor` array earmarking it for
// later removal
params.tagsToRemove.forEach(function (tag) {
var tag_re = new RegExp("\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|[^}]+)?\\}\\}\\n?"));
if (tag_re.test(pageText)) {
pageText = pageText.replace(tag_re, '');
}
else {
getRedirectsFor.push("Template:".concat(tag));
}
});
if (!getRedirectsFor.length) {
postRemoval();
return;
}
// Remove tags which appear in page text as redirects
var api = new Morebits.wiki.api(wgULS('获取模板重定向', '取得模板重新導向'), {
action: 'query',
prop: 'linkshere',
titles: getRedirectsFor.join('|'),
redirects: 1,
lhnamespace: '10',
lhshow: 'redirect',
lhlimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
}, function (apiobj) {
$(apiobj.responseXML)
.find('page')
.each(function (idx, page) {
var removed = false;
$(page)
.find('lh')
.each(function (idx, el) {
var tag = $(el).attr('title').slice(9);
var tag_re = new RegExp("\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?\\}\\}\\n?"));
if (tag_re.test(pageText)) {
pageText = pageText.replace(tag_re, '');
removed = true;
return false; // break out of $.each
}
});
if (!removed) {
Morebits.status.warn(wgULS('信息', '資訊'), wgULS('无法在页面上找到{{', '無法在頁面上找到{{') +
$(page).attr('title').slice(9) +
wgULS('}}……跳过', '}}……跳過'));
}
});
postRemoval();
});
api.post();
};
if (!params.tags.length) {
removeTags();
return;
}
}
break;
var tagRe;
}
var tagText = '';
case 'Missing information':
var tags = [];
{
var groupableTags = [];
checkbox.subgroup = {
var groupableExistingTags = [];
name: 'missingInformation',
// Executes first: addition of selected tags
type: 'input',
/**
* Updates `tagText` with the syntax of `tagName` template with its parameters
label: '缺少的内容(必填):',
*
tooltip: '必填,显示为“缺少有关……的信息。”'
* @param {number} tagIndex
* @param {string} tagName
*/
var addTag = function (tagIndex, tagName) {
var currentTag = '';
if (tagName === 'Uncategorized' || tagName === 'Improve categories') {
pageText += "\n\n{{".concat(tagName, "|time={{subst:#time:c}}}}");
}
else {
currentTag += "{{".concat(tagName);
// fill in other parameters, based on the tag
switch (tagName) {
case 'Expert needed':
currentTag += "|subject=".concat(params.expert);
if (params.expert2) {
currentTag += "|subject2=".concat(params.expert2);
}
if (params.expert3) {
currentTag += "|subject3=".concat(params.expert3);
}
break;
case 'Merge':
case 'Merge to':
case 'Merge from':
if (params.mergeTarget) {
// normalize the merge target for now and later
params.mergeTarget = Morebits.string.toUpperCaseFirstChar(params.mergeTarget.replace(/_/g, ' '));
currentTag += "|".concat(params.mergeTarget);
// link to the correct section on the talk page, for article space only
if (mw.config.get('wgNamespaceNumber') === 0 &&
(params.mergeReason || params.discussArticle)) {
if (!params.discussArticle) {
// discussArticle is the article whose talk page will contain the discussion
params.discussArticle =
tagName === 'Merge to' ? params.mergeTarget : mw.config.get('wgTitle');
// nonDiscussArticle is the article which won't have the discussion
params.nonDiscussArticle =
tagName === 'Merge to' ? mw.config.get('wgTitle') : params.mergeTarget;
params.talkDiscussionTitle =
wgULS('请求与', '請求與') +
params.nonDiscussArticle +
wgULS('合并', '合併');
}
currentTag += "|discuss=Talk:".concat(params.discussArticle, "#").concat(params.talkDiscussionTitle);
}
}
break;
case 'Missing information':
currentTag += "|1=".concat(params.missingInformation);
break;
case 'Requested move':
if (params.moveTarget) {
// normalize the move target for now and later
params.moveTarget = Morebits.string.toUpperCaseFirstChar(params.moveTarget.replace(/_/g, ' '));
params.discussArticle = mw.config.get('wgTitle');
currentTag += "|".concat(params.moveTarget);
}
break;
case 'Split':
if (params.target1) {
currentTag += "|1=".concat(params.target1);
}
if (params.target2) {
currentTag += "|2=".concat(params.target2);
}
if (params.target3) {
currentTag += "|3=".concat(params.target3);
}
break;
case 'Cleanup':
if (params.cleanupReason) {
currentTag += "|reason=".concat(params.cleanupReason);
}
break;
default:
break;
}
currentTag += '|time={{subst:#time:c}}}}\n';
tagText += currentTag;
}
};
};
break;
/**
* Adds the tags which go outside {{multiple issues}}, either because
}
* these tags aren't supported in {{multiple issues}} or because
case 'Notability':
* {{multiple issues}} is not being added to the page at all
{
checkbox.subgroup = {
*/
name: 'notability',
var addUngroupedTags = function () {
type: 'select',
$.each(tags, addTag);
// Insert tag after short description or any hatnotes,
list: [{
label: '{{Notability}}:' + '通用的关注度指引',
// as well as deletion/protection-related templates
value: 'none'
var ysarxiv_page = new Morebits.wikitext.page(pageText);
}, {
var templatesAfter =
label: '{{Notability|Astro}}:' + '天体',
// Protection templates
value: 'Astro'
// CSD
}, {
// AfD
"".concat(Twinkle.hatnoteRegex, "pp|pp-.*?|(?:Delete|Db-reason|D|Deletebecause|Db|\u901F\u5220|\u901F\u522A|Speedy|SD|\u5FEB\u5220|\u5FEB\u522A|CSD)|[rsaiftcmv]fd|vfd-(?:b|q|s|source|v|wikt)|(?:\u79FB\u52A8\u5230\u7EF4\u57FA|\u79FB\u52D5\u5230\u7DAD\u57FA)(?:\u6559\u79D1\u4E66|\u6559\u79D1\u66F8|\u8BED\u5F55|\u8A9E\u9304|\u6587\u5E93|\u6587\u5EAB|\u5BFC\u6E38|\u5C0E\u904A|\u8BCD\u5178|\u8A5E\u5178)");
label: '{{Notability|Biographies}}:' + '人物传记',
pageText = ysarxiv_page.insertAfterTemplates(tagText, templatesAfter).getText();
value: 'Biographies'
}, {
removeTags();
label: '{{Notability|Book}}:' + '书籍',
value: 'Book'
}, {
label: '{{Notability|Companies}}:' + '组织与公司',
value: 'Companies'
}, {
label: '{{Notability|Cyclone}}:' + '气旋',
value: 'Cyclone'
}, {
label: '{{Notability|Fiction}}:' + '虚构事物',
value: 'Fiction'
}, {
label: '{{Notability|Geographic}}:' + '地理特征',
value: 'Geographic'
}, {
label: '{{Notability|Geometry}}:' + '几何图形',
value: 'Geometry'
}, {
label: '{{Notability|Invention}}:' + '发明、研究',
value: 'Invention'
}, {
label: '{{Notability|Music}}:' + '音乐',
value: 'Music'
}, {
label: '{{Notability|Numbers}}:' + '数字',
value: 'Numbers'
}, {
label: '{{Notability|Property}}:' + '性质表',
value: 'Property'
}, {
label: '{{Notability|Traffic}}:' + '交通',
value: 'Traffic'
}, {
label: '{{Notability|Web}}:' + '网站、网络内容' + '(非正式指引)',
value: 'Web'
}]
};
};
// Separate tags into groupable ones (`groupableTags`) and non-groupable ones (`tags`)
break;
}
params.tags.forEach(function (tag) {
tagRe = new RegExp("\\{\\{".concat(tag, "(\\||\\}\\})"), 'im');
case 'Requested move':
// regex check for preexistence of tag can be skipped if in canRemove mode
{
checkbox.subgroup = [{
if (Twinkle.tag.canRemove || !tagRe.exec(pageText)) {
// condition Twinkle.tag.article.tags[tag] to ensure that its not a custom tag
name: 'moveTarget',
// Custom tags are assumed non-groupable, since we don't know whether MI template supports them
type: 'input',
if (Twinkle.tag.article.flatObject[tag] && !Twinkle.tag.article.flatObject[tag].excludeMI) {
label: '新名称:'
}, {
groupableTags.push(tag);
name: 'moveReason',
}
type: 'textarea',
else {
tags.push(tag);
label: '移动理由(会被粘贴该条目的讨论页):',
}
tooltip: '可选,但强烈推荐。如不需要请留空。'
}];
}
break;
else {
}
if (tag === 'Merge from') {
case 'Split':
tags.push(tag);
{
}
checkbox.subgroup = [{
else {
Morebits.status.warn(wgULS('信息', '資訊'), wgULS('在页面上找到{{', '在頁面上找到{{') + tag + wgULS('}}……跳过', '}}……跳過'));
name: 'target1',
type: 'input',
// don't do anything else with merge tags
label: '页面名1:',
if (['Merge', 'Merge to'].includes(tag)) {
params.mergeTarget = params.mergeReason = params.mergeTagOther = null;
tooltip: '可选。'
}, {
}
name: 'target2',
}
type: 'input',
}
label: '页面名2:',
tooltip: '可选。'
}, {
name: 'target3',
type: 'input',
label: '页面名3:',
tooltip: '可选。'
}];
break;
}
case 'Cleanup':
{
checkbox.subgroup = [{
name: 'cleanupReason',
type: 'input',
label: '需要清理的理由',
tooltip: '可选,但强烈推荐。如不需要请留空。'
}];
break;
}
default:
{
break;
}
}
return checkbox;
};
var makeCheckboxesForAlreadyPresentTags = function makeCheckboxesForAlreadyPresentTags() {
container.append({
type: 'header',
id: 'tagHeader0',
label: '已放置的维护标记'
});
var subdiv = container.append({
type: 'div',
id: 'tagSubdiv0'
});
var checkboxes = [];
var unCheckedTags = e.target.form.getUnchecked('existingTags');
Twinkle.tag.alreadyPresentTags.forEach(function (tag) {
var checkbox = {
value: tag,
label: "{{".concat(tag, "}}").concat(Twinkle.tag.article.flatObject[tag] ? ": ".concat(Twinkle.tag.article.flatObject[tag].description) : ''),
checked: !unCheckedTags.includes(tag)
};
checkboxes.push(checkbox);
});
subdiv.append({
type: 'checkbox',
name: 'existingTags',
list: checkboxes
});
};
if (sortorder === 'cat') {
// categorical sort order
// function to iterate through the tags and create a checkbox for each one
var doCategoryCheckboxes = function doCategoryCheckboxes(subdiv, subgroup) {
var checkboxes = [];
$.each(subgroup, function (_k, item) {
if (!Twinkle.tag.alreadyPresentTags.includes(item.tag)) {
checkboxes.push(makeCheckbox(item.tag, item.description));
}
});
subdiv.append({
type: 'checkbox',
name: 'tags',
list: checkboxes
});
};
if (Twinkle.tag.alreadyPresentTags.length > 0) {
makeCheckboxesForAlreadyPresentTags();
}
var i = 1;
// go through each category and sub-category and append lists of checkboxes
Twinkle.tag.article.tagList.forEach(function (group) {
container.append({
type: 'header',
id: "tagHeader".concat(i),
label: group.key
});
var subdiv = container.append({
type: 'div',
id: "tagSubdiv".concat(i++)
});
if (group.value[0].tag) {
doCategoryCheckboxes(subdiv, group.value);
} else {
group.value.forEach(function (subgroup) {
subdiv.append({
type: 'div',
label: [Morebits.htmlNode('b', subgroup.key)]
});
});
// To-be-retained existing tags that are groupable
doCategoryCheckboxes(subdiv, subgroup.value);
params.tagsToRemain.forEach(function (tag) {
});
// If the tag is unknown to us, we consider it non-groupable
}
if (Twinkle.tag.article.flatObject[tag] && !Twinkle.tag.article.flatObject[tag].excludeMI) {
});
groupableExistingTags.push(tag);
} else {
var _Twinkle$tag$article;
}
// alphabetical sort order
});
var miTest = /\{\{(multiple ?issues|article ?issues|mi|ai|issues|多個問題|多个问题|問題條目|问题条目|數個問題|数个问题)\s*\|[^}]+\{/im.exec(pageText);
if (Twinkle.tag.alreadyPresentTags.length > 0) {
if (miTest && groupableTags.length > 0) {
makeCheckboxesForAlreadyPresentTags();
Morebits.status.info(wgULS('信息', '資訊'), wgULS('加入支持的标记入已存在的{{multiple issues}}', '加入支援的標記入已存在的{{multiple issues}}'));
container.append({
type: 'header',
tagText = '';
id: 'tagHeader1',
$.each(groupableTags, addTag);
var miRegex = new RegExp("(\\{\\{\\s*".concat(miTest[1], "\\s*(?:\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?)\\}\\}\\s*"), 'im');
label: '可用的维护标记'
pageText = pageText.replace(miRegex, "$1".concat(tagText, "}}\n"));
});
}
tagText = '';
addUngroupedTags();

// Avoid repeatedly resorting
(_Twinkle$tag$article = Twinkle.tag.article).alphabeticalList || (_Twinkle$tag$article.alphabeticalList = Object.keys(Twinkle.tag.article.flatObject).sort());
var checkboxes = [];
Twinkle.tag.article.alphabeticalList.forEach(function (tag) {
if (!Twinkle.tag.alreadyPresentTags.includes(tag)) {
checkboxes.push(makeCheckbox(tag, Twinkle.tag.article.flatObject[tag].description));
}
});
container.append({
type: 'checkbox',
name: 'tags',
list: checkboxes
});
}

// append any custom tags
if (Twinkle.getPref('customTagList').length) {
container.append({
type: 'header',
label: '自定义模板'
});
container.append({
type: 'checkbox',
name: 'tags',
list: Twinkle.getPref('customTagList').map(function (el) {
el.checked = Twinkle.tag.checkedTags.includes(el.value);
return el;
})
});
}
var $workarea = $(form).find('#tagWorkArea');
var rendered = container.render();
$workarea.empty().append(rendered);

// for quick filter:
$allCheckboxDivs = $workarea.find('[name=tags], [name=existingTags]').parent();
$allHeaders = $workarea.find('h5, .quickformDescription');
form.quickfilter.value = ''; // clear search, because the search results are not preserved over mode change
form.quickfilter.focus();

// 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'
});
Morebits.quickForm.getElements(form, 'existingTags').forEach(generateLinks);
Morebits.quickForm.getElements(form, 'tags').forEach(generateLinks);

// tally tags added/removed, update statusNode text
var statusNode = document.querySelector('#tw-tag-status');
$('[name=tags], [name=existingTags]').on('click', function () {
if (this.name === 'tags') {
Twinkle.tag.status.numAdded += this.checked ? 1 : -1;
} else if (this.name === 'existingTags') {
Twinkle.tag.status.numRemoved += this.checked ? -1 : 1;
}
var firstPart = "\u52A0\u5165".concat(Twinkle.tag.status.numAdded, "\u4E2A\u6807\u8BB0");
var secondPart = "\u79FB\u9664".concat(Twinkle.tag.status.numRemoved, "\u4E2A\u6807\u8BB0");
statusNode.textContent = (Twinkle.tag.status.numAdded ? " ".concat(firstPart) : '') + (Twinkle.tag.status.numRemoved ? (Twinkle.tag.status.numAdded ? ';' : ' ') + secondPart : '');
});
};

/**
* Adds a link to each template's description page
*
* @param {Morebits.quickForm.element} checkbox associated with the template
*/
var generateLinks = function generateLinks(checkbox) {
var link = Morebits.htmlNode('a', '>');
link.setAttribute('class', 'tag-template-link');
var tagname = checkbox.values;
link.setAttribute('href', mw.util.getUrl((!tagname.includes(':') ? 'Template:' : '') + (!tagname.includes('|') ? tagname : tagname.slice(0, tagname.indexOf('|')))));
link.setAttribute('target', '_blank');
$(checkbox).parent().append(["\xA0", link]);
};

// Tags for ARTICLES start here
Twinkle.tag.article = {};

// Tags arranged by category; will be used to generate the alphabetical list,
// but tags should be in alphabetical order within the categories
// excludeMI: true indicate a tag that *does not* work inside {{multiple issues}}
// Add new categories with discretion - the list is long enough as is!
Twinkle.tag.article.tagList = [{
key: '清理和维护模板',
value: [{
key: '常规清理',
value: [{
tag: 'Cleanup',
description: '可能需要进行清理,以符合求闻百科的质量标准'
}, {
tag: 'Cleanup rewrite',
description: '不符合求闻百科的质量标准,需要完全重写'
}, {
tag: 'Cleanup-jargon',
description: '包含过多行话或专业术语,可能需要简化或提出进一步解释'
}, {
tag: 'Copy edit',
description: '需要编修,以确保文法、用词、语气、格式、标点等使用恰当'
}]
}, {
key: '可能多余的内容',
value: [{
tag: 'Copypaste',
description: '内容可能是从某个来源处拷贝后粘贴'
}, {
tag: 'External links',
description: '使用外部链接的方式可能不符合求闻百科的方针或指引'
}, {
tag: 'Non-free',
description: '可能过多或不当地使用了受著作权保护的文字、图像或多媒体文件'
}]
}, {
key: '结构和导言',
value: [{
tag: 'Lead too long',
description: '导言部分也许过于冗长'
}, {
tag: 'Lead too short',
description: '导言部分也许不足以概括其内容'
}, {
tag: 'Very long',
description: '可能过于冗长'
}]
}, {
key: '虚构作品相关清理',
value: [{
tag: 'In-universe',
description: '使用小说故事内的观点描述一个虚构事物'
}, {
tag: 'Long plot',
description: '可能包含过于详细的剧情摘要'
}]
}]
}, {
key: '常规条目问题',
value: [{
key: '重要性和知名度',
value: [{
tag: 'Notability',
description: '可能不符合通用关注度指引',
excludeMI: true
},
// has a subgroup with subcategories
{
tag: 'Notability Unreferenced',
description: '可能具备关注度,但需要来源加以彰显'
}]
}, {
key: '写作风格',
value: [{
tag: 'Advert',
description: '类似广告或宣传性内容'
}, {
tag: 'Fanpov',
description: '类似爱好者网页'
}, {
tag: 'How-to',
description: '包含指南或教学内容'
}, {
tag: 'Inappropriate person',
description: '使用不适当的第一人称和第二人称'
}, {
tag: 'Newsrelease',
description: '阅读起来像是新闻稿及包含过度的宣传性语调'
}, {
tag: 'Prose',
description: '使用了日期或时间列表式记述,需要改写为连贯的叙述性文字'
}, {
tag: 'Review',
description: '阅读起来类似评论,需要清理'
}, {
tag: 'Tone',
description: '语调或风格可能不适合百科全书的写作方式'
}]
}, {
key: '内容',
value: [/* { tag: 'Expand language', description: '可以根据其他语言版本扩展' }, */ // these three have a subgroup with several options
{
tag: 'Missing information',
description: '缺少必要的信息'
},
// these three have a subgroup with several options
{
tag: 'Substub',
description: '过于短小',
excludeMI: true
}, {
tag: 'Unencyclopedic',
description: '可能不适合写入百科全书'
}]
}, {
key: '信息和细节',
value: [{
tag: 'Expert needed',
description: '需要精通或熟悉本主题的专业人士(专家)参与及协助编辑'
}, {
tag: 'Overly detailed',
description: '包含太多过度细节内容'
}, {
tag: 'Trivia',
description: '应避免有陈列杂项、琐碎资料的部分'
}]
}, {
key: '时间性',
value: [{
tag: 'Current',
description: '记述新闻动态',
excludeMI: true
},
// Works but not intended for use in MI
{
tag: 'Update',
description: '当前条目或章节需要更新'
}]
}, {
key: '中立、偏见和事实准确性',
value: [{
tag: 'Autobiography',
description: '类似一篇自传,或内容主要由条目描述的当事人或组织撰写、编辑'
}, {
tag: 'COI',
description: '主要贡献者与本条目所宣扬的内容可能存在利益冲突'
}, {
tag: 'Disputed',
description: '内容疑欠准确,有待查证'
}, {
tag: 'Globalize',
description: '仅具有一部分地区的信息或观点'
}, {
tag: 'Hoax',
description: '真实性被质疑'
}, {
tag: 'POV',
description: '中立性有争议。内容、语调可能带有明显的个人观点或地方色彩'
}, {
tag: 'Self-contradictory',
description: '内容自相矛盾'
}, {
tag: 'Weasel',
description: '语义模棱两可而损及其中立性或准确性'
}]
}, {
key: '可供查证和来源',
value: [{
tag: 'BLPdispute',
description: '可能违反了求闻百科关于生者传记的方针'
}, {
tag: 'BLPsources',
description: '生者传记需要补充更多可供查证的来源'
}, {
tag: 'BLP unsourced',
description: '生者传记没有列出任何参考或来源'
}, {
tag: 'Citecheck',
description: '可能包含不适用或被曲解的引用资料,部分内容的准确性无法被证实'
}, {
tag: 'More footnotes needed',
description: '因为文内引用不足,部分字句的来源仍然不明'
}, {
tag: 'No footnotes',
description: '因为没有内文引用而来源仍然不明'
}, {
tag: 'Onesource',
description: '极大或完全地依赖于某个单一的来源'
}, {
tag: 'Original research',
description: '可能包含原创研究或未查证内容'
}, {
tag: 'Primarysources',
description: '依赖第一手来源'
}, {
tag: 'Refimprove',
description: '需要补充更多来源'
}, {
tag: 'Unreferenced',
description: '没有列出任何参考或来源'
}]
}]
}, {
key: '具体内容问题',
value: [{
key: '语言',
value: [{
tag: 'NotMandarin',
description: '包含过多不是现代标准汉语的内容',
excludeMI: true
}, {
tag: 'Rough translation',
description: '翻译品质不佳'
}]
}, {
key: '链接',
value: [{
tag: 'Dead end',
description: '需要加上内部链接以构筑百科全书的链接网络'
}, {
tag: 'Orphan',
description: '没有或只有很少链入页面'
}, {
tag: 'Overlinked',
description: '含有过多、重复、或不必要的内部链接'
}, {
tag: 'Underlinked',
description: '需要更多内部链接以构筑百科全书的链接网络'
}]
}, {
key: '参考技术',
value: [{
tag: 'Citation style',
description: '引用需要进行清理'
}]
}, {
key: '分类',
value: [{
tag: 'Improve categories',
description: '需要更多页面分类',
excludeMI: true
}, {
tag: 'Uncategorized',
description: '缺少页面分类',
excludeMI: true
}]
}]
}, {
key: '合并、拆分、移动',
value: [{
tag: 'Merge from',
description: '建议将页面并入本页面',
excludeMI: true
}, {
tag: 'Merge to',
description: '建议将此页面并入页面',
excludeMI: true
}, {
tag: 'Merge',
description: '建议此页面与页面合并',
excludeMI: true
}, {
tag: 'Requested move',
description: '建议将此页面移动到新名称',
excludeMI: true
}, {
tag: 'Split',
description: '建议将此页面分割为多个页面',
excludeMI: true
}]
}];

// Tags for REDIRECTS start here
// Not by policy, but the list roughly approximates items with >500
// transclusions from Template:R template index
Twinkle.tag.redirectList = [{
key: '常用模板',
value: [{
tag: '合并重定向',
description: '保持页面题名至相应主条目,令页面内容在合并后仍能保存其编辑历史'
}, {
tag: '简繁重定向',
description: '引导简体至繁体,或繁体至简体'
}, {
tag: '关注度重定向',
description: '缺乏关注度的子主题向有关注度的母主题的重定向'
}, {
tag: '模板重定向',
description: '指向模板的重定向页面'
}, {
tag: '别名重定向',
description: '标题的其他名称、笔名、绰号、同义字等'
}, {
tag: '译名重定向',
description: '人物、作品等各项事物的其他翻译名称'
}, {
tag: '缩写重定向',
description: '标题缩写'
}, {
tag: '拼写重定向',
description: '标题的其他不同拼写'
}, {
tag: '错字重定向',
description: '纠正标题的常见错误拼写或误植'
}, {
tag: '旧名重定向',
description: '将事物早前的名称引导至更改后的主题'
}, {
tag: '全名重定向',
description: '标题的完整或更完整名称'
}, {
tag: '短名重定向',
description: '完整标题名称或人物全名的部分、不完整的名称或简称'
}, {
tag: '姓氏重定向',
description: '人物姓氏'
}, {
tag: '名字重定向',
description: '人物人名'
}, {
tag: '本名重定向',
description: '人物本名'
}, {
tag: '非中文重定向',
description: '非中文标题',
subgroup: [{
name: 'altLangFrom',
type: 'input',
label: '本重新導向的語言(可選)',
tooltip: '輸入重新導向名稱所使用語言的ISO 639代碼,例如en代表英語,代碼可參見 Template:ISO_639_name'
}]
}, {
tag: '日文重定向',
description: '日语名称'
}]
}, {
key: '偶用模板',
value: [{
tag: '角色重定向',
description: '电视剧、电影、书籍等作品的角色'
}, {
tag: '章节重定向',
description: '导向至较高密度组织的页面'
}, {
tag: '列表重定向',
description: '导向至低密度的列表'
}, {
tag: '可能性重定向',
description: '导向至当前提供内容更为详尽的目标页面'
}, {
tag: '关联字重定向',
description: '标题名称关联字'
}, {
tag: '条目请求重定向',
description: '需要独立条目的页面',
subgroup: [{
name: 'reqArticleLang',
type: 'input',
label: '外語語言代碼:',
tooltip: '使用ISO 639代碼,可參見 Template:ISO_639_name'
}, {
name: 'reqArticleTitle',
type: 'input',
label: '外語頁面名稱:',
size: 60
}]
}, {
tag: '快捷方式重定向',
description: '求闻百科快捷方式'
}]
}, {
key: '鲜用模板',
value: [{
tag: '词组重定向',
description: '将词组/词组/成语指向切题的条目及恰当章节'
}, {
tag: '消歧义页重定向',
description: '指向消歧义页'
}, {
tag: '域名重定向',
description: '域名'
}, {
tag: '年代重定向',
description: '于年份条目导向至年代条目'
}, {
tag: '用户框模板重定向',
description: '用户框模板'
}, {
tag: '重定向模板用重定向',
description: '导向至重定向模板'
}, {
tag: 'EXIF重定向',
description: 'JPEG图像文件包含EXIF信息'
}]
}];

// maintenance tags for FILES start here

Twinkle.tag.fileList = [{
key: '著作权和来源问题标签',
value: [{
label: '{{Non-free reduce}}:' + '非低分辨率的合理使用图像(或过长的音频剪辑等)',
value: 'Non-free reduce'
}]
},
/* {
key: '求闻共享资源相关标签',
value: [
{
label:
'{{Copy to Qiuwen Share}}:' +
'自由著作权文件应该被移动至求闻共享资源',
value: 'Copy to Qiuwen Share'
},
{
label: '{{Do not move to Share}}:' + '不要移动至求闻共享资源',
value: 'Do not move to Share',
subgroup: {
type: 'input',
name: 'DoNotMoveToShare_reason',
label: '原因:',
tooltip: '输入不应该将该图像移动到求闻共享资源的原因(必填)。'
}
},
{
label: '{{Keep local}}:' + '请求在本地保留求闻共享资源的文件副本',
value: 'Keep local',
subgroup: [
{
type: 'input',
name: 'keeplocalName',
label: '共享资源的不同图像名称:',
tooltip:
'输入在共享资源的图像名称(若不同于本地名称),不包括 File: 前缀'
},
{
type: 'input',
name: 'keeplocalReason',
label: '原因:',
tooltip: '输入请求在本地保留文件副本的原因(可选):'
}
]
},
{
label: '{{Now Share}}:' + '文件已被复制到求闻共享资源',
value: 'Now Share',
subgroup: {
type: 'input',
name: 'nowshareName',
label: '共享资源的不同图像名称:',
tooltip: '输入在共享资源的图像名称(若不同于本地名称),不包括 File: 前缀'
}
}
]
}, */
{
key: '清理标签',
value: [{
label: '{{Watermark}}:' + '图像包含了水印',
value: 'Watermark'
}, {
label: '{{Rename media}}:' + '文件应该根据文件名称指引被重命名',
value: 'Rename media',
subgroup: [{
type: 'input',
name: 'renamemediaNewname',
label: '新名称:',
tooltip: '输入图像的新名称(可选)'
}, {
type: 'input',
name: 'renamemediaReason',
label: '原因:',
tooltip: '输入重命名的原因(可选)'
}]
}, {
label: '{{Should be SVG}}:' + 'PNG、GIF、JPEG文件应该重制成矢量图形',
value: 'Should be SVG'
}]
}, {
key: '文件取代标签',
value: [{
label: '{{Obsolete}}:' + '有新版本可用的过时文件',
value: 'Obsolete'
}, {
label: '{{Vector version available}}:' + '有矢量图形可用的非矢量图形文件',
value: 'Vector version available'
}],
buildFilename: true
}];
Twinkle.tag.callbacks = {
article: function article(pageobj) {
// Remove tags that become superfluous with this action
var pageText = pageobj.getPageText().replace(/{{\s*([Nn]ew unreviewed article|[Uu]nreviewed|[Uu]serspace draft)\s*(\|(?:{{[^{}]*}}|[^{}])*)?}}\s*/g, '');
var params = pageobj.getCallbackParameters();

/**
* Saves the page following the removal of tags if any. The last step.
* Called from removeTags()
*/
var postRemoval = function postRemoval() {
if (params.tagsToRemove.length) {
// Remove empty {{multiple issues}} if found
pageText = pageText.replace(/{{(multiple ?issues|article ?issues|mi|ai|issues|多個問題|多个问题|問題條目|问题条目|數個問題|数个问题)\s*\|\s*}}\n?/im, '');
// Remove single-element {{multiple issues}} if found
pageText = pageText.replace(/{{(?:multiple ?issues|article ?issues|mi|ai|issues|多個問題|多个问题|問題條目|问题条目|數個問題|数个问题)\s*\|\s*({{(?:{{[^{}]*}}|[^{}])+}})\s*}}/im, '$1');
}

// Build edit summary
var makeSentence = function makeSentence(array) {
if (array.length < 3) {
return array.join('和');
}
var last = array.pop();
return "".concat(array.join('、'), "\u548C").concat(last);
};
var makeTemplateLink = function makeTemplateLink(tag) {
var text = '{{[[';
// if it is a custom tag with a parameter
if (tag.includes('|')) {
tag = tag.slice(0, tag.indexOf('|'));
}
text += tag.includes(':') ? tag : "Template:".concat(tag, "|").concat(tag);
return "".concat(text, "]]}}");
};
var summaryText;
var addedTags = params.tags.map(makeTemplateLink);
var removedTags = params.tagsToRemove.map(makeTemplateLink);
if (addedTags.length) {
summaryText = "\u52A0\u5165".concat(makeSentence(addedTags));
summaryText += removedTags.length ? "\u4E26\u79FB\u9664".concat(makeSentence(removedTags)) : '';
} else {
summaryText = "\u79FB\u9664".concat(makeSentence(removedTags));
}
summaryText += '标记';
if (params.reason) {
summaryText += "\uFF1A".concat(params.reason);
}

// avoid truncated summaries
if (summaryText.length > 499) {
summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)]]/g, '$1');
}
pageobj.setPageText(pageText);
pageobj.setEditSummary(summaryText);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
pageobj.setCreateOption('nocreate');
pageobj.save(function () {
// special functions for merge tags
if (params.mergeReason) {
// post the rationale on the talk page (only operates in main namespace)
var talkpage = new Morebits.wiki.page("Talk:".concat(params.discussArticle), '将理由贴进讨论页');
talkpage.setNewSectionText("".concat(params.mergeReason.trim(), " ~~~~"));
talkpage.setNewSectionTitle("\u8BF7\u6C42\u4E0E[[".concat(params.nonDiscussArticle, "]]\u5408\u5E76"));
talkpage.setChangeTags(Twinkle.changeTags);
talkpage.setWatchlist(Twinkle.getPref('watchMergeDiscussions'));
talkpage.setCreateOption('recreate');
talkpage.newSection();
}
if (params.mergeTagOther) {
// tag the target page if requested
var otherTagName = 'Merge';
if (params.mergeTag === 'Merge from') {
otherTagName = 'Merge to';
} else if (params.mergeTag === 'Merge to') {
otherTagName = 'Merge from';
}
}
else if (params.group && !miTest && groupableExistingTags.length + groupableTags.length >= 2) {
var newParams = {
Morebits.status.info(wgULS('信息', '資訊'), wgULS('加入支持的标记入{{multiple issues}}', '加入支援的標記入{{multiple issues}}'));
tags: [otherTagName],
tagsToRemove: [],
tagText += '{{Multiple issues|\n';
tagsToRemain: [],
/**
mergeTarget: Morebits.pageNameNorm,
* Adds newly added tags to MI
discussArticle: params.discussArticle,
*/
talkDiscussionTitle: params.talkDiscussionTitle,
var addNewTagsToMI_1 = function () {
talkDiscussionTitleLinked: params.talkDiscussionTitleLinked
$.each(groupableTags, addTag);
};
tagText += '}}\n';
addUngroupedTags();
var otherpage = new Morebits.wiki.page(params.mergeTarget, "\u6807\u8BB0\u5176\u4ED6\u9875\u9762\uFF08".concat(params.mergeTarget, "\uFF09"));
otherpage.setCallbackParameters(newParams);
};
otherpage.load(Twinkle.tag.callbacks.article);
var getRedirectsFor_1 = [];
// Reposition the tags on the page into {{multiple issues}}, if found with its
}
// proper name, else moves it to `getRedirectsFor` array to be handled later
// special functions for requested move tags
if (params.moveReason) {
groupableExistingTags.forEach(function (tag) {
var tag_re = new RegExp("(\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|[^}]+)?\\}\\}\\n?)"));
// post the rationale on the talk page (only operates in main namespace)
var moveTalkpageText = "\n\n{{subst:RM|1=".concat(params.moveReason.trim());
if (tag_re.test(pageText)) {
if (params.moveTarget) {
tagText += tag_re.exec(pageText)[1];
moveTalkpageText += "|2=".concat(params.moveTarget);
pageText = pageText.replace(tag_re, '');
}
else {
getRedirectsFor_1.push("Template:".concat(tag));
}
});
if (!getRedirectsFor_1.length) {
addNewTagsToMI_1();
return;
}
var api = new Morebits.wiki.api(wgULS('获取模板重定向', '取得模板重新導向'), {
action: 'query',
prop: 'linkshere',
titles: getRedirectsFor_1.join('|'),
redirects: 1,
lhnamespace: '10',
lhshow: 'redirect',
lhlimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
}, function (apiobj) {
$(apiobj.responseXML)
.find('page')
.each(function (idx, page) {
var found = false;
$(page)
.find('lh')
.each(function (idx, el) {
var tag = $(el).attr('title').slice(9);
var tag_re = new RegExp("(\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|[^}]*)?\\}\\}\\n?)"));
if (tag_re.test(pageText)) {
tagText += tag_re.exec(pageText)[1];
pageText = pageText.replace(tag_re, '');
found = true;
return false; // break out of $.each
}
});
if (!found) {
Morebits.status.warn(wgULS('信息', '資訊'), wgULS('无法在页面上找到{{', '無法在頁面上找到{{') +
$(page).attr('title').slice(9) +
wgULS('}}……跳过', '}}……跳過'));
}
});
addNewTagsToMI_1();
});
api.post();
}
}
moveTalkpageText += '}}';
else {
var moveTalkpage = new Morebits.wiki.page("Talk:".concat(params.discussArticle), '将理由贴进讨论页');
tags = tags.concat(groupableTags);
moveTalkpage.setAppendText(moveTalkpageText);
addUngroupedTags();
moveTalkpage.setEditSummary("\u8BF7\u6C42\u79FB\u52A8".concat(params.moveTarget ? "\u81F3[[".concat(params.moveTarget, "]]") : ''));
moveTalkpage.setChangeTags(Twinkle.changeTags);
moveTalkpage.setCreateOption('recreate');
moveTalkpage.append();
}
});
if (params.patrol) {
pageobj.patrol();
}
};

/**
* Removes the existing tags that were deselected (if any)
* Calls postRemoval() when done
*/
var removeTags = function removeTags() {
if (params.tagsToRemove.length === 0) {
postRemoval();
return;
}
Morebits.status.info('信息', '移除取消选择的已存在标记');
var getRedirectsFor = [];

// Remove the tags from the page text, if found in its proper name,
// otherwise moves it to `getRedirectsFor` array earmarking it for
// later removal
params.tagsToRemove.forEach(function (tag) {
var tag_re = new RegExp("\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|[^}]+)?\\}\\}\\n?"));
if (tag_re.test(pageText)) {
pageText = pageText.replace(tag_re, '');
} else {
getRedirectsFor.push("Template:".concat(tag));
}
});
if (!getRedirectsFor.length) {
postRemoval();
return;
}

// Remove tags which appear in page text as redirects
var api = new Morebits.wiki.api('获取模板重定向', {
action: 'query',
prop: 'linkshere',
titles: getRedirectsFor.join('|'),
redirects: 1,
lhnamespace: '10',
lhshow: 'redirect',
lhlimit: 'max' // 500 is max for normal users, 5000 for bots and sysops
}, function (apiobj) {
$(apiobj.responseXML).find('page').each(function (_idx, page) {
var removed = false;
$(page).find('lh').each(function (_idx, el) {
var tag = $(el).attr('title').slice(9);
var tag_re = new RegExp("\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?\\}\\}\\n?"));
if (tag_re.test(pageText)) {
pageText = pageText.replace(tag_re, '');
removed = true;
return false; // break out of $.each
}
});

if (!removed) {
Morebits.status.warn('信息', "\u65E0\u6CD5\u5728\u9875\u9762\u4E0A\u627E\u5230{{".concat($(page).attr('title').slice(9), "}}\u2026\u8DF3\u8FC7"));
}
}
});
},
postRemoval();
redirect: function (pageobj) {
var params = pageobj.getCallbackParameters();
});
api.post();
var pageText = pageobj.getPageText();
};
var tagRe;
var tagText = '';
if (!params.tags.length) {
removeTags();
var summaryText = '加入';
return;
var tags = [];
}
var i;
for (i = 0; i < params.tags.length; i++) {
var tagRe,
tagRe = new RegExp("(\\{\\{".concat(params.tags[i], "(\\||\\}\\}))"), 'im');
tagText = '',
tags = [];
if (!tagRe.exec(pageText)) {
tags.push(params.tags[i]);
var groupableTags = [],
groupableExistingTags = [];
// Executes first: addition of selected tags
/**
* Updates `tagText` with the syntax of `tagName` template with its parameters
*
* @param {number} _tagIndex
* @param {string} tagName
*/
var addTag = function addTag(_tagIndex, tagName) {
var currentTag = '';
if (tagName === 'Uncategorized' || tagName === 'Improve categories') {
pageText += "\n\n{{".concat(tagName, "|time={{subst:#time:c}}}}");
} else {
currentTag += "{{".concat(tagName);
// fill in other parameters, based on the tag
switch (tagName) {
/* case 'Expand language': {
currentTag += `|1=${params.expandLanguage}`;
if (params.highQualityArticle) {
currentTag += '|status=yes';
}
if (params.expandLanguage2) {
currentTag += `|2=${params.expandLanguage2}`;
if (params.highQualityArticle2) {
currentTag += '|status2=yes';
}
}
if (params.expandLanguage3) {
currentTag += `|3=${params.expandLanguage3}`;
if (params.highQualityArticle3) {
currentTag += '|status3=yes';
}
}
break;
} */
case 'Expert needed':
{
currentTag += "|subject=".concat(params.expert);
if (params.expert2) {
currentTag += "|subject2=".concat(params.expert2);
}
}
if (params.expert3) {
else {
Morebits.status.warn(wgULS('信息', '資訊'), wgULS('在重定向上找到{{', '在重新導向上找到{{') + params.tags[i] + wgULS('}}……跳过', '}}……跳過'));
currentTag += "|subject3=".concat(params.expert3);
}
}
break;
}
}
var addTag = function (tagIndex, tagName) {
case 'Merge':
tagText += "\n{{".concat(tagName);
case 'Merge to':
if (tagName === '非中文重定向') {
case 'Merge from':
if (params.altLangFrom) {
{
tagText += "|1=".concat(params.altLangFrom);
if (params.mergeTarget) {
// normalize the merge target for now and later
params.mergeTarget = Morebits.string.toUpperCaseFirstChar(params.mergeTarget.replace(/_/g, ' '));
currentTag += "|".concat(params.mergeTarget);

// link to the correct section on the talk page, for article space only
if (mw.config.get('wgNamespaceNumber') === 0 && (params.mergeReason || params.discussArticle)) {
if (!params.discussArticle) {
// discussArticle is the article whose talk page will contain the discussion
params.discussArticle = tagName === 'Merge to' ? params.mergeTarget : mw.config.get('wgTitle');
// nonDiscussArticle is the article which won't have the discussion
params.nonDiscussArticle = tagName === 'Merge to' ? mw.config.get('wgTitle') : params.mergeTarget;
params.talkDiscussionTitle = "\u8BF7\u6C42\u4E0E".concat(params.nonDiscussArticle, "\u5408\u5E76");
}
}
currentTag += "|discuss=Talk:".concat(params.discussArticle, "#").concat(params.talkDiscussionTitle);
}
}
}
else if (tagName === '条目请求重定向' || tagName === '條目請求重定向') {
break;
if (params.reqArticleLang && params.reqArticleTitle) {
}
tagText += "|1=".concat(params.reqArticleLang);
case 'Missing information':
tagText += "|2=".concat(params.reqArticleTitle);
{
currentTag += "|1=".concat(params.missingInformation);
}
break;
}
case 'Notability':
{
if (params.notability !== 'none') {
currentTag += "|3=".concat(params.notability);
}
}
break;
tagText += '}}';
}
if (tagIndex > 0) {
case 'Requested move':
if (tagIndex === tags.length - 1) {
{
summaryText += '和';
if (params.moveTarget) {
}
// normalize the move target for now and later
else if (tagIndex < tags.length - 1) {
summaryText += '、';
params.moveTarget = Morebits.string.toUpperCaseFirstChar(params.moveTarget.replace(/_/g, ' '));
params.discussArticle = mw.config.get('wgTitle');
}
currentTag += "|".concat(params.moveTarget);
}
}
summaryText += "{{[[:".concat(tagName.includes(':') ? tagName : "Template:".concat(tagName, "|").concat(tagName), "]]}}");
break;
}
};
case 'Split':
if (!tags.length) {
Morebits.status.warn(wgULS('信息', '資訊'), wgULS('没有标签可供标记', '沒有標籤可供標記'));
{
if (params.target1) {
}
currentTag += "|1=".concat(params.target1);
tags.sort();
$.each(tags, addTag);
// Check for all Rcat shell redirects (from #433)
if (pageText.match(/{{(?:redr|this is a redirect|r(?:edirect)?(?:.?cat.*)?[ _]?sh)/i)) {
// Regex inspired by [[User:Kephir/gadgets/sagittarius.js]] ([[Special:PermaLink/831402893]])
var oldTags = pageText.match(/(\s*{{[A-Za-z\s]+\|(?:\s*1=)?)((?:[^|{}]|{{[^}]+}})+)(}})\s*/i);
pageText = pageText.replace(oldTags[0], oldTags[1] + tagText + oldTags[2] + oldTags[3]);
}
else {
// Fold any pre-existing Rcats into taglist and under Rcatshell
var pageTags = pageText.match(/\s*{{.+?重定向.*?}}/gim);
var oldPageTags_1 = '';
if (pageTags) {
pageTags.forEach(function (pageTag) {
var pageRe = new RegExp(Morebits.string.escapeRegExp(pageTag), 'img');
pageText = pageText.replace(pageRe, '');
pageTag = pageTag.trim();
oldPageTags_1 += "\n".concat(pageTag);
});
}
}
pageText += "\n{{Redirect category shell|".concat(tagText).concat(oldPageTags_1, "\n}}");
if (params.target2) {
}
currentTag += "|2=".concat(params.target2);
summaryText +=
(tags.length > 0 ? wgULS('标记', '標記') : '{{Redirect category shell}}') +
wgULS('到重定向', '到重新導向');
// avoid truncated summaries
if (summaryText.length > 499) {
summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)\]\]/g, '$1');
}
pageobj.setPageText(pageText);
pageobj.setEditSummary(summaryText);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
pageobj.setCreateOption('nocreate');
pageobj.save();
if (params.patrol) {
pageobj.patrol();
}
},
file: function (pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var summary = '加入';
// Add maintenance tags
if (params.tags.length) {
var tagtext_1 = '';
var currentTag_1;
$.each(params.tags, function (k, tag) {
// when other commons-related tags are placed, remove "move to Share" tag
if (['Keep local', 'Now Ysarxiv Share', 'Do not move to Ysarxiv Share'].includes(tag)) {
text = text.replace(/{{(mtc|(copy |move )?to ?share|move to ysarxiv share|copy to ysarxiv share)[^}]*}}/gi, '');
}
if (tag === 'Vector version available') {
text = text.replace(/\{\{((convert to |convertto|should be |shouldbe|to)?svg|badpng|vectorize)[^}]*\}\}/gi, '');
}
currentTag_1 = tag;
switch (tag) {
case 'Now Commons':
currentTag_1 = "subst:".concat(currentTag_1); // subst
if (params.nowcommonsName !== '') {
currentTag_1 += "|1=".concat(params.nowcommonsName);
}
break;
case 'Keep local':
if (params.keeplocalName !== '') {
currentTag_1 += "|1=".concat(params.keeplocalName);
}
if (params.keeplocalReason !== '') {
currentTag_1 += "|reason=".concat(params.keeplocalReason);
}
break;
case 'Rename media':
if (params.renamemediaNewname !== '') {
currentTag_1 += "|1=".concat(params.renamemediaNewname);
}
if (params.renamemediaReason !== '') {
currentTag_1 += "|2=".concat(params.renamemediaReason);
}
break;
case 'Vector version available':
/* falls through */
case 'Obsolete':
currentTag_1 += "|1=".concat(params["".concat(tag.replace(/ /g, '_'), "File")]);
break;
case 'Do not move to Commons':
currentTag_1 += "|reason=".concat(params.DoNotMoveToCommons_reason);
break;
case 'Copy to Wikimedia Commons':
currentTag_1 += "|human=".concat(mw.config.get('wgUserName'));
break;
default:
break;
// don't care
}
currentTag_1 = "{{".concat(currentTag_1, "}}\n");
tagtext_1 += currentTag_1;
summary += "{{".concat(tag, "}}\u3001");
});
if (!tagtext_1) {
pageobj
.getStatusElement()
.warn(wgULS('用户取消操作,没什么要做的', '使用者取消操作,沒什麼要做的'));
return;
}
}
if (params.target3) {
text = tagtext_1 + text;
}
currentTag += "|3=".concat(params.target3);
}
pageobj.setPageText(text);
pageobj.setEditSummary(summary.substring(0, summary.length - 1));
break;
}
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
case 'Cleanup':
pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
{
if (params.cleanupReason) {
pageobj.setCreateOption('nocreate');
currentTag += "|reason=".concat(params.cleanupReason);
pageobj.save();
}
if (params.patrol) {
break;
pageobj.patrol();
}
}
default:
},
{
};
Twinkle.tag.callback.evaluate = function (e) {
break;
}
var form = e.target;
var params = Morebits.quickForm.getInputData(form);
}
// Validation
currentTag += '|time={{subst:#time:c}}}}\n';
// Given an array of incompatible tags, check if we have two or more selected
tagText += currentTag;
var checkIncompatible = function (conflicts, extra) {
}
var count = conflicts.reduce(function (sum, tag) { return (sum += params.tags.includes(tag)); }, 0);
};
if (count > 1) {

var message = "".concat(wgULS('请在以下标签中择一使用', '請在以下標籤中擇一使用'), "\uFF1A{{").concat(conflicts.join('}}、{{'), "}}\u3002");
/**
* Adds the tags which go outside {{multiple issues}}, either because
message += extra || '';
mw.notify(message, {
* these tags aren't supported in {{multiple issues}} or because
* {{multiple issues}} is not being added to the page at all
type: 'warn',
tag: 'friendlytag',
*/
});
var addUngroupedTags = function addUngroupedTags() {
$.each(tags, addTag);
return true;

// Insert tag after short description or any hatnotes,
// as well as deletion/protection-related templates
var wikipage = new Morebits.wikitext.page(pageText);
var templatesAfter = "".concat(Twinkle.hatnoteRegex
// Protection templates
, "pp|pp-.*?|") +
// CSD
'(?:Delete|Db-reason|D|Deletebecause|Db|速删|速刪|Speedy|SD|快删|快刪|CSD)|' +
// AfD
'[rsaiftcmv]fd';
pageText = wikipage.insertAfterTemplates(tagText, templatesAfter).getText();
removeTags();
};

// Separate tags into groupable ones (`groupableTags`) and non-groupable ones (`tags`)
params.tags.forEach(function (tag) {
tagRe = new RegExp("\\{\\{".concat(tag, "(\\||\\}\\})"), 'im');
// regex check for preexistence of tag can be skipped if in canRemove mode
if (Twinkle.tag.canRemove || !tagRe.test(pageText)) {
if (tag === 'Notability' && (mw.config.get('wgNamespaceNumber') === 0 || confirm('该页面不是条目,您仍要提报到关注度提报吗?'))) {
var qiuwen_page = new Morebits.wiki.page('qiuwen:关注度/提报', '加入关注度记录项');
qiuwen_page.setFollowRedirect(true);
qiuwen_page.setCallbackParameters(params);
qiuwen_page.load(Twinkle.tag.callbacks.notabilityList);
}
// condition Twinkle.tag.article.tags[tag] to ensure that its not a custom tag
// Custom tags are assumed non-groupable, since we don't know whether MI template supports them
if (Twinkle.tag.article.flatObject[tag] && !Twinkle.tag.article.flatObject[tag].excludeMI) {
groupableTags.push(tag);
} else {
tags.push(tag);
}
} else {
if (tag === 'Merge from') {
tags.push(tag);
} else {
Morebits.status.warn('信息', "\u5728\u9875\u9762\u4E0A\u627E\u5230{{".concat(tag, "}}\u2026\u8DF3\u8FC7"));
// don't do anything else with merge tags
if (['Merge', 'Merge to'].includes(tag)) {
params.mergeTarget = params.mergeReason = params.mergeTagOther = null;
}
}
}
}
});

// To-be-retained existing tags that are groupable
params.tagsToRemain.forEach(function (tag) {
// If the tag is unknown to us, we consider it non-groupable
if (Twinkle.tag.article.flatObject[tag] && !Twinkle.tag.article.flatObject[tag].excludeMI) {
groupableExistingTags.push(tag);
}
});
var miTest = /{{(multiple ?issues|article ?issues|mi|ai|issues|多個問題|多个问题|問題條目|问题条目|數個問題|数个问题)\s*\|[^}]+{/im.exec(pageText);
if (miTest && groupableTags.length > 0) {
Morebits.status.info('信息', '加入支持的标记入已存在的{{multiple issues}}');
tagText = '';
$.each(groupableTags, addTag);
var miRegex = new RegExp("(\\{\\{\\s*".concat(miTest[1], "\\s*(?:\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?)\\}\\}\\s*"), 'im');
pageText = pageText.replace(miRegex, "$1".concat(tagText, "}}\n"));
tagText = '';
addUngroupedTags();
} else if (params.group && !miTest && groupableExistingTags.length + groupableTags.length >= 2) {
Morebits.status.info('信息', '加入支持的标记入{{multiple issues}}');
tagText += '{{Multiple issues|\n';

/**
* Adds newly added tags to MI
*/
var addNewTagsToMI = function addNewTagsToMI() {
$.each(groupableTags, addTag);
tagText += '}}\n';
addUngroupedTags();
};
};
// Given a tag, ensure an associate parameter is present
var getRedirectsFor = [];
// Maybe just sock this away in each function???

var checkParameter = function (tag, parameter, description) {
// Reposition the tags on the page into {{multiple issues}}, if found with its
if (description === void 0) { description = '理由'; }
// proper name, else moves it to `getRedirectsFor` array to be handled later
if (params.tags.includes(tag) && params[parameter].trim() === '') {
groupableExistingTags.forEach(function (tag) {
var tag_re = new RegExp("(\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|[^}]+)?\\}\\}\\n?)"));
mw.notify("".concat(wgULS('您必须指定', '您必須指定'), "{{").concat(tag, "}}\u7684").concat(description, "\u3002"), {
if (tag_re.test(pageText)) {
type: 'warn',
tagText += tag_re.exec(pageText)[1];
tag: 'friendlytag',
pageText = pageText.replace(tag_re, '');
});
} else {
return true;
getRedirectsFor.push("Template:".concat(tag));
}
});
if (!getRedirectsFor.length) {
addNewTagsToMI();
return;
}
var api = new Morebits.wiki.api('获取模板重定向', {
action: 'query',
prop: 'linkshere',
titles: getRedirectsFor.join('|'),
redirects: 1,
lhnamespace: '10',
lhshow: 'redirect',
lhlimit: 'max' // 500 is max for normal users, 5000 for bots and sysops
}, function (apiobj) {
$(apiobj.responseXML).find('page').each(function (_idx, page) {
var found = false;
$(page).find('lh').each(function (_idx, el) {
var tag = $(el).attr('title').slice(9);
var tag_re = new RegExp("(\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|[^}]*)?\\}\\}\\n?)"));
if (tag_re.test(pageText)) {
tagText += tag_re.exec(pageText)[1];
pageText = pageText.replace(tag_re, '');
found = true;
return false; // break out of $.each
}
});

if (!found) {
Morebits.status.warn('信息', "\u65E0\u6CD5\u5728\u9875\u9762\u4E0A\u627E\u5230{{".concat($(page).attr('title').slice(9), "}}\u2026\u8DF3\u8FC7"));
}
}
});
};
// We could theoretically put them all checkIncompatible calls in a
addNewTagsToMI();
// forEach loop, but it's probably clearer not to have [[array one],
});
// [array two]] devoid of context. Likewise, all the checkParameter
api.post();
// calls could be in one if, but could be similarly confusing.
} else {
tags = tags.concat(groupableTags);
switch (Twinkle.tag.modeEn) {
addUngroupedTags();
case 'article':
params.tagsToRemove = form.getUnchecked('existingTags'); // not in `input`
}
params.tagsToRemain = params.existingTags || []; // container not created if none present
},
if (params.tags.includes('Merge') ||
notabilityList: function notabilityList(pageobj) {
params.tags.includes('Merge from') ||
// var text = pageobj.getPageText();
params.tags.includes('Merge to')) {
// var params = pageobj.getCallbackParameters();
if (checkIncompatible(['Merge', 'Merge from', 'Merge to'], wgULS('若需要多次合并,请使用{{Merge}}并用管道符分隔条目名(但在这种情形中Twinkle不能自动标记其他条目)。', '若需要多次合併,請使用{{Merge}}並用管道符分隔條目名(但在這種情形中Twinkle不能自動標記其他條目)。'))) {
pageobj.setAppendText("\n{{subst:Fameitem|title=".concat(Morebits.pageNameNorm, "}}"));
return;
pageobj.setEditSummary('加入' + "[[".concat(Morebits.pageNameNorm, "]]"));
}
pageobj.setChangeTags(Twinkle.changeTags);
if (!params.mergeTarget) {
pageobj.setCreateOption('recreate');
mw.notify(wgULS('请指定使用于merge模板中的另一个页面标题。', '請指定使用於merge模板中的另一個頁面標題。'), {
pageobj.append();
type: 'warn',
},
tag: 'friendlytag',
redirect: function redirect(pageobj) {
var params = pageobj.getCallbackParameters();
});
var pageText = pageobj.getPageText(),
return;
tagRe,
}
if ((params.mergeTagOther || params.mergeReason) && params.mergeTarget.includes('|')) {
tagText = '',
mw.notify(wgULS('当前还不支持在一次合并中标记多个条目,与开启关于多个条目的讨论。请不要勾选“标记其他条目”并清空“理由”框后再提交。', '目前還不支援在一次合併中標記多個條目,與開啟關於多個條目的討論。請不要勾選「標記其他條目」並清空「理由」框後再提交。'), {
summaryText = '加入';
type: 'warn',
var tags = [];
tag: 'friendlytag',
var i;
for (i = 0; i < params.tags.length; i++) {
});
return;
tagRe = new RegExp("(\\{\\{".concat(params.tags[i], "(\\||\\}\\}))"), 'im');
if (!tagRe.test(pageText)) {
}
tags.push(params.tags[i]);
} else {
Morebits.status.warn('信息', "\u5728\u91CD\u5B9A\u5411\u4E0A\u627E\u5230{{".concat(params.tags[i], "}}\u2026\u8DF3\u8FC7"));
}
}
var addTag = function addTag(tagIndex, tagName) {
tagText += "\n{{".concat(tagName);
if (tagName === '非中文重定向') {
if (params.altLangFrom) {
tagText += "|1=".concat(params.altLangFrom);
}
} else if ((tagName === '条目请求重定向' || tagName === '條目請求重定向') && params.reqArticleLang && params.reqArticleTitle) {
tagText += "|1=".concat(params.reqArticleLang);
tagText += "|2=".concat(params.reqArticleTitle);
}
tagText += '}}';
if (tagIndex > 0) {
if (tagIndex === tags.length - 1) {
summaryText += '和';
} else if (tagIndex < tags.length - 1) {
summaryText += '、';
}
}
summaryText += "{{[[:".concat(tagName.includes(':') ? tagName : "Template:".concat(tagName, "|").concat(tagName), "]]}}");
};
if (!tags.length) {
Morebits.status.warn('信息', '没有标签可供标记');
}
tags.sort();
$.each(tags, addTag);

// Check for all Rcat shell redirects (from #433)
if (/{{(?:redr|this is a redirect|r(?:edirect)?(?:.?cat.*)?[ _]?sh)/i.test(pageText)) {
// Regex inspired by [[User:Kephir/gadgets/sagittarius.js]] ([[Special:PermaLink/831402893]])
var oldTags = pageText.match(/(\s*{{[\sa-z]+\|(?:\s*1=)?)((?:[^{|}]|{{[^}]+}})+)(}})\s*/i);
pageText = pageText.replace(oldTags[0], oldTags[1] + tagText + oldTags[2] + oldTags[3]);
} else {
// Fold any pre-existing Rcats into taglist and under Rcatshell
var pageTags = pageText.match(/\s*{{.+?重定向.*?}}/gim);
var oldPageTags = '';
if (pageTags) {
pageTags.forEach(function (pageTag) {
var pageRe = new RegExp(Morebits.string.escapeRegExp(pageTag), 'img');
pageText = pageText.replace(pageRe, '');
pageTag = pageTag.trim();
oldPageTags += "\n".concat(pageTag);
});
}
pageText += "\n{{Redirect category shell|".concat(tagText).concat(oldPageTags, "\n}}");
}
summaryText += "".concat(tags.length > 0 ? '标记' : '{{Redirect category shell}}', "\u5230\u91CD\u5B9A\u5411");

// avoid truncated summaries
if (summaryText.length > 499) {
summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)]]/g, '$1');
}
pageobj.setPageText(pageText);
pageobj.setEditSummary(summaryText);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
pageobj.setCreateOption('nocreate');
pageobj.save();
if (params.patrol) {
pageobj.patrol();
}
},
file: function file(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var summary = '加入';

// Add maintenance tags
if (params.tags.length) {
var tagtext = '',
currentTag;
$.each(params.tags, function (_k, tag) {
// when other Qiuwen Share-related tags are placed, remove "move to Share" tag
if (['Keep local', 'Now Share', 'Do not move to Share'].includes(tag)) {
text = text.replace(/{{(mtc|(copy |move )?to ?share|move to qiuwen share|copy to qiuwen share)[^}]*}}/gi, '');
}
if (tag === 'Vector version available') {
text = text.replace(/{{((convert to |convertto|should be |shouldbe|to)?svg|badpng|vectorize)[^}]*}}/gi, '');
}
currentTag = tag;
switch (tag) {
case 'Now Share':
{
currentTag = "subst:".concat(currentTag); // subst
if (params.nowshareName !== '') {
currentTag += "|1=".concat(params.nowshareName);
}
}
if (checkParameter('Missing information', 'missingInformation', wgULS('缺少的内容', '缺少的內容'))) {
break;
}
return;
case 'Keep local':
{
if (params.keeplocalName !== '') {
currentTag += "|1=".concat(params.keeplocalName);
}
}
if (params.keeplocalReason !== '') {
if (checkParameter('Expert needed', 'expert', wgULS('专家领域', '專家領域'))) {
currentTag += "|reason=".concat(params.keeplocalReason);
return;
}
}
break;
break;
}
case 'file':
// Silly to provide the same string to each of these
case 'Rename media':
if (checkParameter('Obsolete', 'ObsoleteFile', wgULS('替换的文件名称', '替換的檔案名稱')) ||
{
checkParameter('Vector version available', 'Vector_version_availableFile', wgULS('替换的文件名称', '替換的檔案名稱'))) {
if (params.renamemediaNewname !== '') {
currentTag += "|1=".concat(params.renamemediaNewname);
return;
}
}
if (params.renamemediaReason !== '') {
if (checkParameter('Do not move to Commons', 'DoNotMoveToCommons_reason')) {
currentTag += "|2=".concat(params.renamemediaReason);
return;
}
}
break;
break;
}
case 'redirect':
case 'Vector version available':
/* falls through */
case 'Obsolete':
{
currentTag += "|1=".concat(params["".concat(tag.replace(/ /g, '_'), "File")]);
break;
break;
}
case 'Do not move to Share':
{
currentTag += "|reason=".concat(params.DoNotMoveToShare_reason);
break;
}
case 'Copy to Qiuwen Share':
{
currentTag += "|human=".concat(mw.config.get('wgUserName'));
break;
}
default:
default:
mw.notify("Twinkle.tag\uFF1A\u672A\u77E5\u6A21\u5F0F ".concat(Twinkle.tag.mode), {
{
type: 'warn',
tag: 'friendlytag',
});
break;
break;
}
// don't care
}

currentTag = "{{".concat(currentTag, "}}\n");
tagtext += currentTag;
summary += "{{".concat(tag, "}}\u3001");
});
if (!tagtext) {
pageobj.getStatusElement().warn('用户取消操作,没什么要做的');
return;
}
}
text = tagtext + text;
// File/redirect: return if no tags selected
// Article: return if no tag is selected and no already present tag is deselected
}
if (params.tags.length === 0 && (Twinkle.tag.modeEn !== 'article' || params.tagsToRemove.length === 0)) {
pageobj.setPageText(text);
mw.notify(wgULS('必须选择至少一个标记!', '必須選擇至少一個標記!'), {
pageobj.setEditSummary(summary.substring(0, summary.length - 1));
type: 'warn',
pageobj.setChangeTags(Twinkle.changeTags);
tag: 'friendlytag',
pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
});
pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
pageobj.setCreateOption('nocreate');
pageobj.save();
if (params.patrol) {
pageobj.patrol();
}
}
};
Twinkle.tag.callback.evaluate = function (e) {
var form = e.target;
var params = Morebits.quickForm.getInputData(form);

// Validation
// Given an array of incompatible tags, check if we have two or more selected
var checkIncompatible = function checkIncompatible(conflicts, extra) {
var count = conflicts.reduce(function (sum, tag) {
sum += params.tags.includes(tag);
return sum;
}, 0);
if (count > 1) {
var message = '请在以下标签中择一使用' + "\uFF1A{{".concat(conflicts.join('}}、{{'), "}}\u3002");
message += extra || '';
alert(message);
return true;
}
};
// Given a tag, ensure an associate parameter is present
// Maybe just sock this away in each function?
var checkParameter = function checkParameter(tag, parameter, description) {
description || (description = '理由');
if (params.tags.includes(tag) && params[parameter].trim() === '') {
alert('您必须指定' + "{{".concat(tag, "}}\u7684").concat(description, "\u3002"));
return true;
}
};

// We could theoretically put them all checkIncompatible calls in a
// forEach loop, but it's probably clearer not to have [[array one],
// [array two]] devoid of context. Likewise, all the checkParameter
// calls could be in one if, but could be similarly confusing.
switch (Twinkle.tag.mode) {
case '条目':
{
params.tagsToRemove = form.getUnchecked('existingTags'); // not in `input`
params.tagsToRemain = params.existingTags || []; // container not created if none present

if (params.tags.includes('Merge') || params.tags.includes('Merge from') || params.tags.includes('Merge to')) {
if (checkIncompatible(['Merge', 'Merge from', 'Merge to'], '若需要多次合并,请使用{{Merge}}并用管道符分隔条目名(但在这种情形中Twinkle不能自动标记其他条目)。')) {
return;
}
if (!params.mergeTarget) {
alert('请指定使用于merge模板中的另一个页面标题。');
return;
}
if ((params.mergeTagOther || params.mergeReason) && params.mergeTarget.includes('|')) {
alert('当前还不支持在一次合并中标记多个条目,与开启关于多个条目的讨论。请不要勾选“标记其他条目”并清空“理由”框后再提交。');
return;
}
}

/* if (checkParameter('Expand language', 'expandLanguage', '语言代码')) {
return;
} */
if (checkParameter('Missing information', 'missingInformation', '缺少的内容')) {
return;
return;
}
if (checkParameter('Expert needed', 'expert', '专家领域')) {
return;
}
break;
}
}
Morebits.simpleWindow.setButtonsEnabled(false);
case '文件':
{
Morebits.status.init(form);
Morebits.wiki.actionCompleted.redirect = Morebits.pageNameNorm;
// Silly to provide the same string to each of these
Morebits.wiki.actionCompleted.notice = wgULS('标记完成,将在几秒内刷新页面', '標記完成,將在幾秒內重新整理頁面');
if (checkParameter('Obsolete', 'ObsoleteFile', '替换的文件名称') || checkParameter('Vector version available', 'Vector_version_availableFile', '替换的文件名称')) {
return;
if (Twinkle.tag.modeEn === 'redirect') {
Morebits.wiki.actionCompleted.followRedirect = false;
}
if (checkParameter('Do not move to Share', 'DoNotMoveToShare_reason')) {
return;
}
break;
}
}
var ysarxiv_page = new Morebits.wiki.page(Morebits.pageNameNorm, wgULS('正在标记', '正在標記') + Twinkle.tag.mode);
case '重定向':
ysarxiv_page.setCallbackParameters(params);
{
ysarxiv_page.load(Twinkle.tag.callbacks[Twinkle.tag.modeEn]);
break;
}
};
Twinkle.addInitCallback(Twinkle.tag, 'tag');
default:
})(jQuery);
{
alert("Twinkle.tag\uFF1A\u672A\u77E5\u6A21\u5F0F ".concat(Twinkle.tag.mode));
break;
}
}


// File/redirect: return if no tags selected
// Article: return if no tag is selected and no already present tag is deselected
if (params.tags.length === 0 && (Twinkle.tag.mode !== '条目' || params.tagsToRemove.length === 0)) {
alert('必须选择至少一个标记!');
return;
}
Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.status.init(form);
Morebits.wiki.actionCompleted.redirect = Morebits.pageNameNorm;
Morebits.wiki.actionCompleted.notice = '标记完成,将在几秒内刷新页面';
if (Twinkle.tag.mode === '重定向') {
Morebits.wiki.actionCompleted.followRedirect = false;
}
var qiuwen_page = new Morebits.wiki.page(Morebits.pageNameNorm, "\u6B63\u5728\u6807\u8BB0".concat(Twinkle.tag.mode));
qiuwen_page.setCallbackParameters(params);
qiuwen_page.load(Twinkle.tag.callbacks[Twinkle.tag.mode]);
};
Twinkle.addInitCallback(Twinkle.tag, 'tag');
})(jQuery);
/* </nowiki> */
/* </nowiki> */

2023年9月12日 (二) 00:54的最新版本

/**
 * SPDX-License-Identifier: CC-BY-SA-4.0
 * _addText: '{{Twinkle Header}}'
 *
 * @base <https://git.qiuwen.wiki/InterfaceAdmin/Twinkle>
 * @source <https://github.com/TopRealm/Twinkle>
 */
/**
 * +--------------------------------------------------------+
 * |         === WARNING: GLOBAL GADGET FILE ===            |
 * +--------------------------------------------------------+
 * |      All changes should be made in the repository,     |
 * |              otherwise they will be lost.              |
 * +--------------------------------------------------------+
 * |      Changes to this page may affect many users.       |
 * |  Please discuss changes at talk page before editing.   |
 * +--------------------------------------------------------+
 */
/* <nowiki> */
/* Twinkle.js - friendlytag.js */
(function ($) {
    /**
     * friendlytag.js: Tag module
     * Mode of invocation: Tab ("Tag")
     * Active on: Existing articles and drafts; file pages with a corresponding file
     * which is local (not on Share); all redirects
     */
    Twinkle.tag = function () {
        // redirect tagging
        if (Morebits.isPageRedirect()) {
            Twinkle.tag.mode = wgULS('重定向', '重新導向');
            Twinkle.tag.modeEn = 'redirect';
            Twinkle.addPortletLink(Twinkle.tag.callback, wgULS('标记', '標記'), 'friendly-tag', wgULS('标记重定向', '標記重新導向'));
            // file tagging
        }
        else if (mw.config.get('wgNamespaceNumber') === 6 &&
            !document.getElementById('mw-sharedupload') &&
            document.getElementById('mw-imagepage-section-filehistory')) {
            Twinkle.tag.mode = wgULS('文件', '檔案');
            Twinkle.tag.modeEn = 'file';
            Twinkle.addPortletLink(Twinkle.tag.callback, wgULS('标记', '標記'), 'friendly-tag', wgULS('标记文件', '標記檔案'));
            // article/draft tagging
        }
        else if (([0, 302].includes(mw.config.get('wgNamespaceNumber')) && mw.config.get('wgCurRevisionId')) ||
            Morebits.pageNameNorm === Twinkle.getPref('sandboxPage')) {
            Twinkle.tag.mode = wgULS('条目', '條目');
            Twinkle.tag.modeEn = 'article';
            // Can't remove tags when not viewing current version
            Twinkle.tag.canRemove =
                mw.config.get('wgCurRevisionId') === mw.config.get('wgRevisionId') &&
                    // Disabled on latest diff because the diff slider could be used to slide
                    // away from the latest diff without causing the script to reload
                    !mw.config.get('wgDiffNewId');
            Twinkle.addPortletLink(Twinkle.tag.callback, wgULS('标记', '標記'), 'friendly-tag', wgULS('标记条目', '標記條目'));
        }
    };
    Twinkle.tag.checkedTags = [];
    Twinkle.tag.callback = function () {
        var Window = new Morebits.simpleWindow(630, Twinkle.tag.modeEn === 'article' ? 500 : 400);
        Window.setScriptName('Twinkle');
        Window.addFooterLink(wgULS('标记设置', '標記設定'), 'H:TW/PREF#tag');
        Window.addFooterLink(wgULS('Twinkle帮助', 'Twinkle說明'), 'H:TW/DOC#tag');
        var form = new Morebits.quickForm(Twinkle.tag.callback.evaluate);
        form.append({
            type: 'input',
            label: wgULS('筛选标记列表:', '篩選標記列表:'),
            name: 'quickfilter',
            size: '30',
            event: function twinkletagquickfilter() {
                // flush the DOM of all existing underline spans
                $allCheckboxDivs.find('.search-hit').each(function (i, e) {
                    var label_element = e.parentElement;
                    // This would convert <label>Hello <span class=search-hit>wo</span>rld</label>
                    // to <label>Hello world</label>
                    label_element.innerHTML = label_element.textContent;
                });
                if (this.value) {
                    $allCheckboxDivs.hide();
                    $allHeaders.hide();
                    var searchString_1 = this.value;
                    var searchRegex_1 = new RegExp(mw.util.escapeRegExp(searchString_1), 'i');
                    $allCheckboxDivs.find('label').each(function (_index, element) {
                        var label_text = element.textContent;
                        var searchHit = searchRegex_1.exec(label_text);
                        if (searchHit) {
                            var range = document.createRange();
                            var textnode = element.childNodes[0];
                            range.selectNodeContents(textnode);
                            range.setStart(textnode, searchHit.index);
                            range.setEnd(textnode, searchHit.index + searchString_1.length);
                            var underline_span = $('<span>')
                                .addClass('search-hit')
                                .css('text-decoration', 'underline')[0];
                            range.surroundContents(underline_span);
                            element.parentElement.style.display = 'block'; // show
                        }
                    });
                }
                else {
                    $allCheckboxDivs.show();
                    $allHeaders.show();
                }
            },
        });
        switch (Twinkle.tag.modeEn) {
            case 'article':
                Window.setTitle(wgULS('条目维护标记', '條目維護標記'));
                // Build sorting and lookup object flatObject, which is always
                // needed but also used to generate the alphabetical list
                // Would be infinitely better with Object.values, but, alas, IE 11
                Twinkle.tag.article.flatObject = {};
                Twinkle.tag.article.tagList.forEach(function (group) {
                    group.value.forEach(function (subgroup) {
                        if (subgroup.value) {
                            subgroup.value.forEach(function (item) {
                                Twinkle.tag.article.flatObject[item.tag] = {
                                    description: item.description,
                                    excludeMI: !!item.excludeMI,
                                };
                            });
                        }
                        else {
                            Twinkle.tag.article.flatObject[subgroup.tag] = {
                                description: subgroup.description,
                                excludeMI: !!subgroup.excludeMI,
                            };
                        }
                    });
                });
                form.append({
                    type: 'select',
                    name: 'sortorder',
                    label: wgULS('查看列表:', '檢視列表:'),
                    tooltip: wgULS('您可以在Twinkle参数设置(H:TW/PREF)中更改此项。', '您可以在Twinkle偏好設定(H:TW/PREF)中更改此項。'),
                    event: Twinkle.tag.updateSortOrder,
                    list: [
                        {
                            type: 'option',
                            value: 'cat',
                            label: wgULS('按类型', '按類別'),
                            selected: Twinkle.getPref('tagArticleSortOrder') === 'cat',
                        },
                        {
                            type: 'option',
                            value: 'alpha',
                            label: '按字母',
                            selected: Twinkle.getPref('tagArticleSortOrder') === 'alpha',
                        },
                    ],
                });
                if (!Twinkle.tag.canRemove) {
                    var divElement = document.createElement('div');
                    divElement.innerHTML = wgULS('要移除现有维护标记,请从当前条目版本中打开“标记”菜单', '要移除現有維護標記,請從目前條目版本中打開「標記」選單');
                    form.append({
                        type: 'div',
                        name: 'untagnotice',
                        label: divElement,
                    });
                }
                form.append({
                    type: 'div',
                    id: 'tagWorkArea',
                    className: 'morebits-scrollbox',
                    style: 'max-height: 28em',
                });
                form.append({
                    type: 'checkbox',
                    list: [
                        {
                            label: wgULS('如可能,合并入{{multiple issues}}', '如可能,合併入{{multiple issues}}'),
                            value: 'group',
                            name: 'group',
                            tooltip: wgULS('若加入{{multiple issues}}支持的三个以上的模板,所有支持的模板都会被合并入{{multiple issues}}模板中。', '若加入{{multiple issues}}支援的三個以上的模板,所有支援的模板都會被合併入{{multiple issues}}模板中。'),
                            checked: Twinkle.getPref('groupByDefault'),
                        },
                    ],
                });
                form.append({
                    type: 'input',
                    label: '理由:',
                    name: 'reason',
                    tooltip: wgULS('附加于编辑摘要的可选理由,例如指出条目内容的哪些部分有问题或移除模板的理由,但若理由很长则应该发表在讨论页。', '附加於編輯摘要的可選理由,例如指出條目內容的哪些部分有問題或移除模板的理由,但若理由很長則應該發表在討論頁。'),
                    size: '80',
                });
                break;
            case 'file':
                Window.setTitle(wgULS('文件维护标记', '檔案維護標記'));
                Twinkle.tag.fileList.forEach(function (group) {
                    if (group.buildFilename) {
                        group.value.forEach(function (el) {
                            el.subgroup = {
                                type: 'input',
                                label: wgULS('替换的文件:', '替換的檔案:'),
                                tooltip: wgULS('输入替换此文件的文件名称(必填)', '輸入替換此檔案的檔案名稱(必填)'),
                                name: "".concat(el.value.replace(/ /g, '_'), "File"),
                            };
                        });
                    }
                    form.append({
                        type: 'header',
                        label: group.key,
                    });
                    form.append({
                        type: 'checkbox',
                        name: 'tags',
                        list: group.value,
                    });
                });
                if (Twinkle.getPref('customFileTagList').length) {
                    form.append({
                        type: 'header',
                        label: wgULS('自定义模板', '自訂模板'),
                    });
                    form.append({
                        type: 'checkbox',
                        name: 'tags',
                        list: Twinkle.getPref('customFileTagList'),
                    });
                }
                break;
            case 'redirect': {
                Window.setTitle(wgULS('重定向标记', '重新導向標記'));
                var i_1 = 1;
                Twinkle.tag.redirectList.forEach(function (group) {
                    form.append({
                        type: 'header',
                        id: "tagHeader".concat(i_1),
                        label: group.key,
                    });
                    form.append({
                        type: 'checkbox',
                        name: 'tags',
                        list: group.value.map(function (item) { return ({
                            value: item.tag,
                            label: "{{".concat(item.tag, "}}\uFF1A").concat(item.description),
                            subgroup: item.subgroup,
                        }); }),
                    });
                });
                if (Twinkle.getPref('customRedirectTagList').length) {
                    form.append({
                        type: 'header',
                        label: wgULS('自定义模板', '自訂模板'),
                    });
                    form.append({
                        type: 'checkbox',
                        name: 'tags',
                        list: Twinkle.getPref('customRedirectTagList'),
                    });
                }
                break;
            }
            default:
                mw.notify("Twinkle.tag\uFF1A\u672A\u77E5\u6A21\u5F0F ".concat(Twinkle.tag.mode), {
                    type: 'warn',
                    tag: 'friendlytag',
                });
                break;
        }
        if (document.getElementsByClassName('patrollink').length) {
            form.append({
                type: 'checkbox',
                list: [
                    {
                        label: wgULS('标记页面为已巡查', '標記頁面為已巡查'),
                        value: 'patrol',
                        name: 'patrol',
                        checked: Twinkle.getPref('markTaggedPagesAsPatrolled'),
                    },
                ],
            });
        }
        form.append({
            type: 'submit',
            className: 'tw-tag-submit',
        });
        var result = form.render();
        Window.setContent(result);
        Window.display();
        // for quick filter:
        $allCheckboxDivs = $(result).find('[name$=tags]').parent();
        $allHeaders = $(result).find('h5');
        result.quickfilter.focus(); // place cursor in the quick filter field as soon as window is opened
        result.quickfilter.autocomplete = 'off'; // disable browser suggestions
        result.quickfilter.addEventListener('keypress', function (e) {
            if (e.keyCode === 13) {
                // prevent enter key from accidentally submitting the form
                e.preventDefault();
                return false;
            }
        });
        if (Twinkle.tag.modeEn === 'article') {
            Twinkle.tag.alreadyPresentTags = [];
            if (Twinkle.tag.canRemove) {
                // Look for existing maintenance tags in the lead section and put them in array
                // All tags are HTML table elements that are direct children of .mw-parser-output,
                // except when they are within {{multiple issues}}
                $('.mw-parser-output')
                    .children()
                    .each(function (i, e) {
                    // break out on encountering the first heading, which means we are no
                    // longer in the lead section
                    if (e.tagName === 'H2') {
                        return false;
                    }
                    // The ability to remove tags depends on the template's {{ambox}} |name=
                    // parameter bearing the template's correct name (preferably) or a name that at
                    // least redirects to the actual name
                    // All tags have their first class name as "box-" + template name
                    if (e.className.indexOf('box-') === 0) {
                        if (e.classList[0] === 'box-问题条目') {
                            $(e)
                                .find('.ambox')
                                .each(function (idx, e) {
                                if (e.classList[0].indexOf('box-') === 0) {
                                    var tag_1 = e.classList[0].slice('box-'.length).replace(/_/g, ' ');
                                    Twinkle.tag.alreadyPresentTags.push(tag_1);
                                }
                            });
                            return true; // continue
                        }
                        var tag = e.classList[0].slice('box-'.length).replace(/_/g, ' ');
                        Twinkle.tag.alreadyPresentTags.push(tag);
                    }
                });
                // {{Uncategorized}} and {{Improve categories}} are usually placed at the end
                if ($('.box-Uncategorized').length) {
                    Twinkle.tag.alreadyPresentTags.push('Uncategorized');
                }
                if ($('.box-Improve_categories').length) {
                    Twinkle.tag.alreadyPresentTags.push('Improve categories');
                }
            }
            // Add status text node after Submit button
            var statusNode = document.createElement('span');
            statusNode.style.fontSize = '90%';
            statusNode.id = 'tw-tag-status';
            Twinkle.tag.status = {
                // initial state; defined like this because these need to be available for reference
                // in the click event handler
                numAdded: 0,
                numRemoved: 0,
            };
            $('button.tw-tag-submit').after(statusNode);
            // fake a change event on the sort dropdown, to initialize the tag list
            var evt = document.createEvent('Event');
            evt.initEvent('change', true, true);
            result.sortorder.dispatchEvent(evt);
        }
        else {
            // Redirects and files: Add a link to each template's description page
            Morebits.quickForm.getElements(result, 'tags').forEach(generateLinks);
        }
    };
    // $allCheckboxDivs and $allHeaders are defined globally, rather than in the
    // quickfilter event function, to avoid having to recompute them on every keydown
    var $allCheckboxDivs;
    var $allHeaders;
    Twinkle.tag.updateSortOrder = function (e) {
        var form = e.target.form;
        var sortorder = e.target.value;
        Twinkle.tag.checkedTags = form.getChecked('tags');
        var container = new Morebits.quickForm.element({
            type: 'fragment',
        });
        // function to generate a checkbox, with appropriate subgroup if needed
        var makeCheckbox = function (tag, description) {
            var checkbox = {
                value: tag,
                label: "{{".concat(tag, "}}: ").concat(description),
            };
            if (Twinkle.tag.checkedTags.includes(tag)) {
                checkbox.checked = true;
            }
            switch (tag) {
                case 'Merge':
                case 'Merge from':
                case 'Merge to': {
                    var otherTagName = 'Merge';
                    switch (tag) {
                        case 'Merge from':
                            otherTagName = 'Merge to';
                            break;
                        case 'Merge to':
                            otherTagName = 'Merge from';
                            break;
                        // no default
                    }
                    checkbox.subgroup = [
                        {
                            name: 'mergeTarget',
                            type: 'input',
                            label: wgULS('其他条目:', '其他條目:'),
                            tooltip: wgULS('如指定多个条目,请用管道符分隔:条目甲|条目乙', '如指定多個條目,請用管道符分隔:條目甲|條目乙'),
                        },
                        {
                            type: 'checkbox',
                            list: [
                                {
                                    name: 'mergeTagOther',
                                    label: "\u7528{{".concat(otherTagName).concat(wgULS('}}标记其他条目', '}}標記其他條目')),
                                    checked: true,
                                    tooltip: wgULS('仅在只输入了一个条目名时可用', '僅在只輸入了一個條目名時可用'),
                                },
                            ],
                        },
                    ];
                    if (mw.config.get('wgNamespaceNumber') === 0) {
                        checkbox.subgroup.push({
                            name: 'mergeReason',
                            type: 'textarea',
                            label: wgULS("\u5408\u5E76\u7406\u7531\uFF08\u4F1A\u88AB\u8D34\u4E0A".concat(tag === 'Merge to' ? '其他' : '这', "\u6761\u76EE\u7684\u8BA8\u8BBA\u9875\uFF09\uFF1A"), "\u5408\u4F75\u7406\u7531\uFF08\u6703\u88AB\u8CBC\u4E0A".concat(tag === 'Merge to' ? '其他' : '這', "\u689D\u76EE\u7684\u8A0E\u8AD6\u9801\uFF09\uFF1A")),
                            tooltip: wgULS('可选,但强烈推荐。如不需要请留空。仅在只输入了一个条目名时可用。', '可選,但強烈推薦。如不需要請留空。僅在只輸入了一個條目名時可用。'),
                        });
                    }
                    break;
                }
                case 'Missing information':
                    checkbox.subgroup = {
                        name: 'missingInformation',
                        type: 'input',
                        label: wgULS('缺少的内容(必填):', '缺少的內容(必填):'),
                        tooltip: wgULS('必填,显示为“缺少有关……的信息。”', '必填,顯示為「缺少有關……的資訊。」'),
                    };
                    break;
                case 'Requested move':
                    checkbox.subgroup = [
                        {
                            name: 'moveTarget',
                            type: 'input',
                            label: wgULS('新名称:', '新名稱:'),
                        },
                        {
                            name: 'moveReason',
                            type: 'textarea',
                            label: wgULS('移动理由(会被粘贴该条目的讨论页):', '移動理由(會被貼上該條目的討論頁):'),
                            tooltip: wgULS('可选,但强烈推荐。如不需要请留空。', '可選,但強烈推薦。如不需要請留空。'),
                        },
                    ];
                    break;
                case 'Split':
                    checkbox.subgroup = [
                        {
                            name: 'target1',
                            type: 'input',
                            label: wgULS('页面名1:', '頁面名1:'),
                            tooltip: wgULS('可选。', '可選。'),
                        },
                        {
                            name: 'target2',
                            type: 'input',
                            label: wgULS('页面名2:', '頁面名2:'),
                            tooltip: wgULS('可选。', '可選。'),
                        },
                        {
                            name: 'target3',
                            type: 'input',
                            label: wgULS('页面名3:', '頁面名3:'),
                            tooltip: wgULS('可选。', '可選。'),
                        },
                    ];
                    break;
                case 'Cleanup':
                    checkbox.subgroup = [
                        {
                            name: 'cleanupReason',
                            type: 'input',
                            label: '需要清理的理由',
                            tooltip: wgULS('可选,但强烈推荐。如不需要请留空。', '可選,但強烈推薦。如不需要請留空。'),
                        },
                    ];
                    break;
                default:
                    break;
            }
            return checkbox;
        };
        var makeCheckboxesForAlreadyPresentTags = function () {
            container.append({
                type: 'header',
                id: 'tagHeader0',
                label: wgULS('已放置的维护标记', '已放置的維護標記'),
            });
            var subdiv = container.append({
                type: 'div',
                id: 'tagSubdiv0',
            });
            var checkboxes = [];
            var unCheckedTags = e.target.form.getUnchecked('existingTags');
            Twinkle.tag.alreadyPresentTags.forEach(function (tag) {
                var checkbox = {
                    value: tag,
                    label: "{{".concat(tag, "}}").concat(Twinkle.tag.article.flatObject[tag]
                        ? ": ".concat(Twinkle.tag.article.flatObject[tag].description)
                        : ''),
                    checked: !unCheckedTags.includes(tag),
                };
                checkboxes.push(checkbox);
            });
            subdiv.append({
                type: 'checkbox',
                name: 'existingTags',
                list: checkboxes,
            });
        };
        if (sortorder === 'cat') {
            // categorical sort order
            // function to iterate through the tags and create a checkbox for each one
            var doCategoryCheckboxes_1 = function (subdiv, subgroup) {
                var checkboxes = [];
                $.each(subgroup, function (k, item) {
                    if (!Twinkle.tag.alreadyPresentTags.includes(item.tag)) {
                        checkboxes.push(makeCheckbox(item.tag, item.description));
                    }
                });
                subdiv.append({
                    type: 'checkbox',
                    name: 'tags',
                    list: checkboxes,
                });
            };
            if (Twinkle.tag.alreadyPresentTags.length > 0) {
                makeCheckboxesForAlreadyPresentTags();
            }
            var i_2 = 1;
            // go through each category and sub-category and append lists of checkboxes
            Twinkle.tag.article.tagList.forEach(function (group) {
                container.append({
                    type: 'header',
                    id: "tagHeader".concat(i_2),
                    label: group.key,
                });
                var subdiv = container.append({
                    type: 'div',
                    id: "tagSubdiv".concat(i_2++),
                });
                if (group.value[0].tag) {
                    doCategoryCheckboxes_1(subdiv, group.value);
                }
                else {
                    group.value.forEach(function (subgroup) {
                        subdiv.append({
                            type: 'div',
                            label: [Morebits.htmlNode('b', subgroup.key)],
                        });
                        doCategoryCheckboxes_1(subdiv, subgroup.value);
                    });
                }
            });
        }
        else {
            // alphabetical sort order
            if (Twinkle.tag.alreadyPresentTags.length > 0) {
                makeCheckboxesForAlreadyPresentTags();
                container.append({
                    type: 'header',
                    id: 'tagHeader1',
                    label: wgULS('可用的维护标记', '可用的維護標記'),
                });
            }
            // Avoid repeatedly resorting
            Twinkle.tag.article.alphabeticalList =
                Twinkle.tag.article.alphabeticalList || Object.keys(Twinkle.tag.article.flatObject).sort();
            var checkboxes_1 = [];
            Twinkle.tag.article.alphabeticalList.forEach(function (tag) {
                if (!Twinkle.tag.alreadyPresentTags.includes(tag)) {
                    checkboxes_1.push(makeCheckbox(tag, Twinkle.tag.article.flatObject[tag].description));
                }
            });
            container.append({
                type: 'checkbox',
                name: 'tags',
                list: checkboxes_1,
            });
        }
        // append any custom tags
        if (Twinkle.getPref('customTagList').length) {
            container.append({
                type: 'header',
                label: wgULS('自定义模板', '自訂模板'),
            });
            container.append({
                type: 'checkbox',
                name: 'tags',
                list: Twinkle.getPref('customTagList').map(function (el) {
                    el.checked = Twinkle.tag.checkedTags.includes(el.value);
                    return el;
                }),
            });
        }
        var $workarea = $(form).find('#tagWorkArea');
        var rendered = container.render();
        $workarea.empty().append(rendered);
        // for quick filter:
        $allCheckboxDivs = $workarea.find('[name=tags], [name=existingTags]').parent();
        $allHeaders = $workarea.find('h5, .quickformDescription');
        form.quickfilter.value = ''; // clear search, because the search results are not preserved over mode change
        form.quickfilter.focus();
        // 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',
        });
        Morebits.quickForm.getElements(form, 'existingTags').forEach(generateLinks);
        Morebits.quickForm.getElements(form, 'tags').forEach(generateLinks);
        // tally tags added/removed, update statusNode text
        var statusNode = document.getElementById('tw-tag-status');
        $('[name=tags], [name=existingTags]').on('click', function () {
            if (this.name === 'tags') {
                Twinkle.tag.status.numAdded += this.checked ? 1 : -1;
            }
            else if (this.name === 'existingTags') {
                Twinkle.tag.status.numRemoved += this.checked ? -1 : 1;
            }
            var firstPart = "\u52A0\u5165".concat(Twinkle.tag.status.numAdded).concat(wgULS('个标记', '個標記'));
            var secondPart = "\u79FB\u9664".concat(Twinkle.tag.status.numRemoved).concat(wgULS('个标记', '個標記'));
            statusNode.textContent =
                (Twinkle.tag.status.numAdded ? "  ".concat(firstPart) : '') +
                    (Twinkle.tag.status.numRemoved ? (Twinkle.tag.status.numAdded ? ';' : '  ') + secondPart : '');
        });
    };
    /**
     * Adds a link to each template's description page
     *
     * @param {Morebits.quickForm.element} checkbox  associated with the template
     */
    var generateLinks = function (checkbox) {
        var link = Morebits.htmlNode('a', '>');
        link.setAttribute('class', 'tag-template-link');
        var tagname = checkbox.values;
        link.setAttribute('href', mw.util.getUrl((!tagname.includes(':') ? 'Template:' : '') +
            (!tagname.includes('|') ? tagname : tagname.slice(0, tagname.indexOf('|')))));
        link.setAttribute('target', '_blank');
        $(checkbox).parent().append(['\u00A0', link]);
    };
    // Tags for ARTICLES start here
    Twinkle.tag.article = {};
    // Tags arranged by category; will be used to generate the alphabetical list,
    // but tags should be in alphabetical order within the categories
    // excludeMI: true indicate a tag that *does not* work inside {{multiple issues}}
    // Add new categories with discretion - the list is long enough as is!
    Twinkle.tag.article.tagList = [
        {
            key: wgULS('清理和维护模板', '清理和維護模板'),
            value: [
                {
                    key: wgULS('常规清理', '常規清理'),
                    value: [
                        {
                            tag: 'Cleanup',
                            description: wgULS('可能需要进行清理,以符合有兽档案馆的质量标准', '可能需要進行清理,以符合有獸檔案館的質量標準'),
                        },
                        {
                            tag: '需要整改',
                            description: wgULS('此条目不符合一般的格式要求,需要大规模整改', '此條目不符合一般的格式要求,需要大規模整改'),
                        },
                    ],
                },
                {
                    key: wgULS('可能多余的内容', '可能多餘的內容'),
                    value: [
                        {
                            tag: 'Copypaste',
                            description: wgULS('内容可能是从某个来源处拷贝后粘贴', '內容可能是從某個來源處拷貝後貼上'),
                        },
                        {
                            tag: 'External links',
                            description: wgULS('使用外部链接的方式可能不符合有兽档案馆的条例', '使用外部連結的方式可能不符合有獸檔案館的條例'),
                        },
                        {
                            tag: 'Non-free',
                            description: wgULS('可能过多或不当地使用了受著作权保护的文字、图像或多媒体文件', '可能過多或不當地使用了受版權保護的文字、圖像或多媒體檔案'),
                        },
                    ],
                },
                {
                    key: wgULS('结构和导言', '結構和導言'),
                    value: [
                        {
                            tag: 'Lead too long',
                            description: wgULS('导言部分也许过于冗长', '導言部分也許過於冗長'),
                        },
                        {
                            tag: '序言太短',
                            description: wgULS('此条目序言太短', '此條目序言太短'),
                        },
                        {
                            tag: '没有序言',
                            description: wgULS('此条目没有序言', '此條目沒有序言'),
                        },
                    ],
                },
            ],
        },
        {
            key: wgULS('常规条目问题', '常規條目問題'),
            value: [
                {
                    key: wgULS('写作风格', '寫作風格'),
                    value: [
                        {
                            tag: 'Advert',
                            description: wgULS('类似广告或宣传性内容', '類似廣告或宣傳性內容'),
                        },
                        {
                            tag: 'Inappropriate person',
                            description: wgULS('使用不适当的第一人称和第二人称', '使用不適當的第一人稱和第二人稱'),
                        },
                        {
                            tag: 'Tone',
                            description: wgULS('语调或风格可能不适合百科全书的写作方式', '語調或風格可能不適合百科全書的寫作方式'),
                        },
                        {
                            tag: 'Tone',
                            description: wgULS('语调或风格可能不适合百科全书的写作方式', '語調或風格可能不適合百科全書的寫作方式'),
                        },
                    ],
                },
                {
                    key: wgULS('信息和细节', '資訊和細節'),
                    value: [
                        {
                            tag: 'Expert needed',
                            description: wgULS('需要更了解本部分内容的编者参与及协助编辑', '需要更了解本部分內容的編者參與及協助編輯'),
                        },
                        {
                            tag: 'Trivia',
                            description: wgULS('应避免有陈列杂项、琐碎资料的部分', '應避免有陳列雜項、瑣碎資料的部分'),
                        },
                    ],
                },
                {
                    key: wgULS('时间性', '時間性'),
                    value: [
                        {
                            tag: 'Current',
                            description: wgULS('记述新闻动态', '記述新聞動態'),
                            excludeMI: true,
                        },
                        {
                            tag: 'Update',
                            description: wgULS('当前条目或章节需要更新', '當前條目或章節需要更新'),
                        },
                    ],
                },
                {
                    key: wgULS('中立、偏见和事实准确性', '中立、偏見和事實準確性'),
                    value: [
                        {
                            tag: 'Disputed',
                            description: wgULS('内容疑欠准确,有待查证', '內容疑欠準確,有待查證'),
                        },
                        {
                            tag: 'Hoax',
                            description: wgULS('真实性被质疑', '真實性被質疑'),
                        },
                        {
                            tag: 'POV',
                            description: wgULS('中立性有争议。内容、语调可能带有过度的个人观点', '中立性有爭議。內容、語調可能帶有過度的個人觀點'),
                        },
                        {
                            tag: 'Self-contradictory',
                            description: wgULS('内容自相矛盾', '內容自相矛盾'),
                        },
                        {
                            tag: 'Weasel',
                            description: wgULS('语义模棱两可而损及其中立性或准确性', '語意模棱兩可而損及其中立性或準確性'),
                        },
                    ],
                },
                {
                    key: wgULS('可供查证和来源', '可供查證和來源'),
                    value: [
                        {
                            tag: 'BLPdispute',
                            description: wgULS('可能违反了有兽档案馆关于生者传记的条例', '可能違反了有獸檔案館關於生者傳記的條例'),
                        },
                        {
                            tag: 'BLPsources',
                            description: wgULS('生者传记需要补充更多可供查证的来源', '生者傳記需要補充更多可供查證的來源'),
                        },
                        {
                            tag: 'BLP unsourced',
                            description: wgULS('生者传记没有列出任何参考或来源', '生者傳記沒有列出任何參考或來源'),
                        },
                        {
                            tag: 'Citecheck',
                            description: wgULS('可能包含不适用或被曲解的引用资料,部分内容的准确性无法被证实', '可能包含不適用或被曲解的引用資料,部分內容的準確性無法被證實'),
                        },
                        {
                            tag: 'More footnotes needed',
                            description: wgULS('因为文内引用不足,部分字句的来源仍然不明', '因為文內引用不足,部分字句的來源仍然不明'),
                        },
                        {
                            tag: 'No footnotes',
                            description: wgULS('因为没有内文引用而来源仍然不明', '因為沒有內文引用而來源仍然不明'),
                        },
                        {
                            tag: 'Original research',
                            description: wgULS('可能包含未查证内容', '可能包含未查證內容'),
                        },
                        {
                            tag: 'Refimprove',
                            description: wgULS('需要补充更多来源', '需要補充更多來源'),
                        },
                        {
                            tag: 'Unreferenced',
                            description: wgULS('没有列出任何参考或来源', '沒有列出任何參考或來源'),
                        },
                    ],
                },
            ],
        },
        {
            key: wgULS('具体内容问题', '具體內容問題'),
            value: [
                {
                    key: wgULS('语言', '語言'),
                    value: [
                        {
                            tag: 'NotMandarin',
                            description: wgULS('包含过多不是现代标准汉语的内容', '包含過多不是現代標準漢語的內容'),
                            excludeMI: true,
                        },
                    ],
                },
                {
                    key: wgULS('链接', '連結'),
                    value: [
                        {
                            tag: 'Dead end',
                            description: wgULS('需要加上内部链接以构筑百科全书的链接网络', '需要加上內部連結以構築百科全書的連結網絡'),
                        },
                        {
                            tag: '孤立页面',
                            description: wgULS('没有或只有很少链入页面', '沒有或只有很少連入頁面'),
                        },
                        {
                            tag: 'Overlinked',
                            description: wgULS('含有过多、重复、或不必要的内部链接', '含有過多、重複、或不必要的內部連結'),
                        },
                        {
                            tag: 'Underlinked',
                            description: wgULS('需要更多内部链接以构筑百科全书的链接网络', '需要更多內部連結以構築百科全書的連結網絡'),
                        },
                    ],
                },
                {
                    key: wgULS('参考技术', '參考技術'),
                    value: [
                        {
                            tag: 'Citation style',
                            description: wgULS('引用需要进行清理', '引用需要進行清理'),
                        },
                    ],
                },
                {
                    key: wgULS('分类', '分類'),
                    value: [
                        {
                            tag: 'Improve categories',
                            description: wgULS('需要更多页面分类', '需要更多頁面分類'),
                            excludeMI: true,
                        },
                        {
                            tag: 'Uncategorized',
                            description: wgULS('缺少页面分类', '缺少頁面分類'),
                            excludeMI: true,
                        },
                    ],
                },
            ],
        },
        {
            key: wgULS('合并、拆分、移动', '合併、拆分、移動'),
            value: [
                {
                    tag: 'Merge from',
                    description: wgULS('建议将页面并入此页面', '建議將頁面併入此頁面'),
                    excludeMI: true,
                },
                {
                    tag: 'Merge to',
                    description: wgULS('建议将此页面并入页面', '建議將此頁面併入頁面'),
                    excludeMI: true,
                },
                {
                    tag: 'Merge',
                    description: wgULS('建议此页面与页面合并', '建議此頁面與頁面合併'),
                    excludeMI: true,
                },
                {
                    tag: 'Requested move',
                    description: wgULS('建议将此页面移动到新名称', '建議將此頁面移動到新名稱'),
                    excludeMI: true,
                },
                {
                    tag: 'Split',
                    description: wgULS('建议将此页面分割为多个页面', '建議將此頁面分割為多個頁面'),
                    excludeMI: true,
                },
            ],
        },
    ];
    // Tags for REDIRECTS start here
    // Not by policy, but the list roughly approximates items with >500
    // transclusions from Template:R template index
    Twinkle.tag.redirectList = [
        {
            key: '常用模板',
            value: [
                {
                    tag: wgULS('合并重定向', '合併重定向'),
                    description: wgULS('保持页面题名至相应主条目,令页面内容在合并后仍能保存其编辑历史', '保持頁面題名至相應主條目,令頁面內容在合併後仍能儲存其編輯歷史'),
                },
                {
                    tag: wgULS('简繁重定向', '簡繁重定向'),
                    description: wgULS('引导简体至繁体,或繁体至简体', '引導簡體至繁體,或繁體至簡體'),
                },
                {
                    tag: '模板重定向',
                    description: wgULS('指向模板的重定向页面', '指向模板的重定向頁面'),
                },
                {
                    tag: wgULS('别名重定向', '別名重定向'),
                    description: wgULS('标题的其他名称、笔名、绰号、同义字等', '標題的其他名稱、筆名、綽號、同義字等'),
                },
                {
                    tag: wgULS('译名重定向', '譯名重定向'),
                    description: wgULS('人物、作品等各项事物的其他翻译名称', '人物、作品等各項事物的其他翻譯名稱'),
                },
                {
                    tag: wgULS('缩写重定向', '縮寫重定向'),
                    description: wgULS('标题缩写', '標題縮寫'),
                },
                {
                    tag: wgULS('拼写重定向', '拼寫重定向'),
                    description: wgULS('标题的其他不同拼写', '標題的其他不同拼寫'),
                },
                {
                    tag: wgULS('错字重定向', '錯字重定向'),
                    description: wgULS('纠正标题的常见错误拼写或误植', '糾正標題的常見錯誤拼寫或誤植'),
                },
                {
                    tag: wgULS('旧名重定向', '舊名重定向'),
                    description: wgULS('将事物早前的名称引导至更改后的主题', '將事物早前的名稱引導至更改後的主題'),
                },
                {
                    tag: '全名重定向',
                    description: wgULS('标题的完整或更完整名称', '標題的完整或更完整名稱'),
                },
                {
                    tag: '短名重定向',
                    description: wgULS('完整标题名称或人物全名的部分、不完整的名称或简称', '完整標題名稱或人物全名的部分、不完整的名稱或簡稱'),
                },
                {
                    tag: '姓氏重定向',
                    description: '人物姓氏',
                },
                {
                    tag: '名字重定向',
                    description: '人物人名',
                },
                {
                    tag: '本名重定向',
                    description: '人物本名',
                },
                {
                    tag: '非中文重定向',
                    description: wgULS('非中文标题', '非中文標題'),
                    subgroup: [
                        {
                            name: 'altLangFrom',
                            type: 'input',
                            label: '本重新導向的語言(可選)',
                            tooltip: '輸入重新導向名稱所使用語言的ISO 639代碼,例如en代表英語,代碼可參見 Template:ISO_639_name',
                        },
                    ],
                },
                {
                    tag: '日文重定向',
                    description: wgULS('日语名称', '日語名稱'),
                },
            ],
        },
        {
            key: '偶用模板',
            value: [
                {
                    tag: wgULS('章节重定向', '章節重定向'),
                    description: wgULS('导向至较高密度组织的页面', '導向至較高密度組織的頁面'),
                },
                {
                    tag: '列表重定向',
                    description: wgULS('导向至低密度的列表', '導向至低密度的列表'),
                },
                {
                    tag: '可能性重定向',
                    description: wgULS('导向至当前提供内容更为详尽的目标页面', '導向至當前提供內容更為詳盡的目標頁面'),
                },
                {
                    tag: wgULS('关联字重定向', '關聯字重定向'),
                    description: wgULS('标题名称关联字', '標題名稱關聯字'),
                },
                {
                    tag: wgULS('条目请求重定向', '條目請求重定向'),
                    description: wgULS('需要独立条目的页面', '需要獨立條目的頁面'),
                    subgroup: [
                        {
                            name: 'reqArticleLang',
                            type: 'input',
                            label: '外語語言代碼:',
                            tooltip: '使用ISO 639代碼,可參見 Template:ISO_639_name',
                        },
                        {
                            name: 'reqArticleTitle',
                            type: 'input',
                            label: '外語頁面名稱:',
                            size: 60,
                        },
                    ],
                },
                {
                    tag: wgULS('快捷方式重定向', '捷徑重定向'),
                    description: wgULS('有兽档案馆快捷方式', '有獸檔案館快捷方式'),
                },
            ],
        },
        {
            key: wgULS('鲜用模板', '鮮用模板'),
            value: [
                {
                    tag: wgULS('词组重定向', '詞組重定向'),
                    description: wgULS('将词组/词组/成语指向切题的条目及恰当章节', '將詞組/詞組/成語指向切題的條目及恰當章節'),
                },
                {
                    tag: wgULS('消歧义页重定向', '消歧義頁重定向'),
                    description: wgULS('指向消歧义页', '指向消歧義頁'),
                },
                {
                    tag: '域名重定向',
                    description: wgULS('域名', '網域名稱'),
                },
                {
                    tag: '年代重定向',
                    description: wgULS('于年份条目导向至年代条目', '於年份條目導向至年代條目'),
                },
                {
                    tag: wgULS('用户框模板重定向', '用戶框模板重定向'),
                    description: wgULS('用户框模板', '用戶框模板'),
                },
                {
                    tag: '重定向模板用重定向',
                    description: wgULS('导向至重定向模板', '導向至重定向模板'),
                },
                {
                    tag: 'EXIF重定向',
                    description: wgULS('JPEG图像文件包含EXIF信息', 'JPEG圖檔包含EXIF資訊'),
                },
            ],
        },
    ];
    // maintenance tags for FILES start here
    Twinkle.tag.fileList = [
        {
            key: wgULS('著作权和来源问题标签', '著作權和來源問題標籤'),
            value: [
                {
                    label: "{{Non-free reduce}}\uFF1A".concat(wgULS('非低分辨率的合理使用图像(或过长的音频剪辑等)', '非低解析度的合理使用圖像(或過長的音頻剪輯等)')),
                    value: 'Non-free reduce',
                },
            ],
        },
        {
            key: wgULS('清理标签', '清理標籤'),
            value: [
                {
                    label: "{{Watermark}}\uFF1A".concat(wgULS('图像包含了水印', '圖像包含了浮水印')),
                    value: 'Watermark',
                },
                {
                    label: "{{Rename media}}\uFF1A".concat(wgULS('文件应该根据文件名称指引被重命名', '檔案應該根據檔案名稱指引被重新命名')),
                    value: 'Rename media',
                    subgroup: [
                        {
                            type: 'input',
                            name: 'renamemediaNewname',
                            label: wgULS('新名称:', '新名稱:'),
                            tooltip: wgULS('输入图像的新名称(可选)', '輸入圖像的新名稱(可選)'),
                        },
                        {
                            type: 'input',
                            name: 'renamemediaReason',
                            label: '原因:',
                            tooltip: wgULS('输入重命名的原因(可选)', '輸入重新命名的原因(可選)'),
                        },
                    ],
                },
                {
                    label: "{{Should be SVG}}\uFF1A".concat(wgULS('PNG、GIF、JPEG文件应该重制成矢量图形', 'PNG、GIF、JPEG檔案應該重製成向量圖形')),
                    value: 'Should be SVG',
                },
            ],
        },
        {
            key: wgULS('文件取代标签', '檔案取代標籤'),
            value: [
                {
                    label: "{{Obsolete}}\uFF1A".concat(wgULS('有新版本可用的过时文件', '有新版本可用的過時檔案')),
                    value: 'Obsolete',
                },
                {
                    label: "{{Vector version available}}\uFF1A".concat(wgULS('有矢量图形可用的非矢量图形文件', '有向量圖形可用的非向量圖形檔案')),
                    value: 'Vector version available',
                },
            ],
            buildFilename: true,
        },
    ];
    Twinkle.tag.callbacks = {
        article: function (pageobj) {
            // Remove tags that become superfluous with this action
            var pageText = pageobj
                .getPageText()
                .replace(/\{\{\s*([Nn]ew unreviewed article|[Uu]nreviewed|[Uu]serspace draft)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/g, '');
            var params = pageobj.getCallbackParameters();
            /**
             * Saves the page following the removal of tags if any. The last step.
             * Called from removeTags()
             */
            var postRemoval = function () {
                if (params.tagsToRemove.length) {
                    // Remove empty {{multiple issues}} if found
                    pageText = pageText.replace(/\{\{(multiple ?issues|article ?issues|mi|ai|issues|多個問題|多个问题|問題條目|问题条目|數個問題|数个问题)\s*\|\s*\}\}\n?/im, '');
                    // Remove single-element {{multiple issues}} if found
                    pageText = pageText.replace(/\{\{(?:multiple ?issues|article ?issues|mi|ai|issues|多個問題|多个问题|問題條目|问题条目|數個問題|数个问题)\s*\|\s*(\{\{(?:\{\{[^{}]*\}\}|[^{}])+\}\})\s*\}\}/im, '$1');
                }
                // Build edit summary
                var makeSentence = function (array) {
                    if (array.length < 3) {
                        return array.join('和');
                    }
                    var last = array.pop();
                    return "".concat(array.join('、'), "\u548C").concat(last);
                };
                var makeTemplateLink = function (tag) {
                    var text = '{{[[';
                    // if it is a custom tag with a parameter
                    if (tag.includes('|')) {
                        tag = tag.slice(0, tag.indexOf('|'));
                    }
                    text += tag.includes(':') ? tag : "Template:".concat(tag, "|").concat(tag);
                    return "".concat(text, "]]}}");
                };
                var summaryText;
                var addedTags = params.tags.map(makeTemplateLink);
                var removedTags = params.tagsToRemove.map(makeTemplateLink);
                if (addedTags.length) {
                    summaryText = "\u52A0\u5165".concat(makeSentence(addedTags));
                    summaryText += removedTags.length ? "\u4E26\u79FB\u9664".concat(makeSentence(removedTags)) : '';
                }
                else {
                    summaryText = "\u79FB\u9664".concat(makeSentence(removedTags));
                }
                summaryText += wgULS('标记', '標記');
                if (params.reason) {
                    summaryText += "\uFF1A".concat(params.reason);
                }
                // avoid truncated summaries
                if (summaryText.length > 499) {
                    summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)\]\]/g, '$1');
                }
                pageobj.setPageText(pageText);
                pageobj.setEditSummary(summaryText);
                pageobj.setChangeTags(Twinkle.changeTags);
                pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
                pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
                pageobj.setCreateOption('nocreate');
                pageobj.save(function () {
                    // special functions for merge tags
                    if (params.mergeReason) {
                        // post the rationale on the talk page (only operates in main namespace)
                        var talkpage = new Morebits.wiki.page("Talk:".concat(params.discussArticle), wgULS('将理由贴进讨论页', '將理由貼進討論頁'));
                        talkpage.setNewSectionText("".concat(params.mergeReason.trim(), " ~~~~"));
                        talkpage.setNewSectionTitle("\u8BF7\u6C42\u4E0E[[".concat(params.nonDiscussArticle, "]]\u5408\u5E76"));
                        talkpage.setChangeTags(Twinkle.changeTags);
                        talkpage.setWatchlist(Twinkle.getPref('watchMergeDiscussions'));
                        talkpage.setCreateOption('recreate');
                        talkpage.newSection();
                    }
                    if (params.mergeTagOther) {
                        // tag the target page if requested
                        var otherTagName = 'Merge';
                        if (params.mergeTag === 'Merge from') {
                            otherTagName = 'Merge to';
                        }
                        else if (params.mergeTag === 'Merge to') {
                            otherTagName = 'Merge from';
                        }
                        var newParams = {
                            tags: [otherTagName],
                            tagsToRemove: [],
                            tagsToRemain: [],
                            mergeTarget: Morebits.pageNameNorm,
                            discussArticle: params.discussArticle,
                            talkDiscussionTitle: params.talkDiscussionTitle,
                            talkDiscussionTitleLinked: params.talkDiscussionTitleLinked,
                        };
                        var otherpage = new Morebits.wiki.page(params.mergeTarget, "".concat(wgULS('标记其他页面(', '標記其他頁面(') + params.mergeTarget, "\uFF09"));
                        otherpage.setCallbackParameters(newParams);
                        otherpage.load(Twinkle.tag.callbacks.article);
                    }
                    // special functions for requested move tags
                    if (params.moveReason) {
                        // post the rationale on the talk page (only operates in main namespace)
                        var moveTalkpageText = "\n\n{{subst:RM|1=".concat(params.moveReason.trim());
                        if (params.moveTarget) {
                            moveTalkpageText += "|2=".concat(params.moveTarget);
                        }
                        moveTalkpageText += '}}';
                        var moveTalkpage = new Morebits.wiki.page("Talk:".concat(params.discussArticle), wgULS('将理由贴进讨论页', '將理由貼進討論頁'));
                        moveTalkpage.setAppendText(moveTalkpageText);
                        moveTalkpage.setEditSummary(wgULS('请求移动', '請求移動') + (params.moveTarget ? "\u81F3[[".concat(params.moveTarget, "]]") : ''));
                        moveTalkpage.setChangeTags(Twinkle.changeTags);
                        moveTalkpage.setCreateOption('recreate');
                        moveTalkpage.append();
                    }
                });
                if (params.patrol) {
                    pageobj.patrol();
                }
            };
            /**
             * Removes the existing tags that were deselected (if any)
             * Calls postRemoval() when done
             */
            var removeTags = function () {
                if (params.tagsToRemove.length === 0) {
                    postRemoval();
                    return;
                }
                Morebits.status.info(wgULS('信息', '資訊'), wgULS('移除取消选择的已存在标记', '移除取消選擇的已存在標記'));
                var getRedirectsFor = [];
                // Remove the tags from the page text, if found in its proper name,
                // otherwise moves it to `getRedirectsFor` array earmarking it for
                // later removal
                params.tagsToRemove.forEach(function (tag) {
                    var tag_re = new RegExp("\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|[^}]+)?\\}\\}\\n?"));
                    if (tag_re.test(pageText)) {
                        pageText = pageText.replace(tag_re, '');
                    }
                    else {
                        getRedirectsFor.push("Template:".concat(tag));
                    }
                });
                if (!getRedirectsFor.length) {
                    postRemoval();
                    return;
                }
                // Remove tags which appear in page text as redirects
                var api = new Morebits.wiki.api(wgULS('获取模板重定向', '取得模板重新導向'), {
                    action: 'query',
                    prop: 'linkshere',
                    titles: getRedirectsFor.join('|'),
                    redirects: 1,
                    lhnamespace: '10',
                    lhshow: 'redirect',
                    lhlimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
                }, function (apiobj) {
                    $(apiobj.responseXML)
                        .find('page')
                        .each(function (idx, page) {
                        var removed = false;
                        $(page)
                            .find('lh')
                            .each(function (idx, el) {
                            var tag = $(el).attr('title').slice(9);
                            var tag_re = new RegExp("\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?\\}\\}\\n?"));
                            if (tag_re.test(pageText)) {
                                pageText = pageText.replace(tag_re, '');
                                removed = true;
                                return false; // break out of $.each
                            }
                        });
                        if (!removed) {
                            Morebits.status.warn(wgULS('信息', '資訊'), wgULS('无法在页面上找到{{', '無法在頁面上找到{{') +
                                $(page).attr('title').slice(9) +
                                wgULS('}}……跳过', '}}……跳過'));
                        }
                    });
                    postRemoval();
                });
                api.post();
            };
            if (!params.tags.length) {
                removeTags();
                return;
            }
            var tagRe;
            var tagText = '';
            var tags = [];
            var groupableTags = [];
            var groupableExistingTags = [];
            // Executes first: addition of selected tags
            /**
             * Updates `tagText` with the syntax of `tagName` template with its parameters
             *
             * @param {number} tagIndex
             * @param {string} tagName
             */
            var addTag = function (tagIndex, tagName) {
                var currentTag = '';
                if (tagName === 'Uncategorized' || tagName === 'Improve categories') {
                    pageText += "\n\n{{".concat(tagName, "|time={{subst:#time:c}}}}");
                }
                else {
                    currentTag += "{{".concat(tagName);
                    // fill in other parameters, based on the tag
                    switch (tagName) {
                        case 'Expert needed':
                            currentTag += "|subject=".concat(params.expert);
                            if (params.expert2) {
                                currentTag += "|subject2=".concat(params.expert2);
                            }
                            if (params.expert3) {
                                currentTag += "|subject3=".concat(params.expert3);
                            }
                            break;
                        case 'Merge':
                        case 'Merge to':
                        case 'Merge from':
                            if (params.mergeTarget) {
                                // normalize the merge target for now and later
                                params.mergeTarget = Morebits.string.toUpperCaseFirstChar(params.mergeTarget.replace(/_/g, ' '));
                                currentTag += "|".concat(params.mergeTarget);
                                // link to the correct section on the talk page, for article space only
                                if (mw.config.get('wgNamespaceNumber') === 0 &&
                                    (params.mergeReason || params.discussArticle)) {
                                    if (!params.discussArticle) {
                                        // discussArticle is the article whose talk page will contain the discussion
                                        params.discussArticle =
                                            tagName === 'Merge to' ? params.mergeTarget : mw.config.get('wgTitle');
                                        // nonDiscussArticle is the article which won't have the discussion
                                        params.nonDiscussArticle =
                                            tagName === 'Merge to' ? mw.config.get('wgTitle') : params.mergeTarget;
                                        params.talkDiscussionTitle =
                                            wgULS('请求与', '請求與') +
                                                params.nonDiscussArticle +
                                                wgULS('合并', '合併');
                                    }
                                    currentTag += "|discuss=Talk:".concat(params.discussArticle, "#").concat(params.talkDiscussionTitle);
                                }
                            }
                            break;
                        case 'Missing information':
                            currentTag += "|1=".concat(params.missingInformation);
                            break;
                        case 'Requested move':
                            if (params.moveTarget) {
                                // normalize the move target for now and later
                                params.moveTarget = Morebits.string.toUpperCaseFirstChar(params.moveTarget.replace(/_/g, ' '));
                                params.discussArticle = mw.config.get('wgTitle');
                                currentTag += "|".concat(params.moveTarget);
                            }
                            break;
                        case 'Split':
                            if (params.target1) {
                                currentTag += "|1=".concat(params.target1);
                            }
                            if (params.target2) {
                                currentTag += "|2=".concat(params.target2);
                            }
                            if (params.target3) {
                                currentTag += "|3=".concat(params.target3);
                            }
                            break;
                        case 'Cleanup':
                            if (params.cleanupReason) {
                                currentTag += "|reason=".concat(params.cleanupReason);
                            }
                            break;
                        default:
                            break;
                    }
                    currentTag += '|time={{subst:#time:c}}}}\n';
                    tagText += currentTag;
                }
            };
            /**
             * Adds the tags which go outside {{multiple issues}}, either because
             * these tags aren't supported in {{multiple issues}} or because
             * {{multiple issues}} is not being added to the page at all
             */
            var addUngroupedTags = function () {
                $.each(tags, addTag);
                // Insert tag after short description or any hatnotes,
                // as well as deletion/protection-related templates
                var ysarxiv_page = new Morebits.wikitext.page(pageText);
                var templatesAfter = 
                // Protection templates
                // CSD
                // AfD
                "".concat(Twinkle.hatnoteRegex, "pp|pp-.*?|(?:Delete|Db-reason|D|Deletebecause|Db|\u901F\u5220|\u901F\u522A|Speedy|SD|\u5FEB\u5220|\u5FEB\u522A|CSD)|[rsaiftcmv]fd|vfd-(?:b|q|s|source|v|wikt)|(?:\u79FB\u52A8\u5230\u7EF4\u57FA|\u79FB\u52D5\u5230\u7DAD\u57FA)(?:\u6559\u79D1\u4E66|\u6559\u79D1\u66F8|\u8BED\u5F55|\u8A9E\u9304|\u6587\u5E93|\u6587\u5EAB|\u5BFC\u6E38|\u5C0E\u904A|\u8BCD\u5178|\u8A5E\u5178)");
                pageText = ysarxiv_page.insertAfterTemplates(tagText, templatesAfter).getText();
                removeTags();
            };
            // Separate tags into groupable ones (`groupableTags`) and non-groupable ones (`tags`)
            params.tags.forEach(function (tag) {
                tagRe = new RegExp("\\{\\{".concat(tag, "(\\||\\}\\})"), 'im');
                // regex check for preexistence of tag can be skipped if in canRemove mode
                if (Twinkle.tag.canRemove || !tagRe.exec(pageText)) {
                    // condition Twinkle.tag.article.tags[tag] to ensure that its not a custom tag
                    // Custom tags are assumed non-groupable, since we don't know whether MI template supports them
                    if (Twinkle.tag.article.flatObject[tag] && !Twinkle.tag.article.flatObject[tag].excludeMI) {
                        groupableTags.push(tag);
                    }
                    else {
                        tags.push(tag);
                    }
                }
                else {
                    if (tag === 'Merge from') {
                        tags.push(tag);
                    }
                    else {
                        Morebits.status.warn(wgULS('信息', '資訊'), wgULS('在页面上找到{{', '在頁面上找到{{') + tag + wgULS('}}……跳过', '}}……跳過'));
                        // don't do anything else with merge tags
                        if (['Merge', 'Merge to'].includes(tag)) {
                            params.mergeTarget = params.mergeReason = params.mergeTagOther = null;
                        }
                    }
                }
            });
            // To-be-retained existing tags that are groupable
            params.tagsToRemain.forEach(function (tag) {
                // If the tag is unknown to us, we consider it non-groupable
                if (Twinkle.tag.article.flatObject[tag] && !Twinkle.tag.article.flatObject[tag].excludeMI) {
                    groupableExistingTags.push(tag);
                }
            });
            var miTest = /\{\{(multiple ?issues|article ?issues|mi|ai|issues|多個問題|多个问题|問題條目|问题条目|數個問題|数个问题)\s*\|[^}]+\{/im.exec(pageText);
            if (miTest && groupableTags.length > 0) {
                Morebits.status.info(wgULS('信息', '資訊'), wgULS('加入支持的标记入已存在的{{multiple issues}}', '加入支援的標記入已存在的{{multiple issues}}'));
                tagText = '';
                $.each(groupableTags, addTag);
                var miRegex = new RegExp("(\\{\\{\\s*".concat(miTest[1], "\\s*(?:\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?)\\}\\}\\s*"), 'im');
                pageText = pageText.replace(miRegex, "$1".concat(tagText, "}}\n"));
                tagText = '';
                addUngroupedTags();
            }
            else if (params.group && !miTest && groupableExistingTags.length + groupableTags.length >= 2) {
                Morebits.status.info(wgULS('信息', '資訊'), wgULS('加入支持的标记入{{multiple issues}}', '加入支援的標記入{{multiple issues}}'));
                tagText += '{{Multiple issues|\n';
                /**
                 * Adds newly added tags to MI
                 */
                var addNewTagsToMI_1 = function () {
                    $.each(groupableTags, addTag);
                    tagText += '}}\n';
                    addUngroupedTags();
                };
                var getRedirectsFor_1 = [];
                // Reposition the tags on the page into {{multiple issues}}, if found with its
                // proper name, else moves it to `getRedirectsFor` array to be handled later
                groupableExistingTags.forEach(function (tag) {
                    var tag_re = new RegExp("(\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|[^}]+)?\\}\\}\\n?)"));
                    if (tag_re.test(pageText)) {
                        tagText += tag_re.exec(pageText)[1];
                        pageText = pageText.replace(tag_re, '');
                    }
                    else {
                        getRedirectsFor_1.push("Template:".concat(tag));
                    }
                });
                if (!getRedirectsFor_1.length) {
                    addNewTagsToMI_1();
                    return;
                }
                var api = new Morebits.wiki.api(wgULS('获取模板重定向', '取得模板重新導向'), {
                    action: 'query',
                    prop: 'linkshere',
                    titles: getRedirectsFor_1.join('|'),
                    redirects: 1,
                    lhnamespace: '10',
                    lhshow: 'redirect',
                    lhlimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
                }, function (apiobj) {
                    $(apiobj.responseXML)
                        .find('page')
                        .each(function (idx, page) {
                        var found = false;
                        $(page)
                            .find('lh')
                            .each(function (idx, el) {
                            var tag = $(el).attr('title').slice(9);
                            var tag_re = new RegExp("(\\{\\{".concat(Morebits.pageNameRegex(tag), "\\s*(\\|[^}]*)?\\}\\}\\n?)"));
                            if (tag_re.test(pageText)) {
                                tagText += tag_re.exec(pageText)[1];
                                pageText = pageText.replace(tag_re, '');
                                found = true;
                                return false; // break out of $.each
                            }
                        });
                        if (!found) {
                            Morebits.status.warn(wgULS('信息', '資訊'), wgULS('无法在页面上找到{{', '無法在頁面上找到{{') +
                                $(page).attr('title').slice(9) +
                                wgULS('}}……跳过', '}}……跳過'));
                        }
                    });
                    addNewTagsToMI_1();
                });
                api.post();
            }
            else {
                tags = tags.concat(groupableTags);
                addUngroupedTags();
            }
        },
        redirect: function (pageobj) {
            var params = pageobj.getCallbackParameters();
            var pageText = pageobj.getPageText();
            var tagRe;
            var tagText = '';
            var summaryText = '加入';
            var tags = [];
            var i;
            for (i = 0; i < params.tags.length; i++) {
                tagRe = new RegExp("(\\{\\{".concat(params.tags[i], "(\\||\\}\\}))"), 'im');
                if (!tagRe.exec(pageText)) {
                    tags.push(params.tags[i]);
                }
                else {
                    Morebits.status.warn(wgULS('信息', '資訊'), wgULS('在重定向上找到{{', '在重新導向上找到{{') + params.tags[i] + wgULS('}}……跳过', '}}……跳過'));
                }
            }
            var addTag = function (tagIndex, tagName) {
                tagText += "\n{{".concat(tagName);
                if (tagName === '非中文重定向') {
                    if (params.altLangFrom) {
                        tagText += "|1=".concat(params.altLangFrom);
                    }
                }
                else if (tagName === '条目请求重定向' || tagName === '條目請求重定向') {
                    if (params.reqArticleLang && params.reqArticleTitle) {
                        tagText += "|1=".concat(params.reqArticleLang);
                        tagText += "|2=".concat(params.reqArticleTitle);
                    }
                }
                tagText += '}}';
                if (tagIndex > 0) {
                    if (tagIndex === tags.length - 1) {
                        summaryText += '和';
                    }
                    else if (tagIndex < tags.length - 1) {
                        summaryText += '、';
                    }
                }
                summaryText += "{{[[:".concat(tagName.includes(':') ? tagName : "Template:".concat(tagName, "|").concat(tagName), "]]}}");
            };
            if (!tags.length) {
                Morebits.status.warn(wgULS('信息', '資訊'), wgULS('没有标签可供标记', '沒有標籤可供標記'));
            }
            tags.sort();
            $.each(tags, addTag);
            // Check for all Rcat shell redirects (from #433)
            if (pageText.match(/{{(?:redr|this is a redirect|r(?:edirect)?(?:.?cat.*)?[ _]?sh)/i)) {
                // Regex inspired by [[User:Kephir/gadgets/sagittarius.js]] ([[Special:PermaLink/831402893]])
                var oldTags = pageText.match(/(\s*{{[A-Za-z\s]+\|(?:\s*1=)?)((?:[^|{}]|{{[^}]+}})+)(}})\s*/i);
                pageText = pageText.replace(oldTags[0], oldTags[1] + tagText + oldTags[2] + oldTags[3]);
            }
            else {
                // Fold any pre-existing Rcats into taglist and under Rcatshell
                var pageTags = pageText.match(/\s*{{.+?重定向.*?}}/gim);
                var oldPageTags_1 = '';
                if (pageTags) {
                    pageTags.forEach(function (pageTag) {
                        var pageRe = new RegExp(Morebits.string.escapeRegExp(pageTag), 'img');
                        pageText = pageText.replace(pageRe, '');
                        pageTag = pageTag.trim();
                        oldPageTags_1 += "\n".concat(pageTag);
                    });
                }
                pageText += "\n{{Redirect category shell|".concat(tagText).concat(oldPageTags_1, "\n}}");
            }
            summaryText +=
                (tags.length > 0 ? wgULS('标记', '標記') : '{{Redirect category shell}}') +
                    wgULS('到重定向', '到重新導向');
            // avoid truncated summaries
            if (summaryText.length > 499) {
                summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)\]\]/g, '$1');
            }
            pageobj.setPageText(pageText);
            pageobj.setEditSummary(summaryText);
            pageobj.setChangeTags(Twinkle.changeTags);
            pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
            pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
            pageobj.setCreateOption('nocreate');
            pageobj.save();
            if (params.patrol) {
                pageobj.patrol();
            }
        },
        file: function (pageobj) {
            var text = pageobj.getPageText();
            var params = pageobj.getCallbackParameters();
            var summary = '加入';
            // Add maintenance tags
            if (params.tags.length) {
                var tagtext_1 = '';
                var currentTag_1;
                $.each(params.tags, function (k, tag) {
                    // when other commons-related tags are placed, remove "move to Share" tag
                    if (['Keep local', 'Now Ysarxiv Share', 'Do not move to Ysarxiv Share'].includes(tag)) {
                        text = text.replace(/{{(mtc|(copy |move )?to ?share|move to ysarxiv share|copy to ysarxiv share)[^}]*}}/gi, '');
                    }
                    if (tag === 'Vector version available') {
                        text = text.replace(/\{\{((convert to |convertto|should be |shouldbe|to)?svg|badpng|vectorize)[^}]*\}\}/gi, '');
                    }
                    currentTag_1 = tag;
                    switch (tag) {
                        case 'Now Commons':
                            currentTag_1 = "subst:".concat(currentTag_1); // subst
                            if (params.nowcommonsName !== '') {
                                currentTag_1 += "|1=".concat(params.nowcommonsName);
                            }
                            break;
                        case 'Keep local':
                            if (params.keeplocalName !== '') {
                                currentTag_1 += "|1=".concat(params.keeplocalName);
                            }
                            if (params.keeplocalReason !== '') {
                                currentTag_1 += "|reason=".concat(params.keeplocalReason);
                            }
                            break;
                        case 'Rename media':
                            if (params.renamemediaNewname !== '') {
                                currentTag_1 += "|1=".concat(params.renamemediaNewname);
                            }
                            if (params.renamemediaReason !== '') {
                                currentTag_1 += "|2=".concat(params.renamemediaReason);
                            }
                            break;
                        case 'Vector version available':
                        /* falls through */
                        case 'Obsolete':
                            currentTag_1 += "|1=".concat(params["".concat(tag.replace(/ /g, '_'), "File")]);
                            break;
                        case 'Do not move to Commons':
                            currentTag_1 += "|reason=".concat(params.DoNotMoveToCommons_reason);
                            break;
                        case 'Copy to Wikimedia Commons':
                            currentTag_1 += "|human=".concat(mw.config.get('wgUserName'));
                            break;
                        default:
                            break;
                        // don't care
                    }
                    currentTag_1 = "{{".concat(currentTag_1, "}}\n");
                    tagtext_1 += currentTag_1;
                    summary += "{{".concat(tag, "}}\u3001");
                });
                if (!tagtext_1) {
                    pageobj
                        .getStatusElement()
                        .warn(wgULS('用户取消操作,没什么要做的', '使用者取消操作,沒什麼要做的'));
                    return;
                }
                text = tagtext_1 + text;
            }
            pageobj.setPageText(text);
            pageobj.setEditSummary(summary.substring(0, summary.length - 1));
            pageobj.setChangeTags(Twinkle.changeTags);
            pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
            pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
            pageobj.setCreateOption('nocreate');
            pageobj.save();
            if (params.patrol) {
                pageobj.patrol();
            }
        },
    };
    Twinkle.tag.callback.evaluate = function (e) {
        var form = e.target;
        var params = Morebits.quickForm.getInputData(form);
        // Validation
        // Given an array of incompatible tags, check if we have two or more selected
        var checkIncompatible = function (conflicts, extra) {
            var count = conflicts.reduce(function (sum, tag) { return (sum += params.tags.includes(tag)); }, 0);
            if (count > 1) {
                var message = "".concat(wgULS('请在以下标签中择一使用', '請在以下標籤中擇一使用'), "\uFF1A{{").concat(conflicts.join('}}、{{'), "}}\u3002");
                message += extra || '';
                mw.notify(message, {
                    type: 'warn',
                    tag: 'friendlytag',
                });
                return true;
            }
        };
        // Given a tag, ensure an associate parameter is present
        // Maybe just sock this away in each function???
        var checkParameter = function (tag, parameter, description) {
            if (description === void 0) { description = '理由'; }
            if (params.tags.includes(tag) && params[parameter].trim() === '') {
                mw.notify("".concat(wgULS('您必须指定', '您必須指定'), "{{").concat(tag, "}}\u7684").concat(description, "\u3002"), {
                    type: 'warn',
                    tag: 'friendlytag',
                });
                return true;
            }
        };
        // We could theoretically put them all checkIncompatible calls in a
        // forEach loop, but it's probably clearer not to have [[array one],
        // [array two]] devoid of context. Likewise, all the checkParameter
        // calls could be in one if, but could be similarly confusing.
        switch (Twinkle.tag.modeEn) {
            case 'article':
                params.tagsToRemove = form.getUnchecked('existingTags'); // not in `input`
                params.tagsToRemain = params.existingTags || []; // container not created if none present
                if (params.tags.includes('Merge') ||
                    params.tags.includes('Merge from') ||
                    params.tags.includes('Merge to')) {
                    if (checkIncompatible(['Merge', 'Merge from', 'Merge to'], wgULS('若需要多次合并,请使用{{Merge}}并用管道符分隔条目名(但在这种情形中Twinkle不能自动标记其他条目)。', '若需要多次合併,請使用{{Merge}}並用管道符分隔條目名(但在這種情形中Twinkle不能自動標記其他條目)。'))) {
                        return;
                    }
                    if (!params.mergeTarget) {
                        mw.notify(wgULS('请指定使用于merge模板中的另一个页面标题。', '請指定使用於merge模板中的另一個頁面標題。'), {
                            type: 'warn',
                            tag: 'friendlytag',
                        });
                        return;
                    }
                    if ((params.mergeTagOther || params.mergeReason) && params.mergeTarget.includes('|')) {
                        mw.notify(wgULS('当前还不支持在一次合并中标记多个条目,与开启关于多个条目的讨论。请不要勾选“标记其他条目”并清空“理由”框后再提交。', '目前還不支援在一次合併中標記多個條目,與開啟關於多個條目的討論。請不要勾選「標記其他條目」並清空「理由」框後再提交。'), {
                            type: 'warn',
                            tag: 'friendlytag',
                        });
                        return;
                    }
                }
                if (checkParameter('Missing information', 'missingInformation', wgULS('缺少的内容', '缺少的內容'))) {
                    return;
                }
                if (checkParameter('Expert needed', 'expert', wgULS('专家领域', '專家領域'))) {
                    return;
                }
                break;
            case 'file':
                // Silly to provide the same string to each of these
                if (checkParameter('Obsolete', 'ObsoleteFile', wgULS('替换的文件名称', '替換的檔案名稱')) ||
                    checkParameter('Vector version available', 'Vector_version_availableFile', wgULS('替换的文件名称', '替換的檔案名稱'))) {
                    return;
                }
                if (checkParameter('Do not move to Commons', 'DoNotMoveToCommons_reason')) {
                    return;
                }
                break;
            case 'redirect':
                break;
            default:
                mw.notify("Twinkle.tag\uFF1A\u672A\u77E5\u6A21\u5F0F ".concat(Twinkle.tag.mode), {
                    type: 'warn',
                    tag: 'friendlytag',
                });
                break;
        }
        // File/redirect: return if no tags selected
        // Article: return if no tag is selected and no already present tag is deselected
        if (params.tags.length === 0 && (Twinkle.tag.modeEn !== 'article' || params.tagsToRemove.length === 0)) {
            mw.notify(wgULS('必须选择至少一个标记!', '必須選擇至少一個標記!'), {
                type: 'warn',
                tag: 'friendlytag',
            });
            return;
        }
        Morebits.simpleWindow.setButtonsEnabled(false);
        Morebits.status.init(form);
        Morebits.wiki.actionCompleted.redirect = Morebits.pageNameNorm;
        Morebits.wiki.actionCompleted.notice = wgULS('标记完成,将在几秒内刷新页面', '標記完成,將在幾秒內重新整理頁面');
        if (Twinkle.tag.modeEn === 'redirect') {
            Morebits.wiki.actionCompleted.followRedirect = false;
        }
        var ysarxiv_page = new Morebits.wiki.page(Morebits.pageNameNorm, wgULS('正在标记', '正在標記') + Twinkle.tag.mode);
        ysarxiv_page.setCallbackParameters(params);
        ysarxiv_page.load(Twinkle.tag.callbacks[Twinkle.tag.modeEn]);
    };
    Twinkle.addInitCallback(Twinkle.tag, 'tag');
})(jQuery);

/* </nowiki> */