檢視 MediaWiki:Gadget-friendlytag.js 的原始碼
←
MediaWiki:Gadget-friendlytag.js
跳至導覽
跳至搜尋
由於以下原因,您無權編輯此頁面:
本頁用來提供此 Wiki 軟體介面上的文字,並且已被設為保護以防止惡意修改。 如欲增加或修改 Wiki 的翻譯,請至
translatewiki.net
上的 MediaWiki 在地化專案。
您沒有權限來編輯此 JavaScript 頁面,因為這會影響到所有的網站訪客。
您可以檢視並複製此頁面的原始碼。
//<nowiki> // vim: set noet sts=0 sw=8: (function($){ /* **************************************** *** friendlytag.js: Tag module **************************************** * Mode of invocation: Tab ("Tag") * Active on: Existing articles; * all redirects * Config directives in: FriendlyConfig */ Twinkle.tag = function friendlytag() { // redirect tagging if( Morebits.wiki.isPageRedirect() ) { Twinkle.tag.mode = '重定向'; Twinkle.addPortletLink( Twinkle.tag.callback, "標記", "friendly-tag", "標記重定向" ); } // article/draft tagging else if( ( ( mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 118 ) && mw.config.get('wgCurRevisionId') ) || ( Morebits.pageNameNorm === 'Wikipedia:沙盒' ) ) { Twinkle.tag.mode = '條目'; Twinkle.addPortletLink( Twinkle.tag.callback, "標記", "friendly-tag", "標記條目" ); } }; Twinkle.tag.callback = function friendlytagCallback( uid ) { var Window = new Morebits.simpleWindow( 630, (Twinkle.tag.mode === "條目") ? 500 : 400 ); Window.setScriptName( "Twinkle" ); // anyone got a good policy/guideline/info page/instructional page link?? Window.addFooterLink( "Twinkle幫助", "WP:TW/DOC#tag" ); var form = new Morebits.quickForm( Twinkle.tag.callback.evaluate ); if (document.getElementsByClassName("patrollink").length) { form.append( { type: 'checkbox', list: [ { label: '標記頁面爲已巡查', value: 'patrolPage', name: 'patrolPage', checked: Twinkle.getFriendlyPref('markTaggedPagesAsPatrolled') } ] } ); } switch( Twinkle.tag.mode ) { case '條目': Window.setTitle( "條目維護標記" ); form.append({ type: 'select', name: 'sortorder', label: '察看列表:', tooltip: '您可以在Twinkle參數設置(WP:TWPREFS)中更改此項。', event: Twinkle.tag.updateSortOrder, list: [ { type: 'option', value: 'cat', label: '按類別', selected: Twinkle.getFriendlyPref('tagArticleSortOrder') === 'cat' }, { type: 'option', value: 'alpha', label: '按字母', selected: Twinkle.getFriendlyPref('tagArticleSortOrder') === 'alpha' } ] }); form.append({ type: 'div', id: 'tagWorkArea', className: 'morebits-scrollbox', style: 'max-height: 28em' }); form.append( { type: 'checkbox', list: [ { label: '如可能,合併入{{multiple issues}}', value: 'group', name: 'group', tooltip: '如果添加{{multiple issues}}支持的三個以上的模板,所有支持的模板都會被合併入{{multiple issues}}模板中。', checked: Twinkle.getFriendlyPref('groupByDefault') } ] } ); break; case '重定向': Window.setTitle( "重定向標記" ); form.append({ type: 'header', label:'常用模板' }); form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.tag.frequentList }); form.append({ type: 'header', label:'偶用模板' }); form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.tag.lessFrequentList }); form.append({ type: 'header', label:'鮮用模板' }); form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.tag.rareList }); break; default: alert("Twinkle.tag:未知模式 " + Twinkle.tag.mode); break; } form.append( { type:'submit' } ); var result = form.render(); Window.setContent( result ); Window.display(); if (Twinkle.tag.mode === "條目") { // 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); } }; Twinkle.tag.checkedTags = []; Twinkle.tag.updateSortOrder = function(e) { var sortorder = e.target.value; Twinkle.tag.checkedTags = e.target.form.getChecked("articleTags"); if (!Twinkle.tag.checkedTags) { Twinkle.tag.checkedTags = []; } 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: "{{" + tag + "}}: " + description }; if (Twinkle.tag.checkedTags.indexOf(tag) !== -1) { 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; } checkbox.subgroup = [ { name: 'mergeTarget', type: 'input', label: '其他條目:', tooltip: '如指定多個條目,請用管道符分隔:條目甲|條目乙' }, { name: 'mergeTagOther', type: 'checkbox', list: [ { label: '用{{' + otherTagName + '}}標記其他條目', checked: true, tooltip: '僅在只輸入了一個條目名時可用' } ] } ]; if (mw.config.get('wgNamespaceNumber') === 0) { checkbox.subgroup.push({ name: 'mergeReason', type: 'textarea', label: '合併理由(會被貼上' + (tag === "merge to" ? '其他' : '這') + '條目的討論頁):', tooltip: '可選,但強烈推薦。如不需要請留空。僅在只輸入了一個條目名時可用。' }); } break; case "notability": checkbox.subgroup = { name: 'notability', type: 'select', list: [ { label: "{{notability}}:通用的關注度指引", value: "none" }, { label: "{{notability|Biographies}}:人物傳記", value: "Biographies" }, { label: "{{notability|Book}}:書籍", value: "Book" }, { label: "{{notability|Number}}:數字", value: "Number" }, { label: "{{notability|Fiction}}:虛構事物", value: "Fiction" }, { label: "{{notability|Neologisms}}:發明、研究", value: "Neologisms" }, { label: "{{notability|Web}}:網站、網絡內容", value: "Web"} ] }; break; default: break; } return checkbox; }; // categorical sort order if (sortorder === "cat") { // function to iterate through the tags and create a checkbox for each one var doCategoryCheckboxes = function(subdiv, array) { var checkboxes = []; $.each(array, function(k, tag) { var description = Twinkle.tag.article.tags[tag]; checkboxes.push(makeCheckbox(tag, description)); }); subdiv.append({ type: "checkbox", name: "articleTags", list: checkboxes }); }; var i = 0; // go through each category and sub-category and append lists of checkboxes $.each(Twinkle.tag.article.tagCategories, function(title, content) { container.append({ type: "header", id: "tagHeader" + i, label: title }); var subdiv = container.append({ type: "div", id: "tagSubdiv" + i++ }); if ($.isArray(content)) { doCategoryCheckboxes(subdiv, content); } else { $.each(content, function(subtitle, subcontent) { subdiv.append({ type: "div", label: [ Morebits.htmlNode("b", subtitle) ] }); doCategoryCheckboxes(subdiv, subcontent); }); } }); } // alphabetical sort order else { var checkboxes = []; $.each(Twinkle.tag.article.tags, function(tag, description) { checkboxes.push(makeCheckbox(tag, description)); }); container.append({ type: "checkbox", name: "articleTags", list: checkboxes }); } // append any custom tags if (Twinkle.getFriendlyPref('customTagList').length) { container.append({ type: 'header', label: '自定義模板' }); container.append({ type: 'checkbox', name: 'articleTags', list: Twinkle.getFriendlyPref('customTagList') }); } var $workarea = $(e.target.form).find("div#tagWorkArea"); var rendered = container.render(); $workarea.empty().append(rendered); // style adjustments $workarea.find("h5").css({ 'font-size': '110%' }); $workarea.find("h5:not(:first-child)").css({ 'margin-top': '1em' }); $workarea.find("div").filter(":has(span.quickformDescription)").css({ 'margin-top': '0.4em' }); // add a link to each template's description page $.each(Morebits.quickForm.getElements(e.target.form, "articleTags"), function(index, checkbox) { var $checkbox = $(checkbox); var link = Morebits.htmlNode("a", ">"); link.setAttribute("class", "tag-template-link"); link.setAttribute("href", mw.util.getUrl("Template:" + Morebits.string.toUpperCaseFirstChar(checkbox.values))); link.setAttribute("target", "_blank"); $checkbox.parent().append(["\u00A0", link]); }); }; // Tags for ARTICLES start here Twinkle.tag.article = {}; // A list of all article tags, in alphabetical order // To ensure tags appear in the default "categorized" view, add them to the tagCategories hash below. Twinkle.tag.article.tags = { "advert": "類似廣告或宣傳性內容", "autobiography": "類似一篇自傳,或內容主要由條目描述的當事人或組織撰寫、編輯", "blpdispute": "可能違反了竹園Wiki關於生者傳記的方針", "blpsources": "生者傳記需要補充更多可供查證的來源", "blpunsourced": "生者傳記沒有列出任何參考或來源", "catimprove": "需要更多頁面分類", "citation style": "引用需要進行清理", "citecheck": "可能包含不適用或被曲解的引用資料,部分內容的準確性無法被證實", "cleanup": "可能需要進行清理,以符合竹園Wiki的質量標準", "cleanup-jargon": "包含過多行話或專業術語,可能需要簡化或提出進一步解釋", "coi": "主要貢獻者與本條目所宣揚的內容可能存在利益沖突", "copypaste": "內容可能是從某個來源處拷貝後貼上", "contradict": "內容自相矛盾", "copyedit": "需要編修,以確保文法、用詞、語氣、格式、標點等使用恰當", "dead end": "需要更多內部連接以構築百科全書的鏈接網絡", "disputed": "內容疑欠準確,有待查證", "expand": "需要擴充", "expert": "需要精通或熟悉本主題的專業人士參與及協助編輯", "external links": "使用外部鏈接的方式可能不符合竹園Wiki的方針或指引", "fansite": "類似愛好者網頁", "globalize": "僅具有一部分地區的信息或觀點", "hoax": "真實性被質疑", "howto": "包含指南或教學內容", "in-universe": "使用小說故事內的觀點描述一個虛構事物", "inappropriate person": "使用不適當的第一人稱和第二人稱", "inappropriate tone": "語調或風格可能不適合百科全書的寫作方式", "lead section": "導言部分也許不足以概括其內容", "lead section too long": "導言部分也許過於冗長", "merge": "建議此頁面與頁面合併", "merge from": "建議將頁面並入本頁面", "merge to": "建議將此頁面並入頁面", "newsrelease": "閱讀起來像是新聞稿及包含過度的宣傳性語調", "no footnotes": "因爲沒有內文引用而來源仍然不明", "non-free": "可能過多或不當地使用了受版權保護的文字、圖像或/及多媒體文件", "notability": "可能不符合通用關注度指引", "notmandarin": "包含過多不是現代標準漢語的內容", "onesource": "極大或完全地依賴於某個單一的來源", "original research": "可能包含原創研究或未查證內容", "orphan": "沒有或只有很少鏈入頁面", "overlinked": "含有過多、重複、或不必要的內部鏈接", "overly detailed": "包含太多過度細節內容", "plot": "可能包含過於詳細的劇情摘要", "pov": "中立性有爭議。內容、語調可能帶有明顯的個人觀點或地方色彩", "primarysources": "依賴第一手來源", "prose": "使用了日期或時間列表式記述,需要改寫爲連貫的敘述性文字", "refimprove": "需要補充更多來源", "review": "閱讀起來類似評論,需要清理", "rewrite": "不符合竹園Wiki的質量標準,需要完全重寫", "roughtranslation": "翻譯品質不佳", "substub": "過於短小", "trivia": "應避免有陳列雜項、瑣碎資料的部分", "uncategorized": "缺少頁面分類", "unencyclopedic": "可能不適合寫入百科全書", "unreferenced": "沒有列出任何參考或來源", "update": "當前條目或章節需要更新", "verylong": "可能過於冗長", "weasel": "語意模棱兩可而損及其中立性或準確性" }; // A list of tags in order of category // Tags should be in alphabetical order within the categories // Add new categories with discretion - the list is long enough as is! Twinkle.tag.article.tagCategories = { "清理和維護模板": { "常規清理": [ "cleanup", "cleanup-jargon", "copyedit" ], "可能多余的內容": [ "copypaste", "external links", "non-free" ], "結構和導言": [ "lead section", "lead section too long", "verylong" ], "虛構作品相關清理": [ "in-universe", "plot" ] }, "常規條目問題": { "重要性和知名度": [ "notability" // has subcategories and special-cased code ], "寫作風格": [ "advert", "fansite", "howto", "inappropriate person", "inappropriate tone", "newsrelease", "prose", "review" ], "內容": [ "expand", "substub", "unencyclopedic" ], "信息和細節": [ "expert", "overly detailed", "trivia" ], "時間性": [ "update" ], "中立、偏見和事實準確性": [ "autobiography", "coi", "contradict", "disputed", "globalize", "hoax", "pov", "weasel" ], "可供查證和來源": [ "blpdispute", "blpsources", "blpunsourced", "citecheck", "no footnotes", "onesource", "original research", "primarysources", "refimprove", "unreferenced" ] }, "具體內容問題": { "語言": [ "notmandarin", "roughtranslation" ], "鏈接": [ "dead end", "orphan", "overlinked" ], "參考技術": [ "citation style" ], "分類": [ "catimprove", "uncategorized" ] }, "合併": [ // these three have a subgroup with several options "merge", "merge from", "merge to" ] }; // Tags for REDIRECTS start here Twinkle.tag.frequentList = [ { label: '{{合併重定向}}:保持頁面題名至相應主條目,令頁面內容在合併後仍能保存其編輯曆史', value: '合併重定向' }, { label: '{{簡繁重定向}}:引導簡體至繁體,或繁體至簡體', value: '簡繁重定向' }, { label: '{{模板重定向}}:指向模板的重定向頁面', value: '模板重定向' }, { label: '{{別名重定向}}:標題的其他名稱、筆名、綽號、同義字等', value: '別名重定向' }, { label: '{{譯名重定向}}:人物、作品等各項事物的其他翻譯名稱', value: '譯名重定向' }, { label: '{{縮寫重定向}}:標題縮寫', value: '縮寫重定向' }, { label: '{{拼寫重定向}}:標題的其他不同拼寫', value: '拼寫重定向' }, { label: '{{錯字重定向}}:糾正標題的常見錯誤拼寫或誤植', value: '錯字重定向' }, { label: '{{舊名重定向}}:將事物早前的名稱引導至更改後的主題', value: '舊名重定向' }, { label: '{{曆史名稱重定向}}:具有曆史意義的別名、筆名、同義詞', value: '曆史名稱重定向' }, { label: '{{全名重定向}}:標題的完整或更完整名稱', value: '全名重定向' }, { label: '{{短名重定向}}:完整標題名稱或人物全名的部分、不完整的名稱或簡稱', value: '短名重定向' }, { label: '{{姓氏重定向}}:人物姓氏', value: '姓氏重定向' }, { label: '{{名字重定向}}:人物人名', value: '名字重定向' }, { label: '{{本名重定向}}:人物本名', value: '本名重定向' }, { label: '{{非中文重定向}}:非中文標題', value: '非中文重定向' }, { label: '{{日文重定向}}:日語名稱', value: '日文重定向' } ]; Twinkle.tag.lessFrequentList = [ { label: '{{角色重定向}}:電視劇、電影、書籍等作品的角色', value: '角色重定向' }, { label: '{{章節重定向}}:導向至較高密度組織的頁面', value: '章節重定向' }, { label: '{{列表重定向}}:導向至低密度的列表', value: '列表重定向' }, { label: '{{可能性重定向}}:導向至當前提供內容更爲詳盡的目標頁面', value: '可能性重定向' }, { label: '{{關聯字重定向}}:標題名稱關聯字', value: '關聯字重定向' }, { label: '{{條目請求重定向}}:需要獨立條目的頁面', value: '條目請求重定向' }, { label: '{{快捷方式重定向}}:竹園Wiki快捷方式', value: '快捷方式重定向' } ]; Twinkle.tag.rareList = [ { label: '{{詞組重定向}}:將詞組/詞組/成語指向切題的條目及恰當章節', value: '詞組重定向' }, { label: '{{消歧義頁重定向}}:指向消歧義頁', value: '消歧義頁重定向' }, { label: '{{域名重定向}}:網域名稱', value: '域名重定向' }, { label: '{{年代重定向}}:於年份條目導向至年代條目', value: '年代重定向' }, { label: '{{用戶框模板重定向}}:用戶框模板', value: '用戶框模板重定向' }, { label: '{{重定向模板用重定向}}:導向至重定向模板', value: '重定向模板用重定向' }, { label: '{{EXIF重定向}}:JPEG圖像包含EXIF信息', value: 'EXIF重定向' } ]; // Contains those article tags that *do not* work inside {{multiple issues}}. Twinkle.tag.multipleIssuesExceptions = [ 'catimprove', 'merge', 'merge from', 'merge to', 'notability', 'notmandarin', "substub", 'uncategorized' ]; Twinkle.tag.callbacks = { main: function( pageobj ) { var params = pageobj.getCallbackParameters(), tagRe, tagText = '', summaryText = '添加', tags = [], groupableTags = [], i, totalTags; // 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 addTag = function friendlytagAddTag( tagIndex, tagName ) { var currentTag = ""; if( tagName === 'uncategorized' || tagName === 'catimprove' ) { pageText += '\n\n{{' + tagName + '|time={{subst:#time:c}}}}'; } else { currentTag += ( Twinkle.tag.mode === '重定向' ? '\n' : '' ) + '{{' + tagName; if( tagName === 'notability' && params.tagParameters.notability !== 'none' ) { currentTag += '|||' + params.tagParameters.notability; } // prompt for other parameters, based on the tag switch( tagName ) { 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 += '|' + 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 = '請求與' + params.nonDiscussArticle + '合併'; } currentTag += '|discuss=Talk:' + params.discussArticle + '#' + params.talkDiscussionTitle; } } break; default: break; } currentTag += (Twinkle.tag.mode === '重定向') ? '}}' : '|time={{subst:#time:c}}}}\n'; tagText += currentTag; } if ( tagIndex > 0 ) { if( tagIndex === (totalTags - 1) ) { summaryText += '和'; } else if ( tagIndex < (totalTags - 1) ) { summaryText += '、'; } } summaryText += '{{[['; summaryText += (tagName.indexOf(":") !== -1 ? tagName : ("T:" + tagName + "|" + tagName)); summaryText += ']]}}'; }; if( Twinkle.tag.mode !== '重定向' ) { // Check for preexisting tags and separate tags into groupable and non-groupable arrays for( i = 0; i < params.tags.length; i++ ) { tagRe = new RegExp( '(\\{\\{' + params.tags[i] + '(\\||\\}\\})|\\|\\s*' + params.tags[i] + '\\s*=[a-z ]+\\d+)', 'im' ); if( !tagRe.exec( pageText ) ) { if( params.tags[i] == 'notability' ) { wikipedia_page = new Morebits.wiki.page("Wikipedia:關注度/提報", "添加關注度記錄項"); wikipedia_page.setFollowRedirect(true); wikipedia_page.setCallbackParameters(params); wikipedia_page.load(Twinkle.tag.callbacks.notabilityList); } if( Twinkle.tag.multipleIssuesExceptions.indexOf(params.tags[i]) === -1 ) { groupableTags = groupableTags.concat( params.tags[i] ); } else { tags = tags.concat( params.tags[i] ); } } else { Morebits.status.warn( '信息', '在頁面上找到{{' + params.tags[i] + '}}…跳過' ); // don't do anything else with merge tags if (params.tags[i] === "merge" || params.tags[i] === "merge from" || params.tags[i] === "merge to") { params.mergeTarget = params.mergeReason = params.mergeTagOther = false; } } } var miTest = /\{\{(multiple ?issues|article ?issues|mi)[^}]+\{/im.exec(pageText); var miOldStyleRegex = /\{\{(multiple ?issues|article ?issues|mi)\s*\|([^{]+)\}\}/im; var miOldStyleTest = miOldStyleRegex.exec(pageText); if( ( miTest || miOldStyleTest ) && groupableTags.length > 0 ) { Morebits.status.info( '信息', '添加支持的標記入已存在的{{multiple issues}}' ); groupableTags.sort(); tagText = ""; totalTags = groupableTags.length; $.each(groupableTags, addTag); summaryText += '標記' + '(在{{[[T:multiple issues|multiple issues]]}}內)'; if( tags.length > 0 ) { summaryText += '和'; } if( miOldStyleTest ) { // convert tags from old-style to new-style var split = miOldStyleTest[2].split("|"); $.each(split, function(index, val) { split[index] = val.replace("=", "|time=").trim(); }); pageText = pageText.replace(miOldStyleRegex, "{{$1|\n{{" + split.join("}}\n{{") + "}}\n" + tagText + "}}\n"); } else { var miRegex = new RegExp("(\\{\\{\\s*" + miTest[1] + "\\s*(?:\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?)\\}\\}\\s*", "im"); pageText = pageText.replace(miRegex, "$1" + tagText + "}}\n"); } tagText = ""; } else if( params.group && groupableTags.length >= 3 ) { Morebits.status.info( '信息', '合併支持的模板入{{multiple issues}}' ); groupableTags.sort(); tagText += '{{multiple issues|\n'; totalTags = groupableTags.length; $.each(groupableTags, addTag); summaryText += '等標記({{[[T:multiple issues|multiple issues]]}})'; if( tags.length > 0 ) { summaryText += '及'; } tagText += '}}\n'; } else { tags = tags.concat( groupableTags ); } } else { // Redirect tagging: Check for pre-existing tags for( i = 0; i < params.tags.length; i++ ) { tagRe = new RegExp( '(\\{\\{' + params.tags[i] + '(\\||\\}\\}))', 'im' ); if( !tagRe.exec( pageText ) ) { tags = tags.concat( params.tags[i] ); } else { Morebits.status.warn( '信息', '在重定向上找到{{' + params.tags[i] + '}}…跳過' ); } } } tags.sort(); totalTags = tags.length; $.each(tags, addTag); if( Twinkle.tag.mode === '重定向' ) { pageText += tagText; } else { // smartly insert the new tags after any hatnotes. Regex is a bit more // complicated than it'd need to be, to allow templates as parameters, // and to handle whitespace properly. pageText = pageText.replace(/^\s*(?:((?:\s*\{\{\s*(?:about|correct title|dablink|distinguish|for|other\s?(?:hurricaneuses|people|persons|places|uses(?:of)?)|redirect(?:-acronym)?|see\s?(?:also|wiktionary)|selfref|the)\d*\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\})+(?:\s*\n)?)\s*)?/i, "$1" + tagText); } summaryText += ( tags.length > 0 ? '標記' : '' ) + '到' + Twinkle.tag.mode; // avoid truncated summaries if (summaryText.length > (254 - Twinkle.getPref('summaryAd').length)) { summaryText = summaryText.replace(/\[\[[^\|]+\|([^\]]+)\]\]/g, "$1"); } pageobj.setPageText(pageText); pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd')); pageobj.setWatchlist(Twinkle.getFriendlyPref('watchTaggedPages')); pageobj.setMinorEdit(Twinkle.getFriendlyPref('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 talkpageText = "\n\n== 請求與[[" + params.nonDiscussArticle + "]]合併 ==\n\n"; talkpageText += params.mergeReason.trim() + "--~~~~"; var talkpage = new Morebits.wiki.page("Talk:" + params.discussArticle, "將理由貼進討論頁"); talkpage.setAppendText(talkpageText); talkpage.setEditSummary('請求將[[' + params.nonDiscussArticle + ']]' + '與' + '[[' + params.discussArticle + ']]合併' + Twinkle.getPref('summaryAd')); talkpage.setWatchlist(Twinkle.getFriendlyPref('watchMergeDiscussions')); talkpage.setCreateOption('recreate'); talkpage.append(); } if (params.mergeTagOther) { // tag the target page if requested var otherTagName = "merge"; if (tags.indexOf("merge from") !== -1) { otherTagName = "merge to"; } else if (tags.indexOf("merge to") !== -1) { otherTagName = "merge from"; } var newParams = { tags: [otherTagName], mergeTarget: Morebits.pageNameNorm, discussArticle: params.discussArticle, talkDiscussionTitle: params.talkDiscussionTitle }; var otherpage = new Morebits.wiki.page(params.mergeTarget, "標記其他頁面(" + params.mergeTarget + ")"); otherpage.setCallbackParameters(newParams); otherpage.load(Twinkle.tag.callbacks.main); } }); if( params.patrol ) { pageobj.patrol(); } }, notabilityList: function(pageobj) { var text = pageobj.getPageText(); var params = pageobj.getCallbackParameters(); pageobj.setAppendText("\n{{subst:Wikipedia:關注度/提報/item|title=" + Morebits.pageNameNorm + "}}"); pageobj.setEditSummary("添加[[" + Morebits.pageNameNorm + "]]" + Twinkle.getPref('summaryAd')); pageobj.setCreateOption('recreate'); pageobj.append(); } }; Twinkle.tag.callback.evaluate = function friendlytagCallbackEvaluate(e) { var form = e.target; var params = {}; if (form.patrolPage) { params.patrol = form.patrolPage.checked; } switch (Twinkle.tag.mode) { case '條目': params.tags = form.getChecked( 'articleTags' ); params.group = form.group.checked; params.tagParameters = { notability: form["articleTags.notability"] ? form["articleTags.notability"].value : null }; // common to {{merge}}, {{merge from}}, {{merge to}} params.mergeTarget = form["articleTags.mergeTarget"] ? form["articleTags.mergeTarget"].value : null; params.mergeReason = form["articleTags.mergeReason"] ? form["articleTags.mergeReason"].value : null; params.mergeTagOther = form["articleTags.mergeTagOther"] ? form["articleTags.mergeTagOther"].checked : false; break; case '重定向': params.tags = form.getChecked( 'redirectTags' ); break; default: alert("Twinkle.tag:未知模式 " + Twinkle.tag.mode); break; } // form validation if( !params.tags.length ) { alert( '必須選擇至少一個標記!' ); return; } if( ((params.tags.indexOf("merge") !== -1) + (params.tags.indexOf("merge from") !== -1) + (params.tags.indexOf("merge to") !== -1)) > 1 ) { alert( '請在{{merge}}、{{merge from}}和{{merge to}}中選擇一個。如果需要多次合併,請使用{{merge}}並用管道符分隔條目名(但在這種情形中Twinkle不能自動標記其他條目)。' ); return; } if( (params.mergeTagOther || params.mergeReason) && params.mergeTarget.indexOf('|') !== -1 ) { alert( '目前還不支持在一次合併中標記多個條目,與開啓關於多個條目的討論。請不要勾選“標記其他條目”和/或清理“理由”框,並重試。' ); return; } 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 wikipedia_page = new Morebits.wiki.page(Morebits.pageNameNorm, "正在標記" + Twinkle.tag.mode); wikipedia_page.setCallbackParameters(params); switch (Twinkle.tag.mode) { case '條目': /* falls through */ case '重定向': wikipedia_page.load(Twinkle.tag.callbacks.main); return; default: alert("Twinkle.tag:未知模式 " + Twinkle.tag.mode); break; } }; })(jQuery); //</nowiki>
返回到「
MediaWiki:Gadget-friendlytag.js
」。
導覽選單
個人工具
尚未登入
討論
貢獻
建立帳號
登入
命名空間
訊息
討論
English
視圖
閱讀
檢視原始碼
檢視歷史
更多
搜尋
導覽
首頁
近期變更
最新頁面
隨機頁面
建立一個新項目
建立一個新屬性
說明
歡迎
方針與指引
留言板
工具
連結至此的頁面
相關變更
特殊頁面
頁面資訊