You can edit almost every page by Creating an account. Otherwise, see the FAQ.

Gadget-twinkleprod-2020.js

از EverybodyWiki Bios & Wiki
پرش به:ناوبری، جستجو

// (function($) { /* **************************************** *** twinkleprod.js: PROD module **************************************** * Mode of invocation: Tab ("PROD") * Active on: Existing articles, files, books which are not redirects, * and user pages in [[:Category:Wikipedia books (user books)]] */ Twinkle.prod = function twinkleprod() { if ((([0, 6, 108].indexOf(mw.config.get('wgNamespaceNumber')) === -1) && (mw.config.get('wgNamespaceNumber') !== 2 || mw.config.get('wgCategories').indexOf('Wikipedia books (user books)') === -1)) || !mw.config.get('wgCurRevisionId') || Morebits.wiki.isPageRedirect()) { return; } Twinkle.addPortletLink(Twinkle.prod.callback, 'حذف زمان‌دار', 'tw-prod', 'حذف زمان‌دار طبق وپ:حز'); // localized }; // Used in edit summaries, for comparisons, etc. var namespace; Twinkle.prod.callback = function twinkleprodCallback() { Twinkle.prod.defaultReason = Twinkle.getPref('prodReasonDefault'); switch (mw.config.get('wgNamespaceNumber')) { case 0: namespace = 'article'; break; case 6: namespace = 'file'; break; case 2: case 108: namespace = 'book'; break; // no default } var Window = new Morebits.simpleWindow(800, 410); Window.setTitle('حذف زماندار'); // localized Window.setScriptName('توینکل'); // localiezd var form = new Morebits.quickForm(Twinkle.prod.callback.evaluate); if (namespace === 'article') { Window.addFooterLink('سیاست حذف زمان‌دار', 'وپ:زمان‌دار'); // localized Window.addFooterLink('سیاست حذف زندگینامه زندگان', 'وپ:حزف'); // localized } else if (namespace === 'file') { Window.addFooterLink('سیاست حذف زمان‌دار', 'وپ:زمان‌دار'); // localized } /*else { // if book Window.addFooterLink('Proposed deletion (books) policy', 'WP:BOOKPROD'); // not translated }*/ // loacalized [removed] var field = form.append({ type: 'field', label: 'نوع حذف زماندار', id: 'prodtype_fieldset' }); field.append({ type: 'radio', name: 'prodtype', event: Twinkle.prod.callback.prodtypechanged, list: [ { label: 'حذف زمان‌دار', // localized value: 'prod', checked: true, tooltip: 'پیشنهاد حذف عادی، طبق [[وپ:حز]]' // localized }, { label: 'پیشنهاد حذف زندگی‌نامه زندگان', // localized value: 'prodblp', tooltip: 'پیشنهاد حذف زندگی‌نامه‌های جدید بدون منبع، طبق [[وپ:حزز]]' // localized } ] }); // Placeholder fieldset to be replaced in Twinkle.prod.callback.prodtypechanged form.append({ type: 'field', name: 'parameters' }); Window.addFooterLink('راهنمای توینکل', 'وپ:توینکل/توضیحات'); // localized form.append({ type: 'submit', label: 'حذف زمان‌دار' }); // localized var result = form.render(); Window.setContent(result); Window.display(); // Hide fieldset for File and Book PROD types since only normal PROD is allowed if (namespace !== 'article') { $(result).find('#prodtype_fieldset').hide(); } // Fake a change event on the first prod type radio, to initialize the type-dependent controls var evt = document.createEvent('Event'); evt.initEvent('change', true, true); result.prodtype[0].dispatchEvent(evt); }; Twinkle.prod.callback.prodtypechanged = function(event) { // prepare frame for prod type dependant controls var field = new Morebits.quickForm.element({ type: 'field', label: 'پارامترها', // localized name: 'parameters' }); // create prod type dependant controls switch (event.target.values) { case 'prod': field.append({ type: 'checkbox', list: [ { label: 'آگاه کردن سازندهٔ صفحه در صورت امکان', // localized value: 'notify', name: 'notify', tooltip: "در صورت انتخاب این گزینه در صفحه بحث نویسنده مقاله، الگوی اطلاع‌رسانی درج می‌شود", // localized checked: true } ] }); field.append({ type: 'textarea', name: 'reason', label: 'دلیل برای حذف زمان‌دار:', // localized value: Twinkle.prod.defaultReason }); break; case 'prodblp': // first, remember the prod value that the user entered in the textarea, in case they want to switch back. We can abuse the config field for that. if (event.target.form.reason) { Twinkle.prod.defaultReason = event.target.form.reason.value; } field.append({ type: 'checkbox', list: [ { label: 'آگاه کردن سازندهٔ صفحه در صورت امکان', // localized value: 'notify', name: 'notify', tooltip: 'سازندهٔ مقاله باید مطلع شود.', // localized checked: true, disabled: true } ] }); // temp warning, can be removed down the line once BLPPROD is more established. Amalthea, May 2010. var boldtext = document.createElement('b'); boldtext.appendChild(document.createTextNode('لطفا به یاد داشته باشید که این برچسب فقط برای مقالات بدون منبع زندگی‌نامه افراد زنده است.')); // localized field.append({ type: 'div', label: boldtext }); break; default: break; } event.target.form.replaceChild(field.render(), $(event.target.form).find('fieldset[name="parameters"]')[0]); }; Twinkle.prod.callbacks = { checkpriors: function(apiobj) { var xmlDoc = apiobj.responseXML; var statelem = apiobj.statelem; var params = apiobj.params; // Check talk page for templates indicating prior XfD or PROD var numTemplates = $(xmlDoc).find('templates tl').length; if (numTemplates) { var template = $(xmlDoc).find('templates tl')[0].getAttribute('title'); if (numTemplates === 1 && template === 'Template:Old prod') { if (params.blp) { if (!confirm('برچسب حذف‌زمان‌دار قبلی در صفحه بحث یافت شد. آیا می‌خواهید درج پیشنهاد حذف زندگی‌نامه زندگان را ادامه دهید؟')) { // localized statelem.warn('برچسب حذف‌زمان‌دار قبلی در صفحه بحث یافت شد. عملیات توسط کاربر لغو شد'); // localized return; } statelem.info('برچسب حذف‌زمان‌دار قبلی در صفحه بحث یافت شد. ادامه ...'); // localized } else { statelem.warn('برچسب حذف‌زمان‌دار قبلی در صفحه بحث یافت شد. توقف روند'); // localized return; } // if there are multiple templates, at least one of them would be a prior xfd template } else { statelem.warn('برچسب نظرخواهی حذف قبلی در صفحه بحث یافت شد. توقف روند'); // localized return; } } var ts = new Morebits.wiki.page(mw.config.get('wgPageName')); ts.setFollowRedirect(true); // for NPP, and also because redirects are ineligible for PROD ts.setCallbackParameters(params); ts.setLookupNonRedirectCreator(true); // Look for author of first non-redirect revision ts.lookupCreation(Twinkle.prod.callbacks.creationInfo); }, creationInfo: function(pageobj) { var params = pageobj.getCallbackParameters(); params.initialContrib = pageobj.getCreator(); params.creation = pageobj.getCreationTimestamp(); Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName'); Morebits.wiki.actionCompleted.notice = 'برچسب زدن تمام شد'; // localized var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'برچسب زدن به صفحه'); // localized wikipedia_page.setFollowRedirect(true); // for NPP, and also because redirects are ineligible for PROD wikipedia_page.setCallbackParameters(params); wikipedia_page.load(Twinkle.prod.callbacks.main); }, main: function(pageobj) { var statelem = pageobj.getStatusElement(); if (!pageobj.exists()) { statelem.error("به نظر می‌آید که صفحه وجود ندارد. احتمالا قبلا حذف شده است."); // localized return; } var text = pageobj.getPageText(); var params = pageobj.getCallbackParameters(); // Check for already existing deletion tags var tag_re = /{{(?:db-?|delete|حذف سریع|نظرخواهی برای حذف|article for deletion\/dated|ffd\b)|#invoke:RfD/i; if (tag_re.test(text)) { statelem.warn('صفحه در حال حاضر برچسب حذف دارد. نامزدی حذف زمان‌دار متوقف شد'); // localized return; } // Alert if article is at least three days old, not in Category:Living people, and BLPPROD is selected if (params.blp) { var isMoreThan3DaysOld = new Morebits.date(params.creation).add(3, 'days').isAfter(new Date(pageobj.getLoadTime())); var blpcheck_re = /\[\[Category:افراده زنده\]\]/i; if (!blpcheck_re.test(text) && isMoreThan3DaysOld) { if (!confirm('توجه کنید که مقاله در رده:افراد زنده قرار ندارد و به همین دلیل حذف زماندار طبق [[وپ:حزز]] برای آن مناسب نیست. آیا مطمئنید که می‌خواهید ادامه دهید؟')) { // localized return; } } } // Remove tags that become superfluous with this action text = text.replace(/{{\s*(userspace draft|mtc|(copy|move) to wikimedia commons|(copy |move )?to ?commons)\s*(\|(?:{{[^{}]*}}|[^{}])*)?}}\s*/gi, ''); var prod_re = /{{\s*(?:Prod blp|Proposed deletion|book-prod)\/dated(?: files)?\s*\|(?:{{[^{}]*}}|[^{}])*}}/i; var summaryText; if (!prod_re.test(text)) { // Notification to first contributor if (params.usertalk) { // Disallow warning yourself if (params.initialContrib === mw.config.get('wgUserName')) { statelem.warn('خود شما (' + params.initialContrib + ') را ایجاد کرده‌اید؛ توقف اطلاع‌رسانی به کاربر'); // localized if (Twinkle.getPref('logProdPages')) { Twinkle.prod.callbacks.addToLog(params); } } else { // [[Template:Proposed deletion notify]] supports File namespace var notifyTemplate; if (params.blp) { notifyTemplate = 'prodwarningBLP'; } else if (params.book) { notifyTemplate = 'bprodwarning'; } else { notifyTemplate = 'proposed deletion notify'; } var notifytext = '\n{{subst:' + notifyTemplate + '|1=' + Morebits.pageNameNorm + '|concern=' + params.reason + '}} ~~~~'; var usertalkpage = new Morebits.wiki.page('User talk:' + params.initialContrib, 'اطلاع‌رسانی به سازنده صفحه (' + params.initialContrib + ')'); // localized usertalkpage.setAppendText(notifytext); usertalkpage.setEditSummary('اطلاع‌رسانی: پیشنهاد حذف [[:' + Morebits.pageNameNorm + ']].' + Twinkle.getPref('summaryAd')); // localized usertalkpage.setCreateOption('recreate'); usertalkpage.setFollowRedirect(true); usertalkpage.setCallbackParameters(params); usertalkpage.append(function onNotifySuccess() { // add nomination to the userspace log, if the user has enabled it if (Twinkle.getPref('logProdPages')) { params.logInitialContrib = params.initialContrib; Twinkle.prod.callbacks.addToLog(params); } }, function onNotifyError() { // if user could not be notified, log nomination without mentioning that notification was sent if (Twinkle.getPref('logProdPages')) { Twinkle.prod.callbacks.addToLog(params); } }); } } else if (Twinkle.getPref('logProdPages')) { // If not notifying, log this PROD Twinkle.prod.callbacks.addToLog(params); } if (params.blp) { summaryText = 'درج پیشنهاد حذف زمان‌دار براساس [[وپ:حزز]]'; // localized text = '{{subst:prod blp' + (params.usertalk ? '|help=off' : '') + '}}\n' + text; } /*else if (params.book) { summaryText = 'Proposing book for deletion per [[WP:BOOKPROD]].'; text = '{{subst:book-prod|1=' + Morebits.string.formatReasonText(params.reason) + (params.usertalk ? '|help=off' : '') + '}}\n' + text; } */ else { summaryText = 'نامزد کردن ' + namespace + ' برای حذف زمان‌دار طبق [[وپ:حز]].'; // localized text = '{{subst:حذف زماندار|1=' + Morebits.string.formatReasonText(params.reason) + (params.usertalk ? '|help=off' : '') + '}}\n' + text; // localiezd } // Add {{Old prod}} to the talk page var oldprodfull = '{{Old prod|nom=' + mw.config.get('wgUserName') + '|nomdate={{subst:#time: Y-m-d}}}}\n'; var talktitle = new mw.Title(mw.config.get('wgPageName')).getTalkPage().getPrefixedText(); var talkpage = new Morebits.wiki.page(talktitle, 'Placing {{Old prod}} on talk page'); talkpage.setPrependText(oldprodfull); talkpage.setEditSummary('Adding {{Old prod}}' + Twinkle.getPref('summaryAd')); talkpage.setFollowRedirect(true); // match behavior for page tagging talkpage.setCreateOption('recreate'); talkpage.prepend(); } else { // already tagged for PROD, so try endorsing it var prod2_re = /{{(?:Proposed deletion endorsed|prod-?2).*?}}/i; if (prod2_re.test(text)) { statelem.warn('صفحه کنونی دارای برچسب الگوهای {{حذف زمان‌دار}} و {{تایید حذف زمان‌دار}} است. توقف روند'); // localized return; } var confirmtext = 'A {{proposed deletion}} tag was already found on this page. \nWould you like to add a {{proposed deletion endorsed}} tag with your explanation?'; if (params.blp) { confirmtext = 'A non-BLP {{proposed deletion}} tag was found on this article.\nWould you like to add a {{proposed deletion endorsed}} tag with explanation "article is a biography of a living person with no sources"?'; // FIXME: this msg is shown even if it was a BLPPROD tag. } if (!confirm(confirmtext)) { statelem.warn('به درخواست کاربر لغو شد'); // localized return; } summaryText = 'Endorsing proposed deletion per [[WP:' + (params.blp ? 'BLP' : params.book ? 'BOOK' : '') + 'PROD]].'; text = text.replace(prod_re, text.match(prod_re) + '\n{{Proposed deletion endorsed|1=' + (params.blp ? 'article is a [[WP:BLPPROD|biography of a living person with no sources]]' : Morebits.string.formatReasonText(params.reason)) + '}}\n'); if (Twinkle.getPref('logProdPages')) { params.logEndorsing = true; Twinkle.prod.callbacks.addToLog(params); } } // curate/patrol the page if (Twinkle.getPref('markProdPagesAsPatrolled')) { pageobj.triage(); } pageobj.setPageText(text); pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd')); pageobj.setWatchlist(Twinkle.getPref('watchProdPages')); pageobj.setCreateOption('nocreate'); pageobj.save(); }, addToLog: function(params) { var usl = new Morebits.userspaceLogger(Twinkle.getPref('prodLogPageName')); usl.initialText = "This is a log of all [[WP:PROD|proposed deletion]] tags applied or endorsed by this user using [[WP:TW|Twinkle]]'s PROD module.\n\n" + 'If you no longer wish to keep this log, you can turn it off using the [[Wikipedia:Twinkle/Preferences|preferences panel]], and ' + 'nominate this page for speedy deletion under [[WP:CSD#U1|CSD U1]].\n'; var logText = '# [[:' + Morebits.pageNameNorm + ']]'; var summaryText; // If a logged file is deleted but exists on commons, the wikilink will be blue, so provide a link to the log logText += namespace === 'file' ? ' ([{{fullurl:Special:Log|page=' + mw.util.wikiUrlencode(mw.config.get('wgPageName')) + '}} log]): ' : ': '; if (params.logEndorsing) { logText += 'endorsed ' + (params.blp ? 'BLP ' : params.book ? 'BOOK' : '') + 'PROD. ~~~~~'; if (params.reason) { logText += "\n#* '''دلیل''': " + params.reason + '\n'; // localized } summaryText = 'Logging endorsement of PROD nomination of [[:' + Morebits.pageNameNorm + ']].'; } else { logText += (params.blp ? 'BLP ' : params.book ? 'BOOK' : '') + 'PROD'; if (params.logInitialContrib) { logText += '; {{user|' + params.logInitialContrib + '}} مطلع شد'; // localized } logText += ' ~~~~~\n'; if (!params.blp) { logText += "#* '''دلیل''': " + params.reason + '\n'; // localized } summaryText = 'Logging PROD nomination of [[:' + Morebits.pageNameNorm + ']].'; } usl.log(logText, summaryText + Twinkle.getPref('summaryAd')); } }; Twinkle.prod.callback.evaluate = function twinkleprodCallbackEvaluate(e) { var form = e.target; var prodtype; if (namespace === 'article') { var prodtypes = form.prodtype; for (var i = 0; i < prodtypes.length; i++) { if (prodtypes[i].checked) { prodtype = prodtypes[i].values; break; } } } var params = { usertalk: form.notify.checked, blp: prodtype === 'prodblp', book: namespace === 'book', reason: prodtype === 'prodblp' ? '' : form.reason.value // using an empty string here as fallback will help with prod-2. }; Morebits.simpleWindow.setButtonsEnabled(false); Morebits.status.init(form); var talk_title = new mw.Title(mw.config.get('wgPageName')).getTalkPage().getPrefixedText(); // Talk page templates for PROD-able discussions var blocking_templates = 'Template:Old XfD multi|Template:Old MfD|Template:Oldffdfull|' + // Common prior XfD talk page templates 'Template:Oldpuffull|' + // Legacy prior XfD template 'Template:Olddelrev|' + // Prior DRV template 'Template:Old prod'; var query = { 'action': 'query', 'titles': talk_title, 'prop': 'templates', 'tltemplates': blocking_templates }; var wikipedia_api = new Morebits.wiki.api('Checking talk page for prior nominations', query, Twinkle.prod.callbacks.checkpriors); wikipedia_api.params = params; wikipedia_api.post(); }; })(jQuery); //


This article "Gadget-twinkleprod-2020.js" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Gadget-twinkleprod-2020.js. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.



Read or create/edit this page in another language[ویرایش]