मीडियाविकि:Gadget-twinklexfdBeta.js
ध्यान दें: प्रकाशित करने के बाद बदलाव देखने के लिए आपको अपने ब्राउज़र के कैश को हटाना पड़ सकता है।
- Firefox/Safari: Reload क्लिक समय Shift दबाएँ, या फिर Ctrl-F5 या Ctrl-R दबाएँ (Mac पर ⌘-R)
- Google Chrome: Ctrl-Shift-R दबाएँ (Mac पर ⌘-Shift-R)
- Internet Explorer/Edge: Refresh पर क्लिक करते समय Ctrl दबाएँ, या Ctrl-F5 दबाएँ
- Opera: Ctrl-F5 दबाएँ।
// <nowiki>
(function($) {
/*
****************************************
*** twinklexfd.js: XFD module
****************************************
* Mode of invocation: Tab ("XFD")
* Active on: Existing, non-special pages, except for file pages with no local (non-Commons) file which are not redirects
*/
Twinkle.xfd = function twinklexfd() {
// Disable on:
// * special pages
// * non-existent pages
// * files on Commons, whether there is a local page or not (unneeded local pages of files on Commons are eligible for CSD F2, or R4 if it's a redirect)
if (mw.config.get('wgNamespaceNumber') < 0 || !mw.config.get('wgArticleId') || (mw.config.get('wgNamespaceNumber') === 6 && document.getElementById('mw-sharedupload'))) {
return;
}
var tooltip = 'चर्चा आरंभ करें';
if (mw.config.get('wgIsRedirect')) {
tooltip += ' हटाने अथवा इस पुनर्निर्देशन को कहीं और लक्ष्यित करने के लिए चर्चा करें';
} else {
switch (mw.config.get('wgNamespaceNumber')) {
case 0:
tooltip += ' हटाने अथवा इस लेख के नाम बदलाव हेतु';
break;
case 10:
tooltip += ' हटाने अथवा इस साँचे के विलय हेतु ';
break;
case 828:
tooltip += ' हटाने अथवा इस मॉड्यूल के विलय हेतु ';
break;
case 6:
tooltip += ' इस फ़ाइल को हटाने हेतु';
break;
case 14:
tooltip += ', इस श्रेणी के विलय अथवा पुनर्नामकरण हेतु';
break;
default:
tooltip += ' इस पृष्ठ को हटाने हेतु';
break;
}
}
Twinkle.addPortletLink(Twinkle.xfd.callback, 'हहेच', 'tw-xfd', tooltip);
};
var utils = {
/** Get ordinal number figure */
num2order: function(num) {
switch (num) {
case 1: return '';
case 2: return '2सरा';
case 3: return '3सरा';
case 4: return '4था';
default: return num + 'वाँ';
}
},
/**
* Remove namespace name from title if present
* Exception-safe wrapper around mw.Title
* @param {string} title
*/
stripNs: function(title) {
var title_obj = mw.Title.newFromUserInput(title);
if (!title_obj) {
return title; // user entered invalid input; do nothing
}
return title_obj.getNameText();
},
/**
* Add namespace name to page title if not already given
* CAUTION: namespace name won't be added if a namespace (*not* necessarily
* the same as the one given) already is there in the title
* @param {string} title
* @param {number} namespaceNumber
*/
addNs: function(title, namespaceNumber) {
var title_obj = mw.Title.newFromUserInput(title, namespaceNumber);
if (!title_obj) {
return title; // user entered invalid input; do nothing
}
return title_obj.toText();
},
/**
* Provide Wikipedian TLA style: AfD, RfD, CfDS, RM, SfD, etc.
* @param {string} venue
* @returns {string}
*/
toTLACase: function(venue) {
return venue
.toString()
// Everybody up, inclduing rm and the terminal s in cfds
.toUpperCase()
// Lowercase the central f in a given TLA and normalize sfd-t and sfr-t
.replace(/(.)F(.)(?:-.)?/, '$1f$2');
}
};
Twinkle.xfd.currentRationale = null;
// error callback on Morebits.status.object
Twinkle.xfd.printRationale = function twinklexfdPrintRationale() {
if (Twinkle.xfd.currentRationale) {
Morebits.status.printUserText(Twinkle.xfd.currentRationale, 'आपके द्वारा दिया गया कारण नीचे प्रस्तुत है, इसे आप नई हहेच विंडो में पेस्ट करने के लिए यहाँ से कॉपी कर सकते हैं, अगर दुबारा नामांकन का प्रयास करना चाहें:');
// only need to print the rationale once
Twinkle.xfd.currentRationale = null;
}
};
Twinkle.xfd.callback = function twinklexfdCallback() {
var Window = new Morebits.simpleWindow(700, 400);
Window.setTitle('हटाने हेतु चर्चा (हहेच) आरंभ करें');
Window.setScriptName('ट्विंकल');
Window.addFooterLink('हहेच क्या है?', 'वि:हहेच');
Window.addFooterLink('आपकी वरीयतायें', 'वि:ट्विंकल/वरीयतायें#हहेच');
Window.addFooterLink('ट्विंकल सहायता', 'वि:ट्विंकल/विवरण#हहेच');
Window.addFooterLink('फीडबैक दें', 'विकिपीडिया वार्ता:ट्विंकल');
var form = new Morebits.quickForm(Twinkle.xfd.callback.evaluate);
var categories = form.append({
type: 'select',
name: 'venue',
label: 'हहेच प्रकार और चर्चास्थल चयन करें:',
tooltip: 'यह विंडो सक्रिय होने पर एक विकल्प अपने आप चुना हुआ दीखता है, यह नामस्थान के आधार पर होता है। यह स्वतः चयन सबसे बेहतर होना चाहिये। अगर आप आश्वस्त नहीं हैं कि क्या चुनें तो कृपया कोई और विकल्प न चुनें, इसी विकल्प के साथ आगे बढ़ें। अपनी पसंद अनुसार तभी विकल्प चुने जब आपको भलीभाँति यह पता हो कि आप क्या कर रहे हैं।',
event: Twinkle.xfd.callback.change_category
});
var namespace = mw.config.get('wgNamespaceNumber');
categories.append({
type: 'option',
label: 'लेख हटाने हेतु चर्चा (लेख हहेच)',
selected: namespace === 0, // Main namespace
value: 'afd'
});
// categories.append({
// type: 'option',
// label: 'साँचा/मॉड्यूल हटाने हेतु चर्चा (साँचा हहेच)',
// selected: [ 10, 828 ].indexOf(namespace) !== -1, // Template and module namespaces
// value: 'tfd'
// });
// categories.append({
// type: 'option',
// label: 'फ़ाइल हटाने हेतु चर्चा (फ़ाइल हहेच)',
// selected: namespace === 6, // File namespace
// value: 'ffd'
// });
// categories.append({
// type: 'option',
// label: 'श्रेणी हटाने हेतु चर्चा (श्रेणी हहेच)',
// selected: namespace === 14 || (namespace === 10 && /-stub$/.test(Morebits.pageNameNorm)), // Category namespace and stub templates
// value: 'cfd'
// });
// categories.append({
// type: 'option',
// label: 'CfD/S (Categories for speedy renaming)',
// value: 'cfds'
// });
// categories.append({
// type: 'option',
// label: 'अन्य पृष्ठ हटाने हेतु चर्चा (अन्य हहेच)',
// selected: [ 0, 6, 10, 14, 828 ].indexOf(namespace) === -1 || Morebits.pageNameNorm.indexOf('Template:User ', 0) === 0,
// // Other namespaces, and userboxes in template namespace
// value: 'mfd'
// });
// categories.append({
// type: 'option',
// label: 'RfD (Redirects for discussion)',
// selected: mw.config.get('wgIsRedirect'),
// value: 'rfd'
// });
categories.append({
type: 'option',
label: 'लेख का नाम बदलाव अनुरोध करने हेतु (स्थानांतरण चर्चा)',
selected: false,
value: 'rm'
});
form.append({
type: 'div',
id: 'wrong-venue-warn',
style: 'color: red; font-style: italic'
});
form.append({
type: 'checkbox',
list: [
{
label: 'यदि संभव हो तो पृष्ठ निर्माता को सूचित भी करें',
value: 'notify',
name: 'notifycreator',
tooltip: "पृष्ठ निर्माता के सदस्य वार्ता पृष्ठ पर एक सूचना भेजी जायेगी अगर यह विकल्प आपके द्वारा चुना जाता है।",
checked: true
}
]
});
form.append({
type: 'field',
label: 'Work area',
name: 'work_area'
});
var previewlink = document.createElement('a');
$(previewlink).click(function() {
Twinkle.xfd.callbacks.preview(result); // |result| is defined below
});
previewlink.style.cursor = 'pointer';
previewlink.textContent = 'झलक देखें';
form.append({ type: 'div', id: 'xfdpreview', label: [ previewlink ] });
form.append({ type: 'div', id: 'twinklexfd-previewbox', style: 'display: none' });
form.append({ type: 'submit' });
var result = form.render();
Window.setContent(result);
Window.display();
result.previewer = new Morebits.wiki.preview($(result).find('div#twinklexfd-previewbox').last()[0]);
// We must init the controls
var evt = document.createEvent('Event');
evt.initEvent('change', true, true);
result.venue.dispatchEvent(evt);
};
Twinkle.xfd.callback.wrongVenueWarning = function twinklexfdWrongVenueWarning(venue) {
var text = '';
var namespace = mw.config.get('wgNamespaceNumber');
switch (venue) {
case 'afd':
if (namespace !== 0) {
text = 'लेख हहेच आमतौर पर केवल लेखों के लिए उचित है।';
} else if (mw.config.get('wgIsRedirect')) {
text = 'अनुप्रेषण पृष्ठों के लिए अभी यह उपकरण असक्रिय है। कृपया मैनुअली नामांकन करें।';
}
break;
case 'tfd':
if (namespace === 10 && /-stub$/.test(Morebits.pageNameNorm)) {
text = 'आधार साँचों के कृपया श्रेणी हहेच का प्रयोग करें; क्योंकि ऐसे में श्रेणी का नाम भी बदलना या हटाना होता है जो मुख्य कार्य है।';
} else if (Morebits.pageNameNorm.indexOf('Template:User ') === 0) {
text = 'सदस्य बॉक्स साँचों के लिए अन्य हहेच प्रकार का चुनाव करें।';
}
break;
case 'cfd':
if ([ 10, 14 ].indexOf(namespace) === -1) {
text = 'क्ष हहेच केवल श्रेणियों और आधार साँचों के लिए उपयुक्त है।';
}
break;
case 'cfds':
if (namespace !== 14) {
text = 'CfDS is only for categories.';
}
break;
case 'ffd':
if (namespace !== 6) {
text = 'आपने फ़ाइल हहेच चुना है पर यह पृष्ठ फ़ाइल पृष्ठ तो नहीं प्रतीत हो रहा!';
}
break;
case 'rm':
if (namespace === 14) { // category
text = 'यह केवल लेखों का नाम बदलने के लिए है। अन्य कार्यों के लिए नामस्थान अनुसार उचित हहेच प्रकार चुनें';
}
break;
default: // mfd or rfd
break;
}
$('#wrong-venue-warn').text(text);
};
Twinkle.xfd.callback.change_category = function twinklexfdCallbackChangeCategory(e) {
var value = e.target.value;
var form = e.target.form;
var old_area = Morebits.quickForm.getElements(e.target.form, 'work_area')[0];
var work_area = null;
var oldreasontextbox = form.getElementsByTagName('textarea')[0];
var oldreason = oldreasontextbox ? oldreasontextbox.value : '';
var appendReasonBox = function twinklexfdAppendReasonBox() {
work_area.append({
type: 'textarea',
name: 'reason',
label: 'कारण (हस्ताक्षर न जोड़ें, यह ट्विंकल द्वारा स्वतः जोड़ लिया जायेगा):',
value: oldreason,
tooltip: 'आप अपने कारण में विकिकड़ी का प्रयोग कर सकते हैं। कृपया इसमें बाहरी यूआरएल न डालें और हस्ताक्षर स्वतः जुड़ेंगे।'
});
};
Twinkle.xfd.callback.wrongVenueWarning(value);
form.previewer.closePreview();
switch (value) {
case 'afd':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'लेख हटाने हेतु चर्चा',
name: 'work_area'
});
/*
work_area.append({
type: 'div',
label: '', // Added later by Twinkle.makeFindSourcesDiv()
id: 'twinkle-xfd-findsources',
style: 'margin-bottom: 5px; margin-top: -5px;'
});
*/
work_area.append({
type: 'checkbox',
list: [
{
label: 'टैग को <noinclude> में लपेट कर जोड़ें।',
value: 'noinclude',
name: 'noinclude',
tooltip: 'यह कभी-कभी ही प्रयोग में लिया जाता; जब लेख कहीं और भी ट्रांसक्लूड हो रहा हो। ऐसा न हो तो इसे न चुनें।'
}
]
});
/* ******************************************** इसे फिलहाल असक्रिय रखा गया है ******************************************************
work_area.append({
type: 'select',
name: 'xfdcat',
label: 'Choose what category this nomination belongs in:',
list: [
{ type: 'option', label: 'Unknown', value: '?', selected: true },
{ type: 'option', label: 'Media and music', value: 'M' },
{ type: 'option', label: 'Organisation, corporation, or product', value: 'O' },
{ type: 'option', label: 'Biographical', value: 'B' },
{ type: 'option', label: 'Society topics', value: 'S' },
{ type: 'option', label: 'Web or internet', value: 'W' },
{ type: 'option', label: 'Games or sports', value: 'G' },
{ type: 'option', label: 'Science and technology', value: 'T' },
{ type: 'option', label: 'Fiction and the arts', value: 'F' },
{ type: 'option', label: 'Places and transportation', value: 'P' },
{ type: 'option', label: 'Indiscernible or unclassifiable topic', value: 'I' },
{ type: 'option', label: 'Debate not yet sorted', value: 'U' }
]
});
// delsort categories taken from [[WP:DS/C]], inspired by off [[User:Enterprisey/delsort.js]]
var delsortCategories = {
'People': ['People', 'Academics and educators', 'Actors and filmmakers', 'Artists', 'Authors', 'Bands and musicians', 'Businesspeople', 'Politicians', 'Sportspeople', 'Women', 'Lists of people'],
'Arts': ['Arts', 'Fictional elements', 'Science fiction and fantasy'],
'Arts/Culinary': ['Food and drink', 'Wine'],
'Arts/Language': ['Language', 'Academic journals', 'Bibliographies', 'Journalism', 'Literature', 'Logic', 'News media', 'Philosophy', 'Poetry'],
'Arts/Performing': ['Albums and songs', 'Dance', 'Film', 'Magic', 'Music', 'Radio', 'Television', 'Theatre', 'Video games'],
'Arts/Visual arts': ['Visual arts', 'Architecture', 'Fashion', 'Photography'],
'Arts/Comics and animation': ['Comics and animation', 'Anime and manga', 'Webcomics'],
'Places of interest': ['Museums and libraries', 'Shopping malls'],
'Topical': ['Animal', 'Bilateral relations', 'Conservatism', 'Conspiracy theories', 'Crime', 'Disability', 'Discrimination', 'Entertainment', 'Ethnic groups', 'Events', 'Finance', 'Games', 'Health and fitness', 'History', 'Law', 'Military', 'Organizations', 'Paranormal', 'Piracy', 'Politics', 'Terrorism'],
'Topical/Business': ['Business', 'Advertising', 'Companies', 'Management', 'Products'],
'Topical/Culture': ['Beauty pageants', 'Fashion', 'Mythology', 'Popular culture', 'Sexuality and gender'],
'Topical/Education': ['Education', 'Fraternities and sororities', 'Schools'],
'Topical/Religion': ['Religion', 'Atheism', 'Bible', 'Buddhism', 'Christianity', 'Islam', 'Judaism', 'Hinduism', 'Paganism', 'Sikhism', 'Spirituality'],
'Topical/Science': ['Science', 'Archaeology', 'Astronomy', 'Behavioural science', 'Biology', 'Economics', 'Engineering', 'Environment', 'Geography', 'Mathematics', 'Medicine', 'Organisms', 'Psychiatry', 'Psychology', 'Social science'],
'Topical/Sports': ['Sports', 'American football', 'Baseball', 'Basketball', 'Bodybuilding', 'Boxing', 'Cricket', 'Cycling', 'Football', 'Golf', 'Handball', 'Horse racing', 'Ice hockey', 'Motorsport', 'Rugby union', 'Softball', 'Martial arts', 'Wrestling'],
'Topical/Technology': ['Technology', 'Aviation', 'Computing', 'Firearms', 'Internet', 'Software', 'Transportation', 'Websites'],
'Wikipedia page type': ['Disambiguations', 'Lists'],
'Geographic/Africa': ['Africa', 'Algeria', 'Democratic Republic of the Congo', 'Egypt', 'Ethiopia', 'Ghana', 'Kenya', 'Libya', 'Mauritius', 'Morocco', 'Nigeria', 'Somalia', 'South Africa', 'Zimbabwe'],
'Geographic/Asia': ['Asia', 'Afghanistan', 'Bangladesh', 'Brunei', 'Cambodia', 'China', 'Hong Kong', 'Indonesia', 'Japan', 'Korea', 'Laos', 'Malaysia', 'Maldives', 'Mongolia', 'Myanmar', 'Nepal', 'Pakistan', 'Philippines', 'Singapore', 'South Korea', 'Sri Lanka', 'Taiwan', 'Thailand', 'Vietnam'],
'Geographic/Asia/Central Asia': ['Central Asia', 'Kazakhstan', 'Kyrgyzstan', 'Tajikistan', 'Turkmenistan', 'Uzbekistan'],
'Geographic/Asia/Middle East': ['Middle East', 'Bahrain', 'Iran', 'Iraq', 'Israel', 'Jordan', 'Kuwait', 'Lebanon', 'Libya', 'Palestine', 'Qatar', 'Saudi Arabia', 'Syria', 'United Arab Emirates', 'Yemen'],
'Geographic/Asia/India': ['India', 'Kerala'],
'Geographic/Europe': ['Europe', 'Albania', 'Armenia', 'Austria', 'Azerbaijan', 'Belarus', 'Belgium', 'Bosnia and Herzegovina', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Georgia (country)', 'Germany', 'Greece', 'Hungary', 'Iceland', 'Ireland', 'Italy', 'Jersey', 'Kosovo', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Moldova', 'Montenegro', 'Netherlands', 'North Macedonia', 'Norway', 'Poland', 'Portugal', 'Romania', 'Russia', 'Serbia', 'Slovakia', 'Slovenia', 'Spain', 'Sweden', 'Switzerland', 'Turkey', 'Ukraine', 'Yugoslavia'],
'Geographic/Europe/United Kingdom': ['United Kingdom', 'England', 'Northern Ireland', 'Scotland', 'Wales'],
'Geographic/Oceania': ['Oceania', 'Antarctica', 'Australia', 'New Zealand'],
'Geographic/Americas/Canada': ['Canada', 'Alberta', 'British Columbia', 'Manitoba', 'Nova Scotia', 'Ontario', 'Quebec'],
'Geographic/Americas/Latin America': ['Latin America', 'Caribbean', 'South America', 'Argentina', 'Barbados', 'Belize', 'Bolivia', 'Brazil', 'Chile', 'Colombia', 'Costa Rica', 'Cuba', 'Ecuador', 'El Salvador', 'Grenada', 'Guatemala', 'Haiti', 'Mexico', 'Nicaragua', 'Panama', 'Paraguay', 'Peru', 'Puerto Rico', 'Trinidad and Tobago', 'Uruguay', 'Venezuela'],
'Geographic/Americas/USA': ['United States of America', 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia (U.S. state)', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'Washington, D.C.', 'West Virginia', 'Wisconsin', 'Wyoming'],
'Geographic/Unsorted': ['Islands']
};
var delsort = work_area.append({
type: 'select',
multiple: true,
name: 'delsortCats',
label: 'Choose deletion sorting categories:',
tooltip: 'Select a few categories that are specifically relevant to the subject of the article. Be as precise as possible; categories like People and USA should only be used when no other categories apply.'
});
$.each(delsortCategories, function(groupname, list) {
var group = delsort.append({ type: 'optgroup', label: groupname });
list.forEach(function(item) {
group.append({ type: 'option', label: item, value: item });
});
});
*/
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
// Twinkle.makeFindSourcesDiv('#twinkle-xfd-findsources');
/*
$(work_area).find('[name=delsortCats]')
.attr('data-placeholder', 'Select delsort pages')
.select2({
width: '100%',
matcher: Morebits.select2.matcher,
templateResult: Morebits.select2.highlightSearchMatches,
language: {
searching: Morebits.select2.queryInterceptor
},
// Link text to the page itself
templateSelection: function(choice) {
return $('<a>').text(choice.text).attr({
href: mw.util.getUrl('विकिपीडिया:WikiProject_Deletion_sorting/' + choice.text),
target: '_blank'
});
}
});
*/
mw.util.addCSS(
// Remove black border
'.select2-container--default.select2-container--focus .select2-selection--multiple { border: 1px solid #aaa; }' +
// Reduce padding
'.select2-results .select2-results__option { padding-top: 1px; padding-bottom: 1px; }' +
'.select2-results .select2-results__group { padding-top: 1px; padding-bottom: 1px; } ' +
// Adjust font size
'.select2-container .select2-dropdown .select2-results { font-size: 13px; }' +
'.select2-container .selection .select2-selection__rendered { font-size: 13px; }' +
// Make the tiny cross larger
'.select2-selection__choice__remove { font-size: 130%; }'
)
break;
case 'tfd':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'साँचा हटाने हेतु चर्चा',
name: 'work_area'
});
var templateOrModule = mw.config.get('wgPageContentModel') === 'Scribunto' ? 'module' : 'template';
work_area.append({
type: 'select',
label: 'किस प्रकार की कार्रवाई चाहते हैं?:',
name: 'xfdcat',
event: function(e) {
var target = e.target,
tfdtarget = target.form.tfdtarget;
// add/remove extra input box
if (target.value === 'tfm' && !tfdtarget) {
tfdtarget = new Morebits.quickForm.element({
name: 'tfdtarget',
type: 'input',
label: 'अन्य ' + templateOrModule + ' का विलय कर दिया जाय:',
tooltip: 'यह देना आवश्यक है। इसमें ' + Morebits.string.toUpperCaseFirstChar(templateOrModule) + ': नामस्थान का उपसर्ग न रखें',
required: true
});
target.parentNode.appendChild(tfdtarget.render());
} else {
$(Morebits.quickForm.getElementContainer(tfdtarget)).remove();
tfdtarget = null;
}
},
list: [
{ type: 'option', label: 'हटाने हेतु', value: 'tfd', selected: true },
{ type: 'option', label: 'विलय हेतु', value: 'tfm' }
]
});
work_area.append({
type: 'select',
name: 'templatetype',
label: 'हटाने का टैग किस स्टाइल में दिखे?:',
tooltip: 'Which <code>type=</code> parameter to pass to the TfD tag template.',
list: templateOrModule === 'module' ? [
{ type: 'option', value: 'module', label: 'Module', selected: true }
] : [
{ type: 'option', value: 'standard', label: 'Standard', selected: true },
{ type: 'option', value: 'sidebar', label: 'Sidebar/infobox', selected: $('.infobox').length },
{ type: 'option', value: 'inline', label: 'Inline template', selected: $('.mw-parser-output > p .Inline-Template').length },
{ type: 'option', value: 'tiny', label: 'Tiny inline' }
]
});
work_area.append({
type: 'checkbox',
list: [
{
label: 'हटाने के टैग को <noinclude> में लपेट का जोड़ें',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Will wrap the deletion tag in <noinclude> tags, so that it won\'t get substituted along with the template.',
disabled: templateOrModule === 'module',
checked: !!$('.box-Subst_only').length // Default to checked if page carries {{subst only}}
}
]
});
work_area.append({
type: 'checkbox',
list: [
{
label: 'साँचा के प्रयोगकर्ताओं को सूचित करें',
value: 'devpages',
name: 'devpages',
tooltip: 'A notification template will be sent to Twinkle, AWB, and RedWarn if this is true.',
checked: true
}
]
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'mfd':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'अन्य पृष्ठ हटाने हेतु चर्चा',
name: 'work_area'
});
work_area.append({
type: 'checkbox',
list: [
{
label: 'हटाने के टैग को <noinclude> में लपेट कर जोड़ें',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Will wrap the deletion tag in <noinclude> tags, so that it won\'t transclude. Select this option for userboxes.'
}
]
});
if ((mw.config.get('wgNamespaceNumber') === 2 /* सदस्य: */ || mw.config.get('wgNamespaceNumber') === 3 /* सदस्य वार्ता: */) && mw.config.exists('wgRelevantUserName')) {
work_area.append({
type: 'checkbox',
list: [
{
label: 'सदस्यनामस्थान में बने पृष्ठ के स्वामी को भी सूचित करें (यदि स्वयं वह पृष्ठ का निर्माता नहीं है)',
value: 'notifyuserspace',
name: 'notifyuserspace',
tooltip: 'If the user in whose userspace this page is located is not the page creator (for example, the page is a rescued article stored as a userspace draft), notify the userspace owner as well.',
checked: true
}
]
});
}
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'ffd':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'फ़ाइलों हेतु चर्चा स्थल',
name: 'work_area'
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'cfd':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'श्रेणियों हेतु चर्चा स्थल',
name: 'work_area'
});
var isCategory = mw.config.get('wgNamespaceNumber') === 14;
work_area.append({
type: 'select',
label: 'कार्रवाई का प्रकार चुनें:',
name: 'xfdcat',
event: function(e) {
var value = e.target.value,
cfdtarget = e.target.form.cfdtarget,
cfdtarget2 = e.target.form.cfdtarget2;
// update enabled status
cfdtarget.disabled = value === 'cfd' || value === 'sfd-t';
if (isCategory) {
// update label
if (value === 'cfs') {
Morebits.quickForm.setElementLabel(cfdtarget, 'लक्ष्य श्रेणियाँ: ');
} else if (value === 'cfc') {
Morebits.quickForm.setElementLabel(cfdtarget, 'लक्ष्य लेख: ');
} else {
Morebits.quickForm.setElementLabel(cfdtarget, 'लक्ष्य श्रेणी: ');
}
// add/remove extra input box
if (value === 'cfs') {
if (cfdtarget2) {
cfdtarget2.disabled = false;
$(cfdtarget2).show();
} else {
cfdtarget2 = document.createElement('input');
cfdtarget2.setAttribute('name', 'cfdtarget2');
cfdtarget2.setAttribute('type', 'text');
cfdtarget2.setAttribute('required', 'true');
cfdtarget.parentNode.appendChild(cfdtarget2);
}
} else {
$(cfdtarget2).prop('disabled', true);
$(cfdtarget2).hide();
}
} else { // Update stub template label
Morebits.quickForm.setElementLabel(cfdtarget, 'लक्ष्य आधार साँचा: ');
}
},
list: isCategory ? [
{ type: 'option', label: 'हटाने हेतु', value: 'cfd', selected: true },
{ type: 'option', label: 'विलय हेतु', value: 'cfm' },
{ type: 'option', label: 'नाम बदलाव (स्थानांतरण) हेतु', value: 'cfr' },
{ type: 'option', label: 'द्विभाजन हेतु', value: 'cfs' },
{ type: 'option', label: 'लेख में परिवर्तित करने हेतु', value: 'cfc' }
] : [
{ type: 'option', label: 'आधार श्रेणी हटाने हेतु', value: 'sfd-t', selected: true },
{ type: 'option', label: 'आधार श्रेणी बदलने/नामांतरण हेतु', value: 'sfr-t' }
]
});
work_area.append({
type: 'input',
name: 'cfdtarget',
label: 'लक्ष्य श्रेणी:', // default, changed above
disabled: true,
required: true, // only when enabled
value: ''
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'cfds':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'शीघ्र नाम बदलाव हेतु श्रेणियाँ',
name: 'work_area'
});
work_area.append({
type: 'select',
label: 'C2 उप-मापदंड:',
name: 'xfdcat',
tooltip: 'See WP:CFDS for full explanations.',
list: [
{ type: 'option', label: 'C2A: Typographic and spelling fixes', value: 'C2A', selected: true },
{ type: 'option', label: 'C2B: Naming conventions and disambiguation', value: 'C2B' },
{ type: 'option', label: 'C2C: Consistency with names of similar categories', value: 'C2C' },
{ type: 'option', label: 'C2D: Rename to match article name', value: 'C2D' },
{ type: 'option', label: 'C2E: Author request', value: 'C2E' },
{ type: 'option', label: 'C2F: One eponymous article', value: 'C2F' }
]
});
work_area.append({
type: 'input',
name: 'cfdstarget',
label: 'नया नाम:',
value: '',
required: true
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'rfd':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'अनुप्रेषण पृष्ठ हेतु चर्चा',
name: 'work_area'
});
work_area.append({
type: 'checkbox',
list: [
{
label: 'लक्ष्य पृष्ठ को भी सूचित करें',
value: 'relatedpage',
name: 'relatedpage',
tooltip: "A notification template will be placed on the talk page of this redirect's target if this is true.",
checked: true
}
]
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'rm':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'नाम बदलाव (स्थानांतरण) अनुरोध',
name: 'work_area'
});
work_area.append({
type: 'checkbox',
list: [
{
label: 'ग़ैर-विवादित तकनीकी स्थानांतरण',
value: 'rmtr',
name: 'rmtr',
tooltip: 'इस विकल्प का प्रयोग तब करें जब कोई ग़ैर-विवादित नाम बदलाव करना हो लेकिन आप किसी तकनीकी कारणवश ऐसा न कर पा रहे हों। उदाहरण के लिए आप स्वतः परीक्षित सदस्य न हों, नया शीर्षक पहले से मौज़ूद हो, अथवा शीर्षक सुरक्षित किया गया हो।)',
checked: false,
event: function() {
form.newname.required = this.checked;
}
}
]
});
work_area.append({
type: 'input',
name: 'newname',
label: 'नया नाम:',
tooltip: 'तकनीकी अनुरोधों के लिए यह देना आवश्यक है। अन्यथा आप अगर नये नाम के प्रति संशय में हों तो इसे ख़ाली भी छोड़ सकते हैं।'
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
default:
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'कुछ नहीं, कोई बात नहीं',
name: 'work_area'
});
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
}
// Return to checked state when switching, but no creator notification for CFDS or RM
form.notifycreator.disabled = value === 'cfds' || value === 'rm';
form.notifycreator.checked = !form.notifycreator.disabled;
};
Twinkle.xfd.callbacks = {
// Requires having the tag text (params.tagText) set ahead of time
autoEditRequest: function(pageobj, params) {
var talkName = new mw.Title(pageobj.getPageName()).getTalkPage().toText();
if (talkName === pageobj.getPageName()) {
pageobj.getStatusElement().error('पृष्ठ सुरक्षित है और कोई ऐसी जगह नहीं जहाँ संपादन अनुरोध भेजा जा सके, रद्द किया जा रहा है');
} else {
pageobj.getStatusElement().warn('पृष्ठ सुरक्षित है, संपादन अनुरोध किया जा रहा');
var editRequest = '{{subst:Xfd edit protected|page=' + pageobj.getPageName() +
'|discussion=' + params.discussionpage + (params.venue === 'rfd' ? '|rfd=yes' : '') +
'|tag=<nowiki>' + params.tagText + '\u003C/nowiki>}}'; // U+003C: <
var talk_page = new Morebits.wiki.page(talkName, 'वार्ता पृष्ठ पर स्वचालित रूप से संपादन अनुरोध जोड़ा जा रहा है');
talk_page.setNewSectionTitle('संपादन अनुरोध: ' + utils.toTLACase(params.venue) + ' के नामांकन अनुरोध हेतु');
talk_page.setNewSectionText(editRequest);
talk_page.setCreateOption('recreate');
talk_page.setWatchlist(Twinkle.getPref('xfdWatchPage'));
talk_page.setFollowRedirect(true); // should never be needed, but if the article is moved, we would want to follow the redirect
talk_page.setChangeTags(Twinkle.changeTags);
talk_page.setCallbackParameters(params);
talk_page.newSection(null, function() {
talk_page.getStatusElement().warn('संपादन अनुरोध करने में विफल, संभवतः वार्ता पृष्ठ सुरक्षित हो');
});
}
},
getDiscussionWikitext: function(venue, params) {
if (venue === 'cfds') { // CfD/S takes a completely different style
return '* [[:' + Morebits.pageNameNorm + ']] to [[:' + params.cfdstarget + ']]\u00A0\u2013 ' +
params.xfdcat + (params.reason ? ': ' + Morebits.string.formatReasonText(params.reason) : '.') + ' ~~~~';
// U+00A0 NO-BREAK SPACE; U+2013 EN RULE
}
if (venue === 'rm') {
// even if invoked from talk page, propose the subject page for move
var pageName = new mw.Title(Morebits.pageNameNorm).getSubjectPage().toText();
return (params.rmtr ?
'{{subst:RMassist|1=' + pageName + '|2=' + params.newname :
'{{subst:Requested move|current1=' + pageName + '|new1=' + params.newname)
+ '|reason=' + params.reason + '}}';
}
var text = '{{subst:' + venue + '2';
var reasonKey = venue === 'ffd' ? 'Reason' : 'text';
// Add a reason unconditionally, so that at least a signature is added
text += '|' + reasonKey + '=' + Morebits.string.formatReasonText(params.reason, true);
if (venue === 'afd' || venue === 'mfd') {
text += '|pg=' + Morebits.pageNameNorm;
if (venue === 'afd') {
text += '|cat=' + params.xfdcat;
}
} else if (venue === 'rfd') {
text += '|redirect=' + Morebits.pageNameNorm;
} else {
text += '|1=' + mw.config.get('wgTitle');
if (mw.config.get('wgPageContentModel') === 'Scribunto') {
text += '|module=Module:';
}
}
if (params.rfdtarget) {
text += '|target=' + params.rfdtarget + (params.section ? '#' + params.section : '');
} else if (params.tfdtarget) {
text += '|2=' + params.tfdtarget;
} else if (params.cfdtarget) {
text += '|2=' + params.cfdtarget;
if (params.cfdtarget2) {
text += '|3=' + params.cfdtarget2;
}
} else if (params.uploader) {
text += '|Uploader=' + params.uploader;
}
text += '}}';
if (params.delsortCats) { // Only for AFDs
params.delsortCats.forEach(function (cat) {
text += '\n{{subst:delsort|' + cat + '|~~~~}}';
});
}
return text;
},
showPreview: function(form, venue, params) {
var templatetext = Twinkle.xfd.callbacks.getDiscussionWikitext(venue, params);
if (venue === 'rm') { // RM templates are sensitive to page title
form.previewer.beginRender(templatetext, params.rmtr ? 'विकिपीडिया:स्थानांतरण अनुरोध/तकनीकी अनुरोध' : new mw.Title(Morebits.pageNameNorm).getTalkPage().toText());
} else {
form.previewer.beginRender(templatetext, 'वि:ट्विंकल'); // Force wikitext
}
},
preview: function(form) {
// venue, reason, xfdcat, tfdtarget, cfdtarget, cfdtarget2, cfdstarget, delsortCats, newname
var params = Morebits.quickForm.getInputData(form);
var venue = params.venue;
// Remove CfD or TfD namespace prefixes if given
if (params.tfdtarget) {
params.tfdtarget = utils.stripNs(params.tfdtarget);
} else if (params.cfdtarget) {
params.cfdtarget = utils.stripNs(params.cfdtarget);
if (params.cfdtarget2) {
params.cfdtarget2 = utils.stripNs(params.cfdtarget2);
}
} else if (params.cfdstarget) { // Add namespace if not given (CFDS)
params.cfdstarget = utils.addNs(params.cfdstarget, 14);
}
if (venue === 'ffd') {
// Fetch the uploader
var page = new Morebits.wiki.page(mw.config.get('wgPageName'));
page.lookupCreation(function() {
params.uploader = page.getCreator();
Twinkle.xfd.callbacks.showPreview(form, venue, params);
});
} else if (venue === 'rfd') { // Find the target
Twinkle.xfd.callbacks.rfd.findTarget(params, function(params) {
Twinkle.xfd.callbacks.showPreview(form, venue, params);
});
} else if (venue === 'cfd') { // Swap in CfD subactions
Twinkle.xfd.callbacks.showPreview(form, params.xfdcat, params);
} else {
Twinkle.xfd.callbacks.showPreview(form, venue, params);
}
},
/**
* Unified handler for sending {{Xfd notice}} notifications
* Also handles userspace logging
* @param {object} params
* @param {string} notifyTarget The user or page being notified
* @param {boolean} [noLog=false] Whether to skip logging to userspace
* XfD log, especially useful in cases in where multiple notifications
* may be sent out (MfD, TfM, RfD)
* @param {string} [actionName] Alternative description of the action
* being undertaken. Required if not notifying a user talk page.
*/
notifyUser: function(params, notifyTarget, noLog, actionName) {
// Ensure items with User talk or no namespace prefix both end
// up at user talkspace as expected, but retain the
// prefix-less username for addToLog
notifyTarget = mw.Title.newFromText(notifyTarget, 3);
var targetNS = notifyTarget.getNamespaceId();
var usernameOrTarget = notifyTarget.getRelativeText(3);
notifyTarget = notifyTarget.toText();
if (targetNS === 3) {
// Disallow warning yourself
if (usernameOrTarget === mw.config.get('wgUserName')) {
Morebits.status.warn('ध्यान दें (' + usernameOrTarget + ') जी, यह पृष्ठ आप ही के द्वारा निर्मित है; सूचना भेजना छोड़ा जा रहा');
// if we thought we would notify someone but didn't,
// then jump to logging.
Twinkle.xfd.callbacks.addToLog(params, null);
return;
}
// Default is notifying the initial contributor, but MfD also
// notifies userspace page owner
actionName = actionName || 'पृष्ठ निर्माता (' + usernameOrTarget + ') को सूचित किया जा रहा';
}
var notifytext = '\n{{subst:' + params.venue + ' notice';
// Venue-specific parameters
switch (params.venue) {
case 'afd':
notifytext += '|चर्चा पृष्ठ=' + params.discussionpage + '|कारण=' + params.reason;
case 'mfd':
notifytext += params.numbering !== '' ? '|order= ' + params.numbering : '';
break;
case 'tfd':
if (params.xfdcat === 'tfm') {
notifytext = '\n{{subst:Tfm notice|2=' + params.tfdtarget;
}
break;
case 'cfd':
notifytext += '|action=' + params.action + (mw.config.get('wgNamespaceNumber') === 10 ? '|stub=yes' : '');
break;
default: // ffd, rfd
break;
}
notifytext += '|1=' + Morebits.pageNameNorm + '}} ~~~~';
// Link to the venue; object used here rather than repetitive items in switch
var venueNames = {
afd: 'लेख हटाने हेतु',
tfd: 'चर्चा हेतु साँचे',
mfd: 'चर्चा हेतु विविध पृष्ठ',
cfd: 'चर्चा हेतु श्रेणियाँ',
ffd: 'चर्चा हेतु फ़ाइलें',
rfd: 'चर्चा हेतु पुनर्निर्देशन'
};
var editSummary = 'सूचना: [[:' +
Morebits.pageNameNorm + ']] को [[विकिपीडिया:पृष्ठ हटाने हेतु चर्चा|हटाने हेतु]] नामांकन, [[' + params.discussionpage + '|चर्चा पृष्ठ देखें]]';
var usertalkpage = new Morebits.wiki.page(notifyTarget, actionName);
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary(editSummary);
usertalkpage.setChangeTags(Twinkle.changeTags);
usertalkpage.setCreateOption('recreate');
// Different pref for RfD target notifications
if (params.venue === 'rfd' && targetNS !== 3) {
usertalkpage.setWatchlist(Twinkle.getPref('xfdWatchRelated'));
} else {
usertalkpage.setWatchlist(Twinkle.getPref('xfdWatchUser'));
}
usertalkpage.setFollowRedirect(true, false);
if (noLog) {
usertalkpage.append();
} else {
usertalkpage.append(function onNotifySuccess() {
// Don't treat RfD target or MfD userspace owner as initialContrib in log
if (!params.notifycreator) {
notifyTarget = null;
}
// add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, usernameOrTarget);
}, function onNotifyError() {
// if user could not be notified, log nomination without mentioning that notification was sent
Twinkle.xfd.callbacks.addToLog(params, null);
});
}
},
addToLog: function(params, initialContrib) {
if (!Twinkle.getPref('logXfdNominations') || Twinkle.getPref('noLogOnXfdNomination').indexOf(params.venue) !== -1) {
return;
}
var usl = new Morebits.userspaceLogger(Twinkle.getPref('xfdLogPageName'));// , 'Adding entry to userspace log');
usl.initialText =
"This is a log of all [[WP:XFD|deletion discussion]] nominations made by this user using [[WP:TW|Twinkle]]'s XfD module.\n\n" +
'If you no longer wish to keep this log, you can turn it off using the [[विकिपीडिया:Twinkle/Preferences|preferences panel]], and ' +
'nominate this page for speedy deletion under [[WP:CSD#U1|CSD U1]].' +
(Morebits.userIsSysop ? '\n\nThis log does not track XfD-related deletions made using Twinkle.' : '');
var editsummary = 'Logging ' + utils.toTLACase(params.venue) + ' nomination of [[:' + Morebits.pageNameNorm + ']].';
// If a logged file is deleted but exists on commons, the wikilink will be blue, so provide a link to the log
var fileLogLink = mw.config.get('wgNamespaceNumber') === 6 ? ' ([{{fullurl:Special:Log|page=' + mw.util.wikiUrlencode(mw.config.get('wgPageName')) + '}} log])' : '';
// CFD/S and RM don't have canonical links
var nominatedLink = params.discussionpage ? '[[' + params.discussionpage + '|nominated]]' : 'nominated';
var appendText = '# [[:' + Morebits.pageNameNorm + ']]:' + fileLogLink + ' ' + nominatedLink + ' at [[WP:' + params.venue.toUpperCase() + '|' + utils.toTLACase(params.venue) + ']]';
switch (params.venue) {
case 'tfd':
if (params.xfdcat === 'tfm') {
appendText += ' (merge)';
if (params.tfdtarget) {
var contentModel = mw.config.get('wgPageContentModel') === 'Scribunto' ? 'Module:' : 'Template:';
appendText += '; Other ' + contentModel.toLowerCase() + ' [[';
if (!new RegExp('^:?' + Morebits.namespaceRegex([10, 828]) + ':', 'i').test(params.tfdtarget)) {
appendText += contentModel;
}
appendText += params.tfdtarget + ']]';
}
}
break;
case 'mfd':
if (params.notifyuserspace && params.userspaceOwner && params.userspaceOwner !== initialContrib) {
appendText += '; {{user|1=' + params.userspaceOwner + '}} को सूचित किया';
}
break;
case 'cfd':
appendText += ' (' + utils.toTLACase(params.xfdcat) + ')';
if (params.cfdtarget) {
var categoryOrTemplate = params.xfdcat.charAt(0) === 's' ? 'साँचा:' : ':श्रेणी:';
appendText += '; ' + params.action + ' to [[' + categoryOrTemplate + params.cfdtarget + ']]';
if (params.xfdcat === 'cfs' && params.cfdtarget2) {
appendText += ', [[' + categoryOrTemplate + params.cfdtarget2 + ']]';
}
}
break;
case 'cfds':
appendText += ' (' + utils.toTLACase(params.xfdcat) + ')';
// Ensure there's more than just 'Category:'
if (params.cfdstarget && params.cfdstarget.length > 9) {
appendText += '; नया नाम: [[:' + params.cfdstarget + ']]';
}
break;
case 'rfd':
if (params.rfdtarget) {
appendText += '; लक्ष्यपृष्ठ: [[:' + params.rfdtarget + ']]';
if (params.relatedpage) {
appendText += ' (सूचित किया)';
}
}
break;
case 'rm':
if (params.rmtr) {
appendText += ' (तकनीकी)';
}
if (params.newname) {
appendText += '; नया नाम: [[:' + params.newname + ']]';
}
break;
default: // afd or ffd
break;
}
if (initialContrib && params.notifycreator) {
appendText += '; {{user|1=' + initialContrib + '}} को सूचित किया';
}
appendText += ' ~~~~~';
if (params.reason) {
appendText += "\n#* '''कारण''': " + Morebits.string.formatReasonForLog(params.reason);
}
usl.changeTags = Twinkle.changeTags;
usl.log(appendText, editsummary);
},
afd: {
main: function(apiobj) {
var response = apiobj.getResponse();
var titles = response.query.allpages;
// There has been no earlier entries with this prefix, just go on.
if (titles.length <= 0) {
apiobj.params.numbering = apiobj.params.number = '';
} else {
var number = 0;
for (var i = 0; i < titles.length; ++i) {
var title = titles[i].title;
// First, simple test, is there an instance with this exact name?
if (title === 'विकिपुस्तक:पृष्ठ हटाने हेतु चर्चा/लेख/' + Morebits.pageNameNorm) {
number = Math.max(number, 1);
continue;
}
var order_re = new RegExp('^' +
Morebits.string.escapeRegExp('विकिपुस्तक:पृष्ठ हटाने हेतु चर्चा/लेख/' + Morebits.pageNameNorm) +
'\\s*\\(\\s*(\\d+)(?:(?:वाँ|सरा|था) नामांकन)?)?\\s*\\)\\s*$');
var match = order_re.exec(title);
// No match; A non-good value
if (!match) {
continue;
}
// A match, set number to the max of current
number = Math.max(number, Number(match[1]));
}
apiobj.params.number = utils.num2order(parseInt(number, 10) + 1);
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' नामांकन)' : '';
}
apiobj.params.discussionpage = 'विकिपुस्तक:पृष्ठ हटाने हेतु चर्चा/लेख/' + Morebits.pageNameNorm + apiobj.params.numbering;
Morebits.status.info('नामांकन के क्रम में अगला चर्चा पृष्ठ है: ', '[[' + apiobj.params.discussionpage + ']]');
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = apiobj.params.discussionpage;
Morebits.wiki.actionCompleted.notice = 'नामांकन पूर्ण हुआ, चर्चा पृष्ठ खोला जा रहा';
// Tagging article
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'लेख पर नामांकन टैग जोड़ा जा रहा');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the article is moved, we would want to follow the redirect
wikipedia_page.setChangeTags(Twinkle.changeTags); // Here to apply to triage
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.afd.taggingArticle);
},
// Tagging needs to happen before everything else: this means we can check if there is an AfD tag already on the page
taggingArticle: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
if (!pageobj.exists()) {
statelem.error("ऐसा प्रतीत हो रहा कि पृष्ठ मौजूद नहीं है; हो सकता है इसे पहले ही हटाया जा चुका हो");
return;
}
// Check for existing AfD tag, for the benefit of new page patrollers
var textNoAfd = text.replace(/<!--.*AfD.*\n\{\{(?:Article for deletion\/dated|AfDM|हहेच लेख).*\}\}\n<!--.*(?:\n<!--.*)?AfD.*(?:\s*\n)?/g, '');
if (text !== textNoAfd) {
if (confirm('इस लेख पर पहले ही एक हहेच टैग लगा हुआ है। \nवर्तमान टैग को हटाकर दूसरा लगाने के लिए OK क्लिक करें (यह संस्तुत नहीं है, ऐसा न करें तो बेहतर होगा), अथवा नामांकन प्रकृया रद्द करने के लिए कैंसल दबायें')) {
text = textNoAfd;
} else {
statelem.error('लेख पहले से टैग था, आपने प्रकृया रद्द करना चुना');
window.location.reload();
return;
}
}
// Now we know we want to go ahead with it, trigger the other AJAX requests
// Mark the page as patrolled, if wanted
if (Twinkle.getPref('markXfdPagesAsPatrolled')) {
new Morebits.wiki.page(Morebits.pageNameNorm).patrol(); // Not "triage" as PageTriage extension is not installed here
}
// Start discussion page, will also handle pagetriage and delsort listings
var wikipedia_page = new Morebits.wiki.page(params.discussionpage, 'नामांकन चर्चा का पृष्ठ बनाया जा रहा');
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.afd.discussionPage);
// Today's list
var date = new Morebits.date(pageobj.getLoadTime());
wikipedia_page = new Morebits.wiki.page('विकिपुस्तक:लेख हटाने हेतु चर्चा/लॉग/' +
date.format('YYYY', 'utc'), "चर्चा को इस वर्ष के लॉग में जोड़ा जा रहा");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.afd.todaysList);
// Notification to first contributor
if (params.notifycreator) {
var thispage = new Morebits.wiki.page(mw.config.get('wgPageName'));
thispage.setCallbackParameters(params);
thispage.setLookupNonRedirectCreator(true); // Look for author of first non-redirect revision
thispage.lookupCreation(function(pageobj) {
Twinkle.xfd.callbacks.notifyUser(pageobj.getCallbackParameters(), pageobj.getCreator());
});
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
params.tagText = '{{हहेच लेख| कारण=' + params.reason + '| चर्चा_पृष्ठ= विकिपीडिया:पृष्ठ हटाने हेतु चर्चा/लेख/' + Morebits.pageNameNorm + '}}';
if (pageobj.canEdit()) {
// Remove some tags that should always be removed on AfD.
text = text.replace(/\{\{\s*(dated prod|dated prod blp|Prod blp\/dated|Proposed deletion\/dated|prod2|Proposed deletion endorsed|Userspace draft)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/ig, '');
// Then, test if there are speedy deletion-related templates on the article.
var textNoSd = text.replace(/\{\{\s*(db(-\w*)?|शीह(-\w*)?|हटायें|हटाएँ|delete|(?:hang|hold)[- ]?on)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/ig, '');
if (text !== textNoSd && confirm('लेख पर शीघ्र हटाने का टैग लगा हुआ है, क्या इसे हटा दिया जाय?')) {
text = textNoSd;
}
// Insert tag after short description or any hatnotes
var wikipage = new Morebits.wikitext.page(text);
text = wikipage.insertAfterTemplates(params.tagText, Twinkle.hatnoteRegex).getText();
pageobj.setPageText(text);
pageobj.setEditSummary('हटाने हेतु नामांकित; देखें [[:' + params.discussionpage + ']]');
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('nocreate');
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
discussionPage: function(pageobj) {
var params = pageobj.getCallbackParameters();
pageobj.setPageText(Twinkle.xfd.callbacks.getDiscussionWikitext('afd', params));
pageobj.setEditSummary('[[:' + Morebits.pageNameNorm + ']] को हटाने हेतु चर्चा पृष्ठ बनाया जा रहा');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('createonly');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
// Actions that should wait on the discussion page actually being created
// and whose errors shouldn't output the user rationale
// List at deletion sorting pages
//if (params.delsortCats) {
// params.delsortCats.forEach(function (cat) {
// var delsortPage = new Morebits.wiki.page('विकिपुस्तक:WikiProject Deletion sorting/' + cat, 'Adding to list of ' + cat + '-related deletion discussions');
// delsortPage.setFollowRedirect(true); // In case a category gets renamed
// delsortPage.setCallbackParameters({discussionPage: params.discussionpage});
// delsortPage.load(Twinkle.xfd.callbacks.afd.delsortListing);
// });
//}
});
},
todaysList: function(pageobj) {
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
var added_data = '{{subst:afd3|pg=' + Morebits.pageNameNorm + params.numbering + '}}\n';
var text;
// add date header if the log is found to be empty (a bot should do this automatically)
if (!pageobj.exists()) {
text = '{{subst:AfD log}}\n' + added_data;
} else {
var old_text = pageobj.getPageText() + '\n'; // MW strips trailing blanks, but we like them, so we add a fake one
text = old_text.replace(/(<!-- Add new entries to the TOP of the following list -->\n+)/, '$1' + added_data);
if (text === old_text) {
var linknode = document.createElement('a');
linknode.setAttribute('href', mw.util.getUrl('विकिपुस्तक:Twinkle/Fixing AFD') + '?action=purge');
linknode.appendChild(document.createTextNode('How to fix AFD'));
statelem.error([ 'चर्चा के लिए लक्ष्य स्थल नहीं मिला। इस त्रुटि को दूर करने के लिए कृपया ', linknode, ' देखें अथवा किसी प्रबंधक से संपर्क करें।' ]);
return;
}
}
pageobj.setPageText(text);
pageobj.setEditSummary('[[:' + params.discussionpage + ']] जोड़ा जा रहा');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchList'));
pageobj.setCreateOption('recreate');
pageobj.save();
},
delsortListing: function(pageobj) {
var discussionPage = pageobj.getCallbackParameters().discussionPage;
var text = pageobj.getPageText().replace('directly below this line -->', 'directly below this line -->\n{{' + discussionPage + '}}');
pageobj.setPageText(text);
pageobj.setEditSummary('[[:' + discussionPage + ']] को सूचीबद्ध किया जा रहा');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setCreateOption('nocreate');
pageobj.save();
}
},
tfd: {
main: function(pageobj) {
var params = pageobj.getCallbackParameters();
var date = new Morebits.date(pageobj.getLoadTime());
params.logpage = 'विकिपीडिया:Templates for discussion/Log/' + date.format('YYYY MMMM D', 'utc'),
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
// Add log/discussion page params to the already-loaded page object
pageobj.setCallbackParameters(params);
// Defined here rather than below to reduce duplication
var watchModule, watch_query;
if (params.scribunto) {
var watchPref = Twinkle.getPref('xfdWatchPage');
// action=watch has no way to rely on user
// preferences (T262912), so we do it manually.
// The watchdefault pref appears to reliably return '1' (string),
// but that's not consistent among prefs so might as well be "correct"
watchModule = watchPref !== 'no' && (watchPref !== 'default' || !!parseInt(mw.user.options.get('watchdefault'), 10));
if (watchModule) {
watch_query = {
action: 'watch',
titles: [ mw.config.get('wgPageName') ],
token: mw.user.tokens.get('watchToken')
};
// Only add the expiry if page is unwatched or already temporarily watched
if (pageobj.getWatched() !== true && watchPref !== 'default' && watchPref !== 'yes') {
watch_query.expiry = watchPref;
}
}
}
// Tagging template(s)/module(s)
if (params.xfdcat === 'tfm') { // Merge
var wikipedia_otherpage;
if (params.scribunto) {
wikipedia_otherpage = new Morebits.wiki.page(params.otherTemplateName + '/doc', 'Tagging other module documentation with merge tag');
// Watch tagged module pages as well
if (watchModule) {
watch_query.titles.push(params.otherTemplateName);
new Morebits.wiki.api('Adding Modules to watchlist', watch_query).post();
}
} else {
wikipedia_otherpage = new Morebits.wiki.page(params.otherTemplateName, 'Tagging other template with merge tag');
}
// Tag this template/module
Twinkle.xfd.callbacks.tfd.taggingTemplateForMerge(pageobj);
// Tag other template/module
wikipedia_otherpage.setFollowRedirect(true);
var otherParams = $.extend({}, params);
otherParams.otherTemplateName = Morebits.pageNameNorm;
wikipedia_otherpage.setCallbackParameters(otherParams);
wikipedia_otherpage.load(Twinkle.xfd.callbacks.tfd.taggingTemplateForMerge);
} else { // delete
if (params.scribunto && Twinkle.getPref('xfdWatchPage') !== 'no') {
// Watch tagged module page as well
if (watchModule) {
new Morebits.wiki.api('Adding Module to watchlist', watch_query).post();
}
}
Twinkle.xfd.callbacks.tfd.taggingTemplate(pageobj);
}
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to today's log";
// Adding discussion
var wikipedia_page = new Morebits.wiki.page(params.logpage, "Adding discussion to today's log");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.todaysList);
// Notification to first contributors
if (params.notifycreator) {
var involvedpages = [];
var seenusers = [];
involvedpages.push(new Morebits.wiki.page(mw.config.get('wgPageName')));
if (params.xfdcat === 'tfm') {
if (params.scribunto) {
involvedpages.push(new Morebits.wiki.page('Module:' + params.tfdtarget));
} else {
involvedpages.push(new Morebits.wiki.page('Template:' + params.tfdtarget));
}
}
involvedpages.forEach(function(page) {
page.setCallbackParameters(params);
page.lookupCreation(function(innerpage) {
var username = innerpage.getCreator();
if (seenusers.indexOf(username) === -1) {
seenusers.push(username);
// Only log once on merge nominations, for the initial template
Twinkle.xfd.callbacks.notifyUser(innerpage.getCallbackParameters(), username,
params.xfdcat === 'tfm' && innerpage.getPageName() !== Morebits.pageNameNorm);
}
});
});
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
// Notify developer(s) of script(s) that use(s) the nominated template
if (params.devpages) {
var inCategories = mw.config.get('wgCategories');
var categoryNotificationPageMap = {
'Templates used by Twinkle': 'Wikipedia talk:Twinkle',
'Templates used by AutoWikiBrowser': 'Wikipedia talk:AutoWikiBrowser',
'Templates used by RedWarn': 'Wikipedia talk:RedWarn'
};
$.each(categoryNotificationPageMap, function(category, page) {
if (inCategories.indexOf(category) !== -1) {
Twinkle.xfd.callbacks.notifyUser(params, page, true, 'Notifying ' + page + ' of template nomination');
}
});
}
},
taggingTemplate: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
params.tagText = '{{subst:template for discussion|help=off' + (params.templatetype !== 'standard' ? '|type=' + params.templatetype : '') + '}}';
if (pageobj.getContentModel() === 'sanitized-css') {
params.tagText = '/* ' + params.tagText + ' */';
} else {
if (params.noinclude) {
params.tagText = '<noinclude>' + params.tagText + '</noinclude>';
}
params.tagText += params.templatetype === 'standard' || params.templatetype === 'sidebar' ? '\n' : ''; // No newline for inline
}
if (pageobj.canEdit() && ['wikitext', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Nominated for deletion; see [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
if (params.scribunto) {
pageobj.setCreateOption('recreate'); // Module /doc might not exist
}
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
taggingTemplateForMerge: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
params.tagText = '{{subst:tfm|help=off|' + (params.templatetype !== 'standard' ? 'type=' + params.templatetype + '|' : '') +
'1=' + params.otherTemplateName.replace(new RegExp('^' + Morebits.namespaceRegex([10, 828]) + ':'), '') + '}}';
if (pageobj.getContentModel() === 'sanitized-css') {
params.tagText = '/* ' + params.tagText + ' */';
} else {
if (params.noinclude) {
params.tagText = '<noinclude>' + params.tagText + '</noinclude>';
}
params.tagText += params.templatetype === 'standard' || params.templatetype === 'sidebar' ? '\n' : ''; // No newline for inline
}
if (pageobj.canEdit() && ['wikitext', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Listed for merging with [[:' + params.otherTemplateName + ']]; see [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
if (params.scribunto) {
pageobj.setCreateOption('recreate'); // Module /doc might not exist
}
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
todaysList: function(pageobj) {
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
var added_data = Twinkle.xfd.callbacks.getDiscussionWikitext(params.xfdcat, params);
var text;
// add date header if the log is found to be empty (a bot should do this automatically)
if (!pageobj.exists()) {
text = '{{subst:TfD log}}\n' + added_data;
} else {
var old_text = pageobj.getPageText();
text = old_text.replace('-->', '-->\n' + added_data);
if (text === old_text) {
statelem.error('failed to find target spot for the discussion');
return;
}
}
pageobj.setPageText(text);
pageobj.setEditSummary('Adding ' + (params.xfdcat === 'tfd' ? 'deletion nomination' : 'merge listing') + ' of [[:' + Morebits.pageNameNorm + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
}
},
mfd: {
main: function(apiobj) {
var response = apiobj.getResponse();
var titles = response.query.allpages;
// There has been no earlier entries with this prefix, just go on.
if (titles.length <= 0) {
apiobj.params.numbering = apiobj.params.number = '';
} else {
var number = 0;
for (var i = 0; i < titles.length; ++i) {
var title = titles[i].title;
// First, simple test, is there an instance with this exact name?
if (title === 'विकिपीडिया:Miscellany for deletion/' + Morebits.pageNameNorm) {
number = Math.max(number, 1);
continue;
}
var order_re = new RegExp('^' +
Morebits.string.escapeRegExp('विकिपीडिया:Miscellany for deletion/' + Morebits.pageNameNorm) +
'\\s*\\(\\s*(\\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\\s*\\)\\s*$');
var match = order_re.exec(title);
// No match; A non-good value
if (!match) {
continue;
}
// A match, set number to the max of current
number = Math.max(number, Number(match[1]));
}
apiobj.params.number = utils.num2order(parseInt(number, 10) + 1);
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' nomination)' : '';
}
apiobj.params.discussionpage = 'विकिपीडिया:Miscellany for deletion/' + Morebits.pageNameNorm + apiobj.params.numbering;
apiobj.statelem.info('next in order is [[' + apiobj.params.discussionpage + ']]');
// Tagging page
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Tagging page with deletion tag');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.taggingPage);
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = apiobj.params.discussionpage;
Morebits.wiki.actionCompleted.notice = 'Nomination completed, now redirecting to the discussion page';
// Discussion page
wikipedia_page = new Morebits.wiki.page(apiobj.params.discussionpage, 'Creating deletion discussion page');
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.discussionPage);
// Today's list
wikipedia_page = new Morebits.wiki.page('विकिपीडिया:Miscellany for deletion', "Adding discussion to today's list");
wikipedia_page.setPageSection(2);
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.todaysList);
// Notification to first contributor and/or notification to owner of userspace
if (apiobj.params.notifycreator || apiobj.params.notifyuserspace) {
var thispage = new Morebits.wiki.page(mw.config.get('wgPageName'));
thispage.setCallbackParameters(apiobj.params);
thispage.lookupCreation(Twinkle.xfd.callbacks.mfd.sendNotifications);
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(apiobj.params, null);
}
},
taggingPage: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
params.tagText = '{{' + (params.number === '' ? 'mfd' : 'mfdx|' + params.number) + '|help=off}}';
if (['javascript', 'css', 'sanitized-css'].indexOf(mw.config.get('wgPageContentModel')) !== -1) {
params.tagText = '/* ' + params.tagText + ' */\n';
} else {
params.tagText += '\n';
if (params.noinclude) {
params.tagText = '<noinclude>' + params.tagText + '</noinclude>';
}
}
if (pageobj.canEdit() && ['wikitext', 'javascript', 'css', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Nominated for deletion; see [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('nocreate');
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
discussionPage: function(pageobj) {
var params = pageobj.getCallbackParameters();
pageobj.setPageText(Twinkle.xfd.callbacks.getDiscussionWikitext('mfd', params));
pageobj.setEditSummary('Creating deletion discussion page for [[:' + Morebits.pageNameNorm + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('createonly');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
todaysList: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
var date = new Morebits.date(pageobj.getLoadTime());
var date_header = date.format('===MMMM D, YYYY===\n', 'utc');
var date_header_regex = new RegExp(date.format('(===[\\s]*MMMM[\\s]+D,[\\s]+YYYY[\\s]*===)', 'utc'));
var added_data = '{{subst:mfd3|pg=' + Morebits.pageNameNorm + params.numbering + '}}';
if (date_header_regex.test(text)) { // we have a section already
statelem.info('Found today\'s section, proceeding to add new entry');
text = text.replace(date_header_regex, '$1\n' + added_data);
} else { // we need to create a new section
statelem.info('No section for today found, proceeding to create one');
text = text.replace('===', date_header + added_data + '\n\n===');
}
pageobj.setPageText(text);
pageobj.setEditSummary('Adding [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchList'));
pageobj.setCreateOption('recreate');
pageobj.save();
},
sendNotifications: function(pageobj) {
var initialContrib = pageobj.getCreator();
var params = pageobj.getCallbackParameters();
// Notify the creator
if (params.notifycreator) {
Twinkle.xfd.callbacks.notifyUser(params, initialContrib);
}
// Notify the user who owns the subpage if they are not the creator
params.userspaceOwner = mw.config.get('wgRelevantUserName');
if (params.notifyuserspace) {
if (params.userspaceOwner !== initialContrib) {
// Don't log if notifying creator above, will log then
Twinkle.xfd.callbacks.notifyUser(params, params.userspaceOwner, params.notifycreator, 'Notifying owner of userspace (' + params.userspaceOwner + ')');
} else if (!params.notifycreator) {
// If we thought we would notify the owner but didn't,
// then we need to log if we didn't notify the creator
// Twinkle.xfd.callbacks.addToLog(params, null);
Twinkle.xfd.callbacks.addToLog(params, initialContrib);
}
}
}
},
ffd: {
taggingImage: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var date = new Morebits.date(pageobj.getLoadTime()).format('YYYY MMMM D', 'utc');
params.logpage = 'विकिपीडिया:Files for discussion/' + date;
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
params.tagText = '{{ffd|log=' + date + '|help=off}}\n';
if (pageobj.canEdit()) {
text = text.replace(/\{\{(mtc|(copy |move )?to ?commons|move to wikimedia commons|copy to wikimedia commons)[^}]*\}\}/gi, '');
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Listed for discussion at [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('recreate'); // it might be possible for a file to exist without a description page
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = 'Nomination completed, now redirecting to the discussion page';
// Contributor specific edits
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.lookupCreation(Twinkle.xfd.callbacks.ffd.main);
},
main: function(pageobj) {
// this is coming in from lookupCreation...!
var params = pageobj.getCallbackParameters();
var initialContrib = pageobj.getCreator();
params.uploader = initialContrib;
// Adding discussion
var wikipedia_page = new Morebits.wiki.page(params.logpage, "Adding discussion to today's list");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.ffd.todaysList);
// Notification to first contributor
if (params.notifycreator) {
Twinkle.xfd.callbacks.notifyUser(params, initialContrib);
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
},
todaysList: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
// add date header if the log is found to be empty (a bot should do this automatically)
if (!pageobj.exists()) {
text = '{{subst:FfD log}}';
}
pageobj.setPageText(text + '\n\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('ffd', params));
pageobj.setEditSummary('Adding [[:' + Morebits.pageNameNorm + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
}
},
cfd: {
main: function(pageobj) {
var params = pageobj.getCallbackParameters();
var date = new Morebits.date(pageobj.getLoadTime());
params.logpage = 'विकिपीडिया:Categories for discussion/Log/' + date.format('YYYY MMMM D', 'utc');
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
// Add log/discussion page params to the already-loaded page object
pageobj.setCallbackParameters(params);
// Tagging category
Twinkle.xfd.callbacks.cfd.taggingCategory(pageobj);
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to today's log";
// Adding discussion to list
var wikipedia_page = new Morebits.wiki.page(params.logpage, "Adding discussion to today's list");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfd.todaysList);
// Notification to first contributor
if (params.notifycreator) {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.lookupCreation(function(pageobj) {
Twinkle.xfd.callbacks.notifyUser(pageobj.getCallbackParameters(), pageobj.getCreator());
});
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
},
taggingCategory: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
params.tagText = '{{subst:' + params.xfdcat;
var editsummary = (mw.config.get('wgNamespaceNumber') === 14 ? 'Category' : 'Stub template') +
' being considered for ' + params.action;
switch (params.xfdcat) {
case 'cfd':
case 'sfd-t':
break;
case 'cfc':
editsummary += ' to an article';
// falls through
case 'cfm':
case 'cfr':
case 'sfr-t':
params.tagText += '|' + params.cfdtarget;
break;
case 'cfs':
params.tagText += '|' + params.cfdtarget + '|' + params.cfdtarget2;
break;
default:
alert('twinklexfd in taggingCategory(): unknown CFD action');
break;
}
params.tagText += '}}\n';
editsummary += '; see [[:' + params.discussionpage + ']].';
if (pageobj.canEdit()) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary(editsummary);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
todaysList: function(pageobj) {
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
var added_data = Twinkle.xfd.callbacks.getDiscussionWikitext(params.xfdcat, params);
var text;
// add date header if the log is found to be empty (a bot should do this automatically)
if (!pageobj.exists()) {
text = '{{subst:CfD log}}\n' + added_data;
} else {
var old_text = pageobj.getPageText();
text = old_text.replace('below this line -->', 'below this line -->\n' + added_data);
if (text === old_text) {
statelem.error('failed to find target spot for the discussion');
return;
}
}
pageobj.setPageText(text);
pageobj.setEditSummary('Adding ' + params.action + ' nomination of [[:' + Morebits.pageNameNorm + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
}
},
cfds: {
taggingCategory: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
params.tagText = '{{subst:cfr-speedy|1=' + params.cfdstarget.replace(/^:?Category:/, '') + '}}\n';
if (pageobj.canEdit()) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Listed for speedy renaming; see [[WP:CFDS|Categories for discussion/Speedy]].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
pageobj.save(function() {
// No user notification for CfDS, so just add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
});
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
// No user notification for CfDS, so just add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
}
},
addToList: function(pageobj) {
var old_text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
var text = old_text.replace('BELOW THIS LINE -->', 'BELOW THIS LINE -->\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('cfds', params));
if (text === old_text) {
statelem.error('failed to find target spot for the discussion');
return;
}
pageobj.setPageText(text);
pageobj.setEditSummary('Adding [[:' + Morebits.pageNameNorm + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
}
},
rfd: {
// This gets called both on submit and preview to determine the redirect target
findTarget: function(params, callback) {
// Used by regular redirects to find the target, but for all redirects,
// avoid relying on the client clock to build the log page
var query = {
action: 'query',
curtimestamp: true,
format: 'json'
};
if (document.getElementById('softredirect')) {
// For soft redirects, define the target early
// to skip target checks in findTargetCallback
params.rfdtarget = document.getElementById('softredirect').textContent.replace(/^:+/, '');
} else {
// Find current target of redirect
query.titles = mw.config.get('wgPageName');
query.redirects = true;
}
var wikipedia_api = new Morebits.wiki.api('Finding target of redirect', query, Twinkle.xfd.callbacks.rfd.findTargetCallback(callback));
wikipedia_api.params = params;
wikipedia_api.post();
},
// This is a closure for the callback from the above API request, which gets the target of the redirect
findTargetCallback: function(callback) {
return function(apiobj) {
var response = apiobj.getResponse();
apiobj.params.curtimestamp = response.curtimestamp;
if (!apiobj.params.rfdtarget) { // Not a softredirect
var target = response.query.redirects && response.query.redirects[0].to;
if (!target) {
var message = 'No target found. this page does not appear to be a redirect, aborting';
if (mw.config.get('wgAction') === 'history') {
message += '. If this is a soft redirect, try again from the content page, not the page history.';
}
apiobj.statelem.error(message);
return;
}
apiobj.params.rfdtarget = target;
var section = response.query.redirects[0].tofragment;
apiobj.params.section = section;
}
callback(apiobj.params);
};
},
main: function(params) {
var date = new Morebits.date(params.curtimestamp);
params.logpage = 'विकिपीडिया:चर्चा हेतु पुनर्निर्देशन/लॉग/' + date.format('YYYY', 'utc');
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
// Tagging redirect
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'पुनर्निर्देशन पृष्ठ पर टैग जोड़ा जा रहा');
wikipedia_page.setFollowRedirect(false);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.rfd.taggingRedirect);
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = "नामांकन पूर्ण हुआ, लॉग पृष्ठ खोला जा रहा";
// Adding discussion
wikipedia_page = new Morebits.wiki.page(params.logpage, "चर्चा को लॉग में जोड़ा जा रहा");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.rfd.todaysList);
// Notifications
if (params.notifycreator || params.relatedpage) {
var thispage = new Morebits.wiki.page(mw.config.get('wgPageName'));
thispage.setCallbackParameters(params);
thispage.lookupCreation(Twinkle.xfd.callbacks.rfd.sendNotifications);
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
},
taggingRedirect: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
// Imperfect for edit request but so be it
params.tagText = '{{subst:rfd|' + (mw.config.get('wgNamespaceNumber') === 10 ? 'showontransclusion=1|' : '') + 'content=\n';
if (pageobj.canEdit()) {
pageobj.setPageText(params.tagText + text + '\n}}');
pageobj.setEditSummary('चर्चा को [[:' + params.discussionpage + ']] पर सूचीबद्ध किया जा रहा');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('nocreate');
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
todaysList: function(pageobj) {
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
var added_data = Twinkle.xfd.callbacks.getDiscussionWikitext('rfd', params);
var text;
// add date header if the log is found to be empty (a bot should do this automatically)
if (!pageobj.exists()) {
text = '{{subst:RfD log}}' + added_data;
} else {
var old_text = pageobj.getPageText();
text = old_text.replace(/(<!-- Add new entries directly below this line\.? -->)/, '$1\n' + added_data);
if (text === old_text) {
statelem.error('चर्चा के लिए लक्ष्यस्थल प्राप्त करने में विफल');
return;
}
}
pageobj.setPageText(text);
pageobj.setEditSummary('[[:' + Morebits.pageNameNorm + ']] जोड़ा जा रहा');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
sendNotifications: function(pageobj) {
var initialContrib = pageobj.getCreator();
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
// Notifying initial contributor
if (params.notifycreator) {
Twinkle.xfd.callbacks.notifyUser(params, initialContrib);
}
// Notifying target page's watchers, if not a soft redirect
if (params.relatedpage) {
var targetTalk = new mw.Title(params.rfdtarget).getTalkPage();
// On the offchance it's a circular redirect
if (params.rfdtarget === mw.config.get('wgPageName')) {
statelem.warn('Circular redirect; skipping target page notification');
} else if (document.getElementById('softredirect')) {
statelem.warn('Soft redirect; skipping target page notification');
// Don't issue if target talk is the initial contributor's talk or your own
} else if (targetTalk.getNamespaceId() === 3 && targetTalk.getNameText() === initialContrib) {
statelem.warn('Target is initial contributor; skipping target page notification');
} else if (targetTalk.getNamespaceId() === 3 && targetTalk.getNameText() === mw.config.get('wgUserName')) {
statelem.warn('You (' + mw.config.get('wgUserName') + ') are the target; skipping target page notification');
} else {
// Don't log if notifying creator above, will log then
Twinkle.xfd.callbacks.notifyUser(params, targetTalk.toText(), params.notifycreator, 'Notifying redirect target of the discussion');
return;
}
// If we thought we would notify the target but didn't,
// we need to log if we didn't notify the creator
if (!params.notifycreator) {
Twinkle.xfd.callbacks.addToLog(params, null);
}
}
}
},
rm: {
listAtTalk: function(pageobj) {
var params = pageobj.getCallbackParameters();
pageobj.setAppendText('\n\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('rm', params));
pageobj.setEditSummary('लेख ' + (params.newname ? ' का नाम बदल कर [[:' + params.newname + ']] करने हेतु अनुरोध' : 'का नाम बदलने हेतु अनुरोध'));
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setCreateOption('recreate'); // since the talk page need not exist
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.append(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
// add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
});
},
listAtRMTR: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
var hiddenCommentRE = /---- and enter on a new line.* -->/;
var newtext = text.replace(hiddenCommentRE, '$&\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('rm', params));
if (text === newtext) {
statelem.error('प्रविष्टि के लिए लक्ष्यस्थल प्राप्त करने में विफल');
return;
}
pageobj.setPageText(newtext);
pageobj.setEditSummary('[[:' + Morebits.pageNameNorm + ']] जोड़ा जा रहा');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
// add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
});
}
}
};
Twinkle.xfd.callback.evaluate = function(e) {
var form = e.target;
var params = Morebits.quickForm.getInputData(form);
Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.status.init(form);
Twinkle.xfd.currentRationale = params.reason;
Morebits.status.onError(Twinkle.xfd.printRationale);
var query, wikipedia_page, wikipedia_api;
switch (params.venue) {
case 'afd': // AFD
query = {
action: 'query',
list: 'allpages',
apprefix: 'पृष्ठ हटाने हेतु चर्चा/लेख/' + Morebits.pageNameNorm,
apnamespace: 4,
apfilterredir: 'nonredirects',
aplimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
format: 'json'
};
wikipedia_api = new Morebits.wiki.api('लेख पर हटाने का टैग जोड़ा जा रहा', query, Twinkle.xfd.callbacks.afd.main);
wikipedia_api.params = params;
wikipedia_api.post();
break;
case 'tfd': // TFD
if (params.tfdtarget) { // remove namespace name
params.tfdtarget = utils.stripNs(params.tfdtarget);
}
// Modules can't be tagged, TfD instructions are to place on /doc subpage
params.scribunto = mw.config.get('wgPageContentModel') === 'Scribunto';
if (params.xfdcat === 'tfm') { // Merge
// Tag this template/module
if (params.scribunto) {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName') + '/doc', 'मॉड्यूल के विवरण पृष्ठ पर विलय का टैग जोड़ा जा रहा');
params.otherTemplateName = 'Module:' + params.tfdtarget;
} else {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'साँचे पर विलय का टैग जोड़ा जा रहा');
params.otherTemplateName = 'साँचा:' + params.tfdtarget;
}
} else { // delete
if (params.scribunto) {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName') + '/doc', 'मॉड्यूल के विवरण पृष्ठ पर हटाने का टैग जोड़ा जा रहा');
} else {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'साँचे पर हटाने का टैग जोड़ा जा रहा ');
}
}
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.main);
break;
case 'mfd': // MFD
query = {
action: 'query',
list: 'allpages',
apprefix: 'पृष्ठ हटाने हेतु चर्चा/अन्य/' + Morebits.pageNameNorm,
apnamespace: 4,
apfilterredir: 'nonredirects',
aplimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
format: 'json'
};
wikipedia_api = new Morebits.wiki.api('पृष्ठ के पुराने हहेच नामांकनों के लिये खोज की जा रही है', query, Twinkle.xfd.callbacks.mfd.main);
wikipedia_api.params = params;
wikipedia_api.post();
break;
case 'ffd': // FFD
// Tagging file
// A little out of order with this coming before 'main',
// but tagging doesn't need the uploader parameter,
// while everything else does, so tag then get the uploader
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'फ़ाइल पृष्ठ पर हटाने का टैग जोड़ा जा रहा');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.ffd.taggingImage);
break;
case 'cfd':
if (params.cfdtarget) {
params.cfdtarget = utils.stripNs(params.cfdtarget);
} else {
params.cfdtarget = ''; // delete
}
if (params.cfdtarget2) { // split
params.cfdtarget2 = utils.stripNs(params.cfdtarget2);
}
// Used for customized actions in edit summaries and the notification template
var summaryActions = {
'cfd': 'हटाने',
'sfd-t': 'हटाने',
'cfm': 'विलय',
'cfr': 'नाम बदलाव',
'sfr-t': 'नाम बदलाव',
'cfs': 'द्विभाजन',
'cfc': 'परिवर्तित करने'
};
params.action = summaryActions[params.xfdcat];
// Tagging category
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'श्रेणी पर ' + params.action + ' का टैग जोड़ा जा रहा');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfd.main);
break;
case 'rfd':
// find target and pass main as the callback
Twinkle.xfd.callbacks.rfd.findTarget(params, Twinkle.xfd.callbacks.rfd.main);
break;
case 'rm':
var nomPageName = params.rmtr ?
'विकिपीडिया:स्थानांतरण अनुरोध/तकनीकी अनुरोध' :
new mw.Title(Morebits.pageNameNorm).getTalkPage().toText();
Morebits.wiki.actionCompleted.redirect = nomPageName;
Morebits.wiki.actionCompleted.notice = 'नामांकन पूर्ण हुआ, चर्चा पृष्ठ खोला जा रहा है';
wikipedia_page = new Morebits.wiki.page(nomPageName, params.rmtr ? 'Adding entry at WP:RM/TR' : 'वार्ता पृष्ठ पर प्रविष्टि दर्ज की जा रही');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
if (params.rmtr) {
wikipedia_page.setPageSection(2);
wikipedia_page.load(Twinkle.xfd.callbacks.rm.listAtRMTR);
} else {
// listAtTalk uses .append(), so no need to load the page
Twinkle.xfd.callbacks.rm.listAtTalk(wikipedia_page);
}
break;
default:
alert('twinklexfd: unknown XFD discussion venue');
break;
}
};
Twinkle.addInitCallback(Twinkle.xfd, 'xfd');
})(jQuery);
// </nowiki>