मीडियाविकि:Gadget-twinklespeedy.js

सूचना: यह पृष्ठ सुरक्षित करने बाद, परिवर्तनों को देखने लिए ब्राउज़र का कैश ख़ाली करने की आवश्यकता हो सकती है।

  • मोज़िला / फ़ायरफ़ॉक्स / सफ़ारी: shift hold करें जब आप reload क्लिक करते है, या Ctrl-Shift-R (अपल मैक में Cmd-Shift-R) दबाएँ;
  • गूगल क्रोम: Ctrl-shift-R (मैक में Cmd-Shift-R) दबाएँ
  • इंटरनेट एक्सप्लोरर: Ctrl hold करें जब आप refresh क्लिक करते हैं, या Ctrl-F5 क्लिक करते हैं;
  • कॉङ्करर: सिर्फ़ Reload बटन पर क्लिक करें, या F5 क्लिक करें;
  • ऑपरा सदस्य को Tools→Preferences में सम्पूर्ण कैश ख़ाली करने की ज़रूरत हो सकती है।
//<nowiki>


(function($) {


/*
 ****************************************
 *** twinklespeedy.js: CSD module
 ****************************************
 * Mode of invocation:     Tab ("शीह")
 * Active on:              Non-special, existing pages
 *
 * NOTE FOR DEVELOPERS:
 *   If adding a new criterion, add it to the appropriate places at the top of
 *   twinkleconfig.js.  Also check out the default values of the CSD preferences
 *   in twinkle.js, and add your new criterion to those if you think it would be
 *   good.
 */

Twinkle.speedy = function twinklespeedy() {
	// Disable on:
	// * special pages
	// * non-existent pages
	if (mw.config.get('wgNamespaceNumber') < 0 || !mw.config.get('wgArticleId')) {
		return;
	}

	Twinkle.addPortletLink(Twinkle.speedy.callback, 'शीह', 'tw-csd', Morebits.userIsSysop ? 'वि:शीह अनुसार पृष्ठ हटायें' : 'वि:शीह अनुसार पृष्ठ हटाने का अनुरोध करें');
};

// This function is run when the CSD tab/header link is clicked
Twinkle.speedy.callback = function twinklespeedyCallback() {
	Twinkle.speedy.initDialog(Morebits.userIsSysop ? Twinkle.speedy.callback.evaluateSysop : Twinkle.speedy.callback.evaluateUser, true);
};

// Used by unlink feature
Twinkle.speedy.dialog = null;
// Used throughout
Twinkle.speedy.hasCSD = !!$('#delete-reason').length;

// Prepares the speedy deletion dialog and displays it
Twinkle.speedy.initDialog = function twinklespeedyInitDialog(callbackfunc) {
	var dialog;
	Twinkle.speedy.dialog = new Morebits.simpleWindow(Twinkle.getPref('speedyWindowWidth'), Twinkle.getPref('speedyWindowHeight'));
	dialog = Twinkle.speedy.dialog;
	dialog.setTitle('शीघ्र हटाने का एक मापदंड चुनें');
	dialog.setScriptName('ट्विंकल');
	dialog.addFooterLink('शीघ्र हटाने की नीति', 'वि:शीह');
	dialog.addFooterLink('शीह वरीयताएँ', 'वि:ट्विंकल/वरीयताएँ#शीह');
	dialog.addFooterLink('ट्विंकल सहायता', 'वि:ट्विंकल/विवरण#शीह');
	dialog.addFooterLink('फीडबैक दें', 'विवा:ट्विंकल');

	var form = new Morebits.quickForm(callbackfunc, Twinkle.getPref('speedySelectionStyle') === 'radioClick' ? 'change' : null);
	if (Morebits.userIsSysop) {
		form.append({
			type: 'checkbox',
			list: [
				{
					label: 'केवल टैग जोड़ें, हटाएँ नहीं',
					value: 'tag_only',
					name: 'tag_only',
					tooltip: 'यदि आप पृष्ठ को केवल टैग करना चाहते/चाहती हैं, अभी तत्काल स्वयं हटाना नहीं चाहते/चाहतीं',
					checked: !(Twinkle.speedy.hasCSD || Twinkle.getPref('deleteSysopDefaultToDelete')),
					event: function(event) {
						var cForm = event.target.form;
						var cChecked = event.target.checked;
						// enable talk page checkbox
						if (cForm.talkpage) {
							cForm.talkpage.checked = !cChecked && Twinkle.getPref('deleteTalkPageOnDelete');
						}
						// enable redirects checkbox
						cForm.redirects.checked = !cChecked;
						// enable delete multiple
						cForm.delmultiple.checked = false;
						// enable notify checkbox
						cForm.notify.checked = cChecked;
						// enable deletion notification checkbox
						cForm.warnusertalk.checked = !cChecked && !Twinkle.speedy.hasCSD;
						// enable multiple
						cForm.multiple.checked = false;
						// enable requesting creation protection
						cForm.salting.checked = false;

						Twinkle.speedy.callback.modeChanged(cForm);

						event.stopPropagation();
					}
				}
			]
		});

		var deleteOptions = form.append({
			type: 'div',
			name: 'delete_options'
		});
		deleteOptions.append({
			type: 'header',
			label: 'हटाने-संबंधी विकल्प'
		});
		if (mw.config.get('wgNamespaceNumber') % 2 === 0 && (mw.config.get('wgNamespaceNumber') !== 2 || (/\//).test(mw.config.get('wgTitle')))) {  // hide option for user pages, to avoid accidentally deleting user talk page
			deleteOptions.append({
				type: 'checkbox',
				list: [
					{
						label: 'वार्ता पृष्ठ भी हटायें',
						value: 'talkpage',
						name: 'talkpage',
						tooltip: "यह विकल्प पृष्ठ के वार्ता पृष्ठ को भी हटा देगा।",
						checked: Twinkle.getPref('deleteTalkPageOnDelete'),
						event: function(event) {
							event.stopPropagation();
						}
					}
				]
			});
		}
		deleteOptions.append({
			type: 'checkbox',
			list: [
				{
					label: 'सभी पुनर्निर्देश भी हटायें',
					value: 'redirects',
					name: 'redirects',
					tooltip: 'यह विकल्प चुनने पर यहाँ पुनर्निर्देशित पृष्ठ भी हटा दिये जायेंगे। कुछ प्रोसीज़र(जैसे: स्थानांतरण/विलय) आदि की दशाओं में पृष्ठ हटाते समय इस विकल्प को चुनने से बचें।',
					checked: Twinkle.getPref('deleteRedirectsOnDelete'),
					event: function (event) {
						event.stopPropagation();
					}
				},
				{
					label: 'कई मापदंडों के साथ हटायें',
					value: 'delmultiple',
					name: 'delmultiple',
					tooltip: 'यह विकल्प चुनने पर आप कई मापदंडों के तहत पृष्ठ को हटा सकते हैं। ',
					event: function(event) {
						Twinkle.speedy.callback.modeChanged(event.target.form);
						event.stopPropagation();
					}
				},
				{
					label: 'पृष्ठ निर्माता को पृष्ठ के हटाये जाने की सूचना भेजें',
					value: 'warnusertalk',
					name: 'warnusertalk',
					tooltip: 'निर्माता के वार्ता पन्ने पर एक सूचना साँचा जोड़ दिया जायेगा, अगर आपने अपनी वरीयताओं में सूचना भेजने का विकल्प सक्रिय रखा होगा ' +
						'और  यदि आपने स्वागत का विकल्प भी चुना होगा और साथ ही यह विकल्प चेक हो तब निर्माता का स्वागत भी किया जायेगा।',
					false: !Twinkle.speedy.hasCSD,
					event: function(event) {
						event.stopPropagation();
					}
				}
			]
		});
	}

	var tagOptions = form.append({
		type: 'div',
		name: 'tag_options'
	});

	if (Morebits.userIsSysop) {
		tagOptions.append({
			type: 'header',
			label: 'टैग-जोड़ने-संबंधी विकल्प'
		});
	}

	tagOptions.append({
		type: 'checkbox',
		list: [
			{
				label: 'अगर संभव हो तो पृष्ठ निर्माता को सूचित करें',
				value: 'notify',
				name: 'notify',
				tooltip: 'निर्माता के वार्ता पन्ने पर एक सूचना साँचा जोड़ दिया जायेगा, अगर आपने अपनी वरीयताओं में सूचना भेजने का विकल्प सक्रिय रखा होगा ' +
						'और  यदि आपने स्वागत का विकल्प भी चुना होगा और साथ ही यह विकल्प चेक हो तब निर्माता का स्वागत भी किया जायेगा। आइपी द्वारा बनाए पृष्ठों अथवा स्वयं आपके ही द्वारा बनाये गये पृष्ठों पर कोई सूचना नहीं भेजी जायेगी।',
				checked: !Morebits.userIsSysop || !(Twinkle.speedy.hasCSD || Twinkle.getPref('deleteSysopDefaultToDelete')),
				event: function(event) {
					event.stopPropagation();
				}
			},
			{
				label: 'पृष्ठ निर्माण करने से सुरक्षित करने का अनुरोध भी करें',
				value: 'salting',
				name: 'salting',
				tooltip: 'अगर पृष्ठ को भविष्य में पुनः निर्मित करने से रोकना हो तो यह विकल्प चुनने पर निर्माण-सुरक्षित करने का अनुरोध भी भेजा जायेगा; यह तभी चुनें जब पृष्ठ हटाने के बावज़ूद बारंबार पुनःनिर्मित किया जा रहा हो।',
				event: function(event) {
					event.stopPropagation();
				}
			},
			{
				label: 'कई मापदंडों के साथ टैग करें',
				value: 'multiple',
				name: 'multiple',
				tooltip: 'यह विकल्प चुनने पर आप एक साथ कई मापदंडों के साथ हटाने का टैग जोड़ सकते हैं; कृपया सावधानी पूर्वक टैग चुनें।',
				event: function(event) {
					Twinkle.speedy.callback.modeChanged(event.target.form);
					event.stopPropagation();
				}
			}
		]
	});

	form.append({
		type: 'div',
		id: 'prior-deletion-count',
		style: 'font-style: italic'
	});

	form.append({
		type: 'div',
		name: 'work_area',
		label: 'शीह मॉड्यूल सक्रिय होने में विफल रहा। कृपया दुबारा प्रयास करें, अथवा ट्विंकल के रखरखाव करने वाले सदस्यों को सूचित करें।'
	});

	if (Twinkle.getPref('speedySelectionStyle') !== 'radioClick') {
		form.append({ type: 'submit', className: 'tw-speedy-submit' }); // Renamed in modeChanged
	}

	var result = form.render();
	dialog.setContent(result);
	dialog.display();

	Twinkle.speedy.callback.modeChanged(result);

	// Check for prior deletions.  Just once, upon init
	Twinkle.speedy.callback.priorDeletionCount();
};

Twinkle.speedy.callback.modeChanged = function twinklespeedyCallbackModeChanged(form) {
	var namespace = mw.config.get('wgNamespaceNumber');

	// first figure out what mode we're in
	var mode = {
		isSysop: !!form.tag_only && !form.tag_only.checked,
		isMultiple: form.tag_only && !form.tag_only.checked ? form.delmultiple.checked : form.multiple.checked,
		isRadioClick: Twinkle.getPref('speedySelectionStyle') === 'radioClick'
	};

	if (mode.isSysop) {
		$('[name=delete_options]').show();
		$('[name=tag_options]').hide();
		$('button.tw-speedy-submit').text('पृष्ठ हटायें');
	} else {
		$('[name=delete_options]').hide();
		$('[name=tag_options]').show();
		$('button.tw-speedy-submit').text('टैग जोड़ें');
	}

	var work_area = new Morebits.quickForm.element({
		type: 'div',
		name: 'work_area'
	});

	if (mode.isMultiple && mode.isRadioClick) {
		var evaluateType = mode.isSysop ? 'evaluateSysop' : 'evaluateUser';

		work_area.append({
			type: 'div',
			label: 'जब आप मापदंड चुन लें, क्लिक करें:'
		});
		work_area.append({
			type: 'button',
			name: 'submit-multiple',
			label: mode.isSysop ? 'पृष्ठ हटायें' : 'टैग जोड़ें',
			event: function(event) {
				Twinkle.speedy.callback[evaluateType](event);
				event.stopPropagation();
			}
		});
	}

	var appendList = function(headerLabel, csdList) {
		work_area.append({ type: 'header', label: headerLabel });
		work_area.append({ type: mode.isMultiple ? 'checkbox' : 'radio', name: 'csd', list: Twinkle.speedy.generateCsdList(csdList, mode) });
	};

	if (mode.isSysop && !mode.isMultiple) {
		appendList('हटाने हेतु आपका वैयक्तिक/विशिष्ट तर्क', Twinkle.speedy.customRationale);
	}

	if (!Morebits.isPageRedirect()) {
		switch (namespace) {
			case 0:  // article
			case 1:  // talk
				appendList('लेखों हेतु', Twinkle.speedy.articleList);
				break;

			case 2:  // user
			case 3:  // user talk
				appendList('सदस्य पृष्ठों हेतु', Twinkle.speedy.userList);
				break;

			case 6:  // file
			case 7:  // file talk
				appendList('फाइलों हेतु', Twinkle.speedy.fileList);
				if (!mode.isSysop) {
					work_area.append({ type: 'div', label: 'कुछ फ़ाइलों के स्थानीय पृष्ठ व2:परीक्षण, व3:धोखा अथवा अन्य आम कारणों के तहत भी हटाये जा सकते हैं। कृपया सबसे बेहतर औचित्य चुनें।' });
				}
				break;

			default:
				break;
		}
	} else {
		if (namespace === 2 || namespace === 3) {
			appendList('सदस्य पृष्ठों हेतु', Twinkle.speedy.userList);
		}
		appendList('पुनर्निर्देशनों हेतु', Twinkle.speedy.redirectList);
	}

	var generalCriteria = Twinkle.speedy.generalList;

	// custom rationale lives under general criteria when tagging
	if (!mode.isSysop) {
		generalCriteria = Twinkle.speedy.customRationale.concat(generalCriteria);
	}
	appendList('आम कारण', generalCriteria);

	var old_area = Morebits.quickForm.getElements(form, 'work_area')[0];
	form.replaceChild(work_area.render(), old_area);

	// if sysop, check if CSD is already on the page and fill in custom rationale
	if (mode.isSysop && Twinkle.speedy.hasCSD) {
		var customOption = $('input[name=csd][value=reason]')[0];
		if (customOption) {
			if (Twinkle.getPref('speedySelectionStyle') !== 'radioClick') {
				// force listeners to re-init
				customOption.click();
				customOption.parentNode.appendChild(customOption.subgroup);
			}
			customOption.subgroup.querySelector('input').value = decodeURIComponent($('#delete-reason').text()).replace(/\+/g, ' ');
		}
	}
};

Twinkle.speedy.callback.priorDeletionCount = function () {
	var query = {
		action: 'query',
		format: 'json',
		list: 'logevents',
		letype: 'delete',
		leaction: 'delete/delete', // Just pure page deletion, no redirect overwrites or revdel
		letitle: mw.config.get('wgPageName'),
		leprop: '', // We're just counting we don't actually care about the entries
		lelimit: 5  // A little bit goes a long way
	};

	new Morebits.wiki.api('पहले कितनी बार हटाया जा चुका यह जाँचा जा रहा', query, function(apiobj) {
		var response = apiobj.getResponse();
		var delCount = response.query.logevents.length;
		if (delCount) {
			var message = delCount + ' बार पहले भी हटाया जा चुका';
			if (delCount > 1) {
				message += '';
				if (response.continue) {
					message = message + ' या और भी अधिक बार हटाया जा चुका';
				}

				// 3+ seems problematic
				if (delCount >= 3) {
					$('#prior-deletion-count').css('color', 'red');
				}
			}

			// Provide a link to page logs (CSD templates have one for sysops)
			var link = Morebits.htmlNode('a', '(logs)');
			link.setAttribute('href', mw.util.getUrl('विशेष:लॉग', {page: mw.config.get('wgPageName')}));
			link.setAttribute('target', '_blank');

			$('#prior-deletion-count').text(message + ' '); // Space before log link
			$('#prior-deletion-count').append(link);
		}
	}).post();
};


Twinkle.speedy.generateCsdList = function twinklespeedyGenerateCsdList(list, mode) {

	var pageNamespace = mw.config.get('wgNamespaceNumber');

	var openSubgroupHandler = function(e) {
		$(e.target.form).find('input').prop('disabled', true);
		$(e.target.form).children().css('color', 'gray');
		$(e.target).parent().css('color', 'black').find('input').prop('disabled', false);
		$(e.target).parent().find('input:text')[0].focus();
		e.stopPropagation();
	};
	var submitSubgroupHandler = function(e) {
		var evaluateType = mode.isSysop ? 'evaluateSysop' : 'evaluateUser';
		Twinkle.speedy.callback[evaluateType](e);
		e.stopPropagation();
	};

	return $.map(list, function(critElement) {
		var criterion = $.extend({}, critElement);

		if (mode.isMultiple) {
			if (criterion.hideWhenMultiple) {
				return null;
			}
			if (criterion.hideSubgroupWhenMultiple) {
				criterion.subgroup = null;
			}
		} else {
			if (criterion.hideWhenSingle) {
				return null;
			}
			if (criterion.hideSubgroupWhenSingle) {
				criterion.subgroup = null;
			}
		}

		if (mode.isSysop) {
			if (criterion.hideWhenSysop) {
				return null;
			}
			if (criterion.hideSubgroupWhenSysop) {
				criterion.subgroup = null;
			}
		} else {
			if (criterion.hideWhenUser) {
				return null;
			}
			if (criterion.hideSubgroupWhenUser) {
				criterion.subgroup = null;
			}
		}

		if (Morebits.isPageRedirect() && criterion.hideWhenRedirect) {
			return null;
		}

		if (criterion.showInNamespaces && criterion.showInNamespaces.indexOf(pageNamespace) < 0) {
			return null;
		}
		if (criterion.hideInNamespaces && criterion.hideInNamespaces.indexOf(pageNamespace) > -1) {
			return null;
		}

		if (criterion.subgroup && !mode.isMultiple && mode.isRadioClick) {
			if (Array.isArray(criterion.subgroup)) {
				criterion.subgroup = criterion.subgroup.concat({
					type: 'button',
					name: 'submit',
					label: mode.isSysop ? 'पृष्ठ हटायें' : 'टैग जोड़ें',
					event: submitSubgroupHandler
				});
			} else {
				criterion.subgroup = [
					criterion.subgroup,
					{
						type: 'button',
						name: 'submit',  // ends up being called "csd.submit" so this is OK
						label: mode.isSysop ? 'पृष्ठ हटायें' : 'टैग जोड़ें',
						event: submitSubgroupHandler
					}
				];
			}
			// FIXME: does this do anything?
			criterion.event = openSubgroupHandler;
		}

		return criterion;
	});
};

Twinkle.speedy.customRationale = [
	{
		label: 'आपका दिया गया कारण' + (Morebits.userIsSysop ? ' (किंतु यह भी कारण मापदंड अनुसार ही होना चाहिये)' : ' {{शीह-कारण}} साँचे का प्रयोग करते हुये'),
		value: 'reason',
		tooltip: 'कृपया ध्यान दें कि यह कारण मनमाना निर्मित नहीं होना चाहिये, कोई-न-कोई शीह मापदंड अवश्य लागू होना चाहिए और आपको उसका उल्लेख भी करना होगा, आप बस उसकी व्याख्या अपने शब्दों में लिख सकते अगर आपको ऐसा लगता है कि सीधे दिये गए विकल्पों में से कोई मापदंड चुनने पर उसका लागू होना स्पष्ट नहीं हो पा रहा है। कोई मापदंड भी लागू नहीं हो पा रहा इसलिए यह विकल्प न चुनें कि अपनी मर्जी से कारण बता दें।',
		subgroup: {
			name: 'reason_1',
			type: 'input',
			label: 'कारण/तर्क:',
			size: 60
		},
		hideWhenMultiple: true
	}
];

Twinkle.speedy.fileList = [
	{
		label: 'फ़1: 14 दिनों  (2 सप्ताह) से अधिक समय तक कोई लाइसेंस न होना',
		value: 'license',
		tooltip: 'इसमें वे सभी फाइलें आती हैं जिनमें अपलोड होने से दो सप्ताह के बाद तक भी कोई लाइसेंस नहीं दिया गया है।',
	},
	{
		label: 'फ़2: विकिमीडिया कॉमन्स पर स्रोत और लाइसेंस जानकारी सहित उपलब्ध होना',
		value: 'commons',
		tooltip: 'फ़ाइल का विकिमीडिया कॉमन्स पर स्रोत और लाइसेंस जानकारी सहित उपलब्ध होना तथा 1: The file format of both images is the same. 2: The file\'s license and source status is beyond reasonable doubt, and the license is undoubtedly accepted at Commons. 3: All information on the file description page is present on the Commons file description page. That includes the complete upload history with links to the uploader\'s local user pages. 4: The file is not protected, and the file description page does not contain a request not to move it to Commons. 5: If the file is available on Commons under a different name than locally, all local references to the file must be updated to point to the title used at Commons. 6: For {{c-uploaded}} files: They may be speedily deleted as soon as they are off the Main Page',
		subgroup: {
			name: 'commons_filename',
			type: 'input',
			label: 'कॉमंस पर फ़ाइल का नाम (अगर ठीक इसी नाम से हो, बॉक्स को ख़ाली छोड़ दें):',
			tooltip: 'अगर ठीक उसी नाम से उपलब्ध हो तो इसे ख़ाली भी छोड़ा जा सकता है, अन्यथा कॉमंस की फ़ाइल का नाम लिखें और उसमें "चित्र:" या "File:" जैसे उपसर्ग न रखें। '
		},
		hideWhenMultiple: true
	},
	{
		label: 'फ़3: अप्रयुक्त ग़ैर-मुक्त उचित-उपयोग फ़ाइल',
		value: 'unused',
		tooltip: 'इस मापदंड के अंतर्गत वे फ़ाइलें आती हैं जो कॉपीराइट सुरक्षित हैं और उचित उपयोग हेतु विकिपीडिया पर डाली गई हैं, परंतु जिनका कोई उपयोग न किया जा रहा है और न ही होने की संभावना है।',
		hideWhenUser: true
	},
	{
		label: 'फ़4: ग़ैर मुक्त उचित उपयोग उपयोग फ़ाइल जिसपर कोई उचित उपयोग औचित्य न दिया हो',
		value: 'norat',
		tooltip: '"No fair use rationale" अर्थात, फ़ाइल ग़ैर-मुक्त है और उचित उपयोग हेतु रखी गयी है पर इस उपयोग का औचित्य नहीं दिया गया है। इन्हें अपलोड के 7 दिनों के बाद कभी भी इस मापदंड के तहत हटाया जा सकता है। ',
		hideWhenUser: true
	},
	{
		label: 'फ़5: ग़ैर मुक्त फ़ाइलें जिनका मुक्त विकल्प उपलब्ध हो',
		value: 'freealt',
		tooltip: 'इस मापदंड के अंतर्गत वे फ़ाइलें आती हैं जो ग़ैर मुक्त हैं और जिनका कोई मुक्त विकल्प उपलब्ध है। यह आवश्यक नहीं कि मुक्त विकल्प हूबहू वही फ़ाइल हो।',
		subgroup: {
			name: 'freealt_filename',
			type: 'input',
			label: 'मुक्त-विकल्प फ़ाइल का नाम:',
			tooltip: 'कॉमंस की फ़ाइल का नाम लिखें और उसमें "चित्र:" या "File:" जैसे उपसर्ग न रखें।',
			size: 60
		},
		hideWhenMultiple: true
	},
	{
		label: 'व6फ़: कॉपीराइट उल्लंघन चित्र',
		value: 'imgcopyvio',
		tooltip: 'ऐसी जगह से लिया गया चित्र जहाँ वह मुक्त लाइसेंस के तहत अथवा विकिपीडिया पर उपयोग के लिए उचित लाइसेंस के साथ मौज़ूद नहीं है।',
		subgroup: [
			{
				name: 'imgcopyvio_url',
				type: 'input',
				label: 'पूरा  यूआरएल "http://" के साथ। अगर चित्र इंटरनेट पर नहीं है तो नीचे के बॉक्स में कारण सुर स्रोत लिखें।',
				size: 60
			},
			{
				name: 'imgcopyvio_rationale',
				type: 'input',
				label: 'गैर-इंटरनेट फ़ाइल के लिए कारण एवं स्पष्टीकरण:',
				size: 60
			}
		]
	},
	{
		label: 'फ़6: फ़ालतू गैर-मीडिया फ़ाइल',
		value: 'badfiletype',
		tooltip: 'वे फ़ाइलें आती हैं जिनका कोई प्रयोग नहीं हो रहा है और जिनका कोई ज्ञानकोशीय प्रयोग नहीं किया जा सकता है। इसमें चित्र, ध्वनियाँ एवं वीडियो फ़ाइलें नहीं आती हैं। (जैसे: .doc, .pdf, or .xls files) जिनका कोई ज्ञानकोशीय इस्तेमाल नहीं हो सकता।'
	}
];

Twinkle.speedy.articleList = [
	{
		label: 'ल1: पूर्णतया अन्य भाषा में लिखे लेख',
		value: 'foreign',
		tooltip: 'इसमें वे लेख आते हैं जो पूर्णतया हिन्दी के अलावा किसी और भाषा में लिखे हुए हैं, चाहे उनका नाम हिन्दी में हो या किसी और भाषा में।'
	},
	{
		label: 'ल2: साफ़ प्रचार',
		value: 'promo',
		tooltip: 'जब लेख किसी व्यक्ति, वस्तु, उत्पाद, विचारधारा इत्यादि का साफ़ तौर पर प्रचार अथवा प्रोमोशन कर रहा हो। इसमें पेड लेख, निजी-रुचि के तहत बनाये लेख, स्पैम के लिए बनाए गए लेख शामिल हैं।',
	},
	{
		label: 'ल4: प्रतिलिपि लेख',
		value: 'duplicate',
		tooltip: 'इस मापदंड के अंतर्गत वो लेख आते हैं जो किसी पुराने लेख की प्रतिलिपि हैं। इसमें वे लेख भी आते हैं जो किसी ऐसे विषय पर बनाए गए हैं जिनपर पहले से लेख मौजूद है और पुराना लेख नए लेख से बेहतर है।',
		subgroup: {
			name: 'duplicate_pagename',
			type: 'input',
			label: 'मूल लेख:',
			tooltip: 'मूल पुराने लेख का नाम जिसकी प्रतिलिपि यह लेख है (बिना विकिकड़ी बनाये)'
		}
	},
	{
		label: 'ल5: ख़राब अनुवाद',
		value: 'badtrans',
		tooltip: 'इस मापदंड के अंतर्गत वो लेख आते हैं जो किसी अन्य भाषा के लेख का अत्यधिक खराब मशीनी अनुवाद हैं और इन्हें सुधारने की बजाय हटा कर दुबारा लिखना उचित होगा।'
	}
];

Twinkle.speedy.userList = [
	{
		label: 'स1: सदस्य अनुरोध',
		value: 'userreq',
		tooltip: 'Personal subpages, upon request by their user. In some rare cases there may be administrative need to retain the page. Also, sometimes, main user pages may be deleted as well. See Wikipedia:User page for full instructions and guidelines',
		subgroup: mw.config.get('wgNamespaceNumber') === 3 && mw.config.get('wgTitle').indexOf('/') === -1 ? {
			name: 'userreq_rationale',
			type: 'input',
			label: 'एक कारण अवश्य चाहिये कि यह पृष्ठ हटा दिया जाय क्योंकि:',
			tooltip: 'सदस्य वार्ता पन्ना बहुत ही दुर्लभ दशाओं में ही हटाया जा सकता है, कृपया इसके लिए मनमर्जी से नामांकन न करें।',
			size: 60
		} : null,
		hideSubgroupWhenMultiple: true
	},
	{
		label: 'स2: अस्तित्वहीन सदस्यों के सदस्य पृष्ठ अथवा उपपृष्ठ',
		value: 'nouser',
		tooltip: 'ऐसे सदस्यों के पृष्ठ, वार्ता पृष्ठ अथवा उपपृष्ठ जो विकिपीडिया पर पंजीकृत नहीं हैं, इस मापदंड के अंतर्गत शाघ्र हटाए जा सकते हैं।'
	},
	{
		label: 'स3: वेब होस्ट के रूप में विकिपीडिया का स्पष्ट दुरुपयोग',
		value: 'notwebhost',
		tooltip: 'सदस्य नामस्थान में बने ऐसे पृष्ठ जिनका विकिपीडिया के लक्ष्यों से कोई नज़दीकी संबंध नहीं। [[वि:सपृनहीं]] के सभी उल्लंघन इस मापदंड के तहत शीघ्र हटाये जा सकते हैं।',
		hideWhenRedirect: true
	}
];

Twinkle.speedy.generalList = [
	{
		label: 'व1: अर्थहीन नाम अथवा सम्पूर्णतया अर्थहीन सामग्री वाले पृष्ठ ',
		value: 'nonsense',
		tooltip: 'पूरी तरह से अर्थहीन और बिलकुल न समझ में आने वाला। अगर आपको थोड़ा भी समझ में आ रहा, यह मापदंड नहीं लागू होगा।',
		hideInNamespaces: [ 2 ] // Not applicable in userspace
	},
	{
		label: 'व2: परीक्षण पृष्ठ',
		value: 'test',
		tooltip: 'प्रयोग अथवा परीक्षण के लिए बनाया गया, विकिपीडिया के किसी फंक्शन का परीक्षण करने हेतु बनाया गया।',
		hideInNamespaces: [ 2 ] // Not applicable in userspace
	},
	{
		label: 'व3: साफ़ बर्बरता',
		value: 'vandalism',
		tooltip: 'विशुद्ध रूप से बर्बरता। इसमें स्थानांतरण द्वारा बर्बरता से पीछे छूटे पुनर्निर्देश भी शामिल हैं।'
	},
	{
		label: 'व4: साफ़ धोखा',
		value: 'hoax',
		tooltip: 'साफ़ तौर पर धोखा, स्वयं गढ़ी हुई कथा-कहानी अथवा दावा इत्यादि जिनका कही अन्यत्र कोई प्रमाण उपलब्ध न हो; संदेह की दशा में मूल शोध के तहत हहेच करें।',
		hideWhenMultiple: true
	},
	{
		label: 'व5: ख़ाली पृष्ठ अथवा लेखक द्वारा स्वयं ख़ाली किया गया पृष्ठ',
		value: 'blank',
		tooltip: 'पूर्णतया ख़ाली पृष्ठ, या बहुत ही कम सामग्री वाला पृष्ठ जिससे उद्देश्य स्पष्ट न हो, अथवा लेखक द्वारा स्वयं ख़ाली किया गया पृष्ठ',
		hideWhenMultiple: true
	},
	{
		label: 'व6: साफ़ कॉपीराइट उल्लंघन ',
		value: 'copyvio',
		tooltip: 'किसी भी नामस्थान में कॉपीराइट उल्लंघन पाठ जोड़ना',
		subgroup: {
			name: 'copyvio_url',
			type: 'input',
			label: 'स्रोत यूआरएल ("http://" अथवा "https:// के साथ):',
			size: 60,
			hideInNamespaces: [ 6 ] // Not applicable in file namespace
		}
	},
	{
		label: 'व7:  किसी भी पृष्ठ पर साफ़ प्रचार अथवा स्पैम',
		value: 'spam',
		tooltip: 'मुख्य नामस्थान के अतिरिक्त किसी अन्य नामस्थान में प्रचारक कार्य, स्पैम इत्यादि। ',
	}
];

Twinkle.speedy.normalizeHash = {
	reason: 'db',
	nonsense: 'व1',
	test: 'व2',
	vandalism: 'व3',
	hoax: 'व4',
	blank: 'व5',
	copyvio: 'व6',
	imgcopyvio: 'व6फ़',
	spam: 'व7',
	foreign: 'ल1',
	promo: 'ल2',
	duplicate: 'ल4',
	badtrans: 'ल5',
	license: 'फ़1',
	commons: 'फ़2',
	unused: 'फ़3',
	norat: 'फ़4',
	freealt: 'फ़5',
	badfiletype: 'फ़6',
	userreq: 'स1',
	nouser: 'स2',
	notwebhost: 'स3'
};

Twinkle.speedy.callbacks = {
	getTemplateCodeAndParams: function(params) {
		var code, parameters, i;
		if (params.normalizeds.length > 1) {
			code = '{{db-multiple';
			params.utparams = {};
			$.each(params.normalizeds, function(index, norm) {
				code += '|' + norm.toUpperCase();
				parameters = params.templateParams[index] || [];
				for (var i in parameters) {
					if (typeof parameters[i] === 'string' && !parseInt(i, 10)) {  // skip numeric parameters - {{db-multiple}} doesn't understand them
						code += '|' + i + '=' + parameters[i];
					}
				}
				$.extend(params.utparams, Twinkle.speedy.getUserTalkParameters(norm, parameters));
			});
			code += '}}';
		} else {
			parameters = params.templateParams[0] || [];
			code = '{{db-' + params.values[0];
			for (i in parameters) {
				if (typeof parameters[i] === 'string') {
					code += '|' + i + '=' + parameters[i];
				}
			}
			if (params.usertalk) {
				code += '|help=off';
			}
			code += '}}';
			params.utparams = Twinkle.speedy.getUserTalkParameters(params.normalizeds[0], parameters);
		}

		return [code, params.utparams];
	},

	parseWikitext: function(wikitext, callback) {
		var query = {
			action: 'parse',
			prop: 'text',
			pst: 'true',
			text: wikitext,
			contentmodel: 'wikitext',
			title: mw.config.get('wgPageName'),
			disablelimitreport: true,
			format: 'json'
		};

		var statusIndicator = new Morebits.status('हटाने का सारांश निर्मित किया जा रहा');
		var api = new Morebits.wiki.api('हटाने का साँचा प्राप्त किया जा रहा', query, function(apiobj) {
			var reason = decodeURIComponent($(apiobj.getResponse().parse.text).find('#delete-reason').text()).replace(/\+/g, ' ');
			if (!reason) {
				statusIndicator.warn('हटाने के साँचे द्वारा संपादन सारांश निर्मित करने में विफल');
			} else {
				statusIndicator.info('पूर्ण हुआ');
			}
			callback(reason);
		}, statusIndicator);
		api.post();
	},

	noteToCreator: function(pageobj) {
		var params = pageobj.getCallbackParameters();
		var initialContrib = pageobj.getCreator();
			params.initialContribIsIP = mw.util.isIPAddress(pageobj.getCreator());
	
		// don't notify IP's 
		if (params.initialContribIsIP) {
    		Morebits.status.warn("यह पृष्ठ किसी आइपी द्वारा निर्मित है, सूचना साँचा नहीं जोड़ा जा रहा।"); 
			return;
		}

		// disallow notifying yourself
		if (initialContrib === mw.config.get('wgUserName')) {
			Morebits.status.warn('इस पृष्ठ का निर्माण आप ही के द्वारा किया गया है, सूचना नहीं भेजी जायेगी।');
			initialContrib = null;

		// don't notify users when their user talk page is nominated/deleted
		} else if (initialContrib === mw.config.get('wgTitle') && mw.config.get('wgNamespaceNumber') === 3) {
			Morebits.status.warn('इस सदस्य द्वारा स्वयं ही अपना सदस्य वार्ता पृष्ठ बनाया गया है; कोई सूचना नहीं भेजी जायेगी।');
			initialContrib = null;

		// quick hack to prevent excessive unwanted notifications, per request. Should actually be configurable on recipient page...
		} else if ((initialContrib === 'Cyberbot I' || initialContrib === 'SoxBot') && params.normalizeds[0] === 'f2') {
			Morebits.status.warn('Notifying initial contributor: page created procedurally by bot; skipping notification');
			initialContrib = null;

		// Check for already existing tags
		} else if (Twinkle.speedy.hasCSD && params.warnUser && !confirm('The page is has a deletion-related tag, and thus the creator has likely been notified.  Do you want to notify them for this deletion as well?')) {
			Morebits.status.info('Notifying initial contributor', 'canceled by user; skipping notification.');
			initialContrib = null;
		}

		if (initialContrib) {
			var usertalkpage = new Morebits.wiki.page('सदस्य वार्ता:' + initialContrib, ' पर पृष्ठ निर्माता  (' + initialContrib + ') को सूचित किया जा रहा है'),
				notifytext, i, editsummary;

			// special cases: "db" and "db-multiple"
			if (params.normalizeds.length > 1) {
				notifytext = '\n{{subst:db-' + (params.warnUser ? 'deleted' : 'notice') + '-multiple|1=' + Morebits.pageNameNorm;
				var count = 2;
				$.each(params.normalizeds, function(index, norm) {
					notifytext += '|' + count++ + '=' + norm.toUpperCase();
				});
			} else if (params.normalizeds[0] === 'db') {
				notifytext = '\n{{subst:db-reason-' + (params.warnUser ? 'deleted' : 'notice') + '|1=' + Morebits.pageNameNorm;
			} else {
				notifytext = '\n{{subst:db-csd-' + (params.warnUser ? 'deleted' : 'notice') + '-custom|1=';
				if (params.values[0] === 'copypaste') {
					notifytext += params.templateParams[0].sourcepage;
				} else {
					notifytext += Morebits.pageNameNorm;
				}
				notifytext += '|2=' + params.values[0];
			}

			for (i in params.utparams) {
				if (typeof params.utparams[i] === 'string') {
					notifytext += '|' + i + '=' + params.utparams[i];
				}
			}
			notifytext += (params.welcomeuser ? '' : '|nowelcome=yes') + '}} ~~~~';

			editsummary = 'सूचना:  [[:' + Morebits.pageNameNorm + ']] को शीघ्र हटाने का नामांकन';

			usertalkpage.setAppendText(notifytext);
			usertalkpage.setEditSummary(editsummary);
			usertalkpage.setChangeTags(Twinkle.changeTags);
			usertalkpage.setCreateOption('recreate');
			usertalkpage.setWatchlist(Twinkle.getPref('watchSpeedyUser'));
			usertalkpage.setFollowRedirect(true, false);
			usertalkpage.append(function onNotifySuccess() {
				// add this nomination to the user's userspace log, if the user has enabled it
				if (params.lognomination) {
					Twinkle.speedy.callbacks.user.addToLog(params, initialContrib);
				}
			}, function onNotifyError() {
				// if user could not be notified, log nomination without mentioning that notification was sent
				if (params.lognomination) {
					Twinkle.speedy.callbacks.user.addToLog(params, null);
				}
			});
		} else if (params.lognomination) {
			// log nomination even if the user notification wasn't sent
			Twinkle.speedy.callbacks.user.addToLog(params, null);
		}
	},

	sysop: {
		main: function(params) {
			var reason;
			if (!params.normalizeds.length && params.normalizeds[0] === 'db') {
				reason = prompt('Enter the deletion summary to use, which will be entered into the deletion log:', '');
				Twinkle.speedy.callbacks.sysop.deletePage(reason, params);
			} else {
				var code = Twinkle.speedy.callbacks.getTemplateCodeAndParams(params)[0];
				Twinkle.speedy.callbacks.parseWikitext(code, function(reason) {
					if (params.promptForSummary) {
						reason = prompt('Enter the deletion summary to use, or press OK to accept the automatically generated one.', reason);
					}
					Twinkle.speedy.callbacks.sysop.deletePage(reason, params);
				});
			}
		},
		deletePage: function(reason, params) {
			var thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), 'पृष्ठ हटाया जा रहा है');

			if (reason === null) {
				return Morebits.status.error('कारण पूछा जा रहा है', 'सदस्य द्वारा रद्द किया गया');
			} else if (!reason || !reason.replace(/^\s*/, '').replace(/\s*$/, '')) {
				return Morebits.status.error('कारण पूछा जा रहा है', "आपने कोई कारण नहीं बताया है। अब मुझे नहीं पता... प्रबंधकों का यह क्या रवैया है... यह कार्य यहीं छोड़ा जा रहा...");
			}

			var deleteMain = function(callback) {
				thispage.setEditSummary(reason);
				thispage.setChangeTags(Twinkle.changeTags);
				thispage.setWatchlist(params.watch);
				thispage.deletePage(function() {
					thispage.getStatusElement().info('पूर्ण हुआ');
					typeof callback === 'function' && callback();
					Twinkle.speedy.callbacks.sysop.deleteTalk(params);
				});
			};

			// look up initial contributor. If prompting user for deletion reason, just display a link.
			// Otherwise open the talk page directly
			if (params.warnUser) {
				thispage.setCallbackParameters(params);
				thispage.lookupCreation(function(pageobj) {
					deleteMain(function() {
						Twinkle.speedy.callbacks.noteToCreator(pageobj);
					});
				});
			} else {
				deleteMain();
			}
		},
		deleteTalk: function(params) {
			// delete talk page
			if (params.deleteTalkPage &&
					params.normalized !== 'f8' &&
					!document.getElementById('ca-talk').classList.contains('new')) {
				var talkpage = new Morebits.wiki.page(mw.config.get('wgFormattedNamespaces')[mw.config.get('wgNamespaceNumber') + 1] + ':' + mw.config.get('wgTitle'), 'वार्ता पृष्ठ हटाया जा रहा है');
				talkpage.setEditSummary('हटाये गये पृष्ठ "' + Morebits.pageNameNorm + '" का वार्ता पृष्ठ');
				talkpage.setChangeTags(Twinkle.changeTags);
				talkpage.deletePage();
				// this is ugly, but because of the architecture of wiki.api, it is needed
				// (otherwise success/failure messages for the previous action would be suppressed)
				window.setTimeout(function() {
					Twinkle.speedy.callbacks.sysop.deleteRedirects(params);
				}, 1800);
			} else {
				Twinkle.speedy.callbacks.sysop.deleteRedirects(params);
			}
		},
		deleteRedirects: function(params) {
			// delete redirects
			if (params.deleteRedirects) {
				var query = {
					action: 'query',
					titles: mw.config.get('wgPageName'),
					prop: 'redirects',
					rdlimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
					format: 'json'
				};
				var wikipedia_api = new Morebits.wiki.api('पुनर्निर्देशनों की सूची प्राप्त की जा रही...', query, Twinkle.speedy.callbacks.sysop.deleteRedirectsMain,
					new Morebits.status('पुनर्निर्देशन हटाये जा रहे'));
				wikipedia_api.params = params;
				wikipedia_api.post();
			}

			// promote Unlink tool
			var $link, $bigtext;
			if (mw.config.get('wgNamespaceNumber') === 6 && params.normalized !== 'f8') {
				$link = $('<a/>', {
					href: '#',
					text: 'कड़ीतोड़ उपकरण पर जाने के लिए यहाँ क्लिक करें',
					css: { fontSize: '130%', fontWeight: 'bold' },
					click: function() {
						Morebits.wiki.actionCompleted.redirect = null;
						Twinkle.speedy.dialog.close();
						Twinkle.unlink.callback('Removing usages of and/or links to deleted file ' + Morebits.pageNameNorm);
					}
				});
				$bigtext = $('<span/>', {
					text: 'To orphan backlinks and remove instances of file usage',
					css: { fontSize: '130%', fontWeight: 'bold' }
				});
				Morebits.status.info($bigtext[0], $link[0]);
			} else if (params.normalized !== 'f8') {
				$link = $('<a/>', {
					href: '#',
					text: 'कड़ीतोड़ उपकरण पर जाने के लिए यहाँ क्लिक करें',
					css: { fontSize: '130%', fontWeight: 'bold' },
					click: function() {
						Morebits.wiki.actionCompleted.redirect = null;
						Twinkle.speedy.dialog.close();
						Twinkle.unlink.callback('Removing links to deleted page ' + Morebits.pageNameNorm);
					}
				});
				$bigtext = $('<span/>', {
					text: 'To orphan backlinks',
					css: { fontSize: '130%', fontWeight: 'bold' }
				});
				Morebits.status.info($bigtext[0], $link[0]);
			}
		},
		deleteRedirectsMain: function(apiobj) {
			var response = apiobj.getResponse();
			var snapshot = response.query.pages[0].redirects || [];
			var total = snapshot.length;
			var statusIndicator = apiobj.statelem;

			if (!total) {
				statusIndicator.status('कोई पुनर्निर्देशन नहीं मिले');
				return;
			}

			statusIndicator.status('0%');

			var current = 0;
			var onsuccess = function(apiobjInner) {
				var now = parseInt(100 * ++current / total, 10) + '%';
				statusIndicator.update(now);
				apiobjInner.statelem.unlink();
				if (current >= total) {
					statusIndicator.info(now + ' (पूर्ण हुआ)');
					Morebits.wiki.removeCheckpoint();
				}
			};

			Morebits.wiki.addCheckpoint();

			snapshot.forEach(function(value) {
				var title = value.title;
				var page = new Morebits.wiki.page(title, 'पुनर्निर्देशन हटाये जा रहे "' + title + '"');
				page.setEditSummary('"' + Morebits.pageNameNorm + '" पर पुनर्निर्देशित पृष्ठ हटाये गये');
				page.setChangeTags(Twinkle.changeTags);
				page.deletePage(onsuccess);
			});
		}
	},

	user: {
		main: function(pageobj) {
			var statelem = pageobj.getStatusElement();

			if (!pageobj.exists()) {
				statelem.error("ऐसा मालूम होता है कि यह पृष्ठ मौज़ूद नहीं है; हो सकता है इसे पहले ही हटाया जा चुका हो");
				return;
			}

			var params = pageobj.getCallbackParameters();

			// given the params, builds the template and also adds the user talk page parameters to the params that were passed in
			// returns => [<string> wikitext, <object> utparams]
			var buildData = Twinkle.speedy.callbacks.getTemplateCodeAndParams(params),
				code = buildData[0];
			params.utparams = buildData[1];

			// Set the correct value for |ts= parameter in {{db-g13}}
			if (params.normalizeds.indexOf('g13') !== -1) {
				code = code.replace('$TIMESTAMP', pageobj.getLastEditTime());
			}

			// Tag if possible, post on talk if not
			if (pageobj.canEdit() && ['wikitext', 'Scribunto', 'javascript', 'css', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
				var text = pageobj.getPageText();

				statelem.status('पृष्ठ पर उपस्थित टैग की जांच की जा रही...');

				// check for existing deletion tags
				var tag = /(?:\{\{\s*(db|शीह|delete|हटाएँ|db-.*?|शीह-.*?|speedy deletion-.*?)(?:\s*\||\s*\}\}))/.exec(text);
				// This won't make use of the db-multiple template but it probably should
				if (tag && !confirm('पृष्ठ पर पहले से ही {{' + tag[1] + '}} के रूप में शीह टैग लगा हुआ है। आप दूसरा टैग भी जोड़ना चाहते हैं? ')) {
					return;
				}

				var xfd = /\{\{((?:article for deletion|proposed deletion|prod blp|template for discussion)\/dated|[cfm]fd\b)/i.exec(text) || /#invoke:(RfD)/.exec(text);
				if (xfd && !confirm('हटाने संबंधी टैग {{' + xfd[1] + '}} पृष्ठ पर पहले से लगा हुआ है। आप फिर भी शीह का टैग जोड़ना चाहते हैं?')) {
					return;
				}

				// curate/patrol the page
				if (Twinkle.getPref('markSpeedyPagesAsPatrolled')) {
					pageobj.triage();
				}

				// Wrap SD template in noinclude tags if we are in template space.
				// Won't work with userboxes in userspace, or any other transcluded page outside template space
				if (mw.config.get('wgNamespaceNumber') === 10) {  // Template:
					code = '<noinclude>' + code + '</noinclude>';
				}

				// Remove tags that become superfluous with this action
				text = text.replace(/\{\{\s*([Uu]serspace draft)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/g, '');
				if (mw.config.get('wgNamespaceNumber') === 6) {
					// remove "move to Commons" tag - deletion-tagged files cannot be moved to Commons
					text = text.replace(/\{\{(mtc|(copy |move )?to ?commons|move to wikimedia commons|copy to wikimedia commons)[^}]*\}\}/gi, '');
				}

				if (params.requestsalt) {
					if (params.normalizeds.indexOf('g10') === -1) {
						code += '\n{{salt}}';
					} else {
						code = '{{salt}}\n' + code;
					}
				}

				if (mw.config.get('wgPageContentModel') === 'Scribunto') {
					// Scribunto isn't parsed like wikitext, so CSD templates on modules need special handling to work
					var equals = '';
					while (code.indexOf(']' + equals + ']') !== -1) {
						equals += '=';
					}
					code = "require('Module:Module wikitext')._addText([" + equals + '[' + code + ']' + equals + ']);';
				} else if (['javascript', 'css', 'sanitized-css'].indexOf(mw.config.get('wgPageContentModel')) !== -1) {
					// Likewise for JS/CSS pages
					code = '/* ' + code + ' */';
				}

				// Generate edit summary for edit
				var editsummary;
				if (params.normalizeds.length > 1) {
					editsummary = 'शीघ्र हटाने का अनुरोध किया जा रहा (';
					$.each(params.normalizeds, function(index, norm) {
						editsummary += '[[वि:शीह#' + norm.toUpperCase() + '|शीह ' + norm.toUpperCase() + ']], ';
					});
					editsummary = editsummary.substr(0, editsummary.length - 2); // remove trailing comma
					editsummary += ').';
				} else if (params.normalizeds[0] === 'db') {
					editsummary = '[[वि:शीह|शीघ्र हटाने का अनुरोध]] कारण "' + params.templateParams[0]['1'] + '"';
				} else {
					editsummary = 'शीघ्र हटाने का अनुरोध ( मापदंड:[[वि:शीह#' + params.normalizeds[0].toUpperCase() + '|शीह ' + params.normalizeds[0].toUpperCase() + ']])';
				}

				// Blank attack pages
				if (params.normalizeds.indexOf('g10') !== -1) {
					text = code;
				} else {
					// Insert tag after short description or any hatnotes
					var wikipage = new Morebits.wikitext.page(text);
					text = wikipage.insertAfterTemplates(code + '\n', Twinkle.hatnoteRegex).getText();
				}


				pageobj.setPageText(text);
				pageobj.setEditSummary(editsummary);
				pageobj.setWatchlist(params.watch);
				pageobj.save(Twinkle.speedy.callbacks.user.tagComplete);
			} else { // Attempt to place on talk page
				var talkName = new mw.Title(pageobj.getPageName()).getTalkPage().toText();
				if (talkName !== pageobj.getPageName()) {
					if (params.requestsalt) {
						code += '\n{{salt}}';
					}

					pageobj.getStatusElement().warn('Unable to edit page, placing tag on talk page');

					var talk_page = new Morebits.wiki.page(talkName, 'Automatically placing tag on talk page');
					talk_page.setNewSectionTitle(pageobj.getPageName() + ' nominated for CSD, request deletion');
					talk_page.setNewSectionText(code + '\n\nI was unable to tag ' + pageobj.getPageName() + ' so please delete it. ~~~~');
					talk_page.setCreateOption('recreate');
					talk_page.setFollowRedirect(true);
					talk_page.setWatchlist(params.watch);
					talk_page.setChangeTags(Twinkle.changeTags);
					talk_page.setCallbackParameters(params);
					talk_page.newSection(Twinkle.speedy.callbacks.user.tagComplete);
				} else {
					pageobj.getStatusElement().error('Page protected and nowhere to add an edit request, aborting');
				}
			}
		},

		tagComplete: function(pageobj) {
			var params = pageobj.getCallbackParameters();

			// Notification to first contributor, will also log nomination to the user's userspace log
			if (params.usertalk) {
				var thispage = new Morebits.wiki.page(Morebits.pageNameNorm);
				thispage.setCallbackParameters(params);
				thispage.lookupCreation(Twinkle.speedy.callbacks.noteToCreator);
			// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
			} else if (params.lognomination) {
				Twinkle.speedy.callbacks.user.addToLog(params, null);
			}
		},

		addToLog: function(params, initialContrib) {
			var usl = new Morebits.userspaceLogger(Twinkle.getPref('speedyLogPageName'));
			usl.initialText =
				"This is a log of all [[वि:शीह|speedy deletion]] nominations made by this user using [[WP:TW|Twinkle]]'s CSD 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 [[वि:शीह#U1|CSD U1]].' +
				(Morebits.userIsSysop ? '\n\nThis log does not track outright speedy deletions made using Twinkle.' : '');

			var formatParamLog = function(normalize, csdparam, input) {
				if ((normalize === 'G4' && csdparam === 'xfd') ||
					(normalize === 'G6' && csdparam === 'page') ||
					(normalize === 'G6' && csdparam === 'fullvotepage') ||
					(normalize === 'G6' && csdparam === 'sourcepage') ||
					(normalize === 'A2' && csdparam === 'source') ||
					(normalize === 'A10' && csdparam === 'article') ||
					(normalize === 'F1' && csdparam === 'filename')) {
					input = '[[:' + input + ']]';
				} else if (normalize === 'G5' && csdparam === 'user') {
					input = '[[:User:' + input + ']]';
				} else if (normalize === 'G12' && csdparam.lastIndexOf('url', 0) === 0 && input.lastIndexOf('http', 0) === 0) {
					input = '[' + input + ' ' + input + ']';
				} else if (normalize === 'फ़2' && csdparam === 'filename') {
					input = '[[commons:' + input + ']]';
				} else if (normalize === 'P1' && csdparam === 'criterion') {
					input = '[[वि:शीह#' + input + ']]';
				}
				return ' {' + normalize + ' ' + csdparam + ': ' + input + '}';
			};

			var extraInfo = '';

			// 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])' : '';

			var editsummary = 'शीह नामांकन का लॉग बनाया जा रहा';
			var appendText = '# [[:' + Morebits.pageNameNorm;

			if (params.normalizeds.indexOf('g10') === -1) {  // no article name in log for G10 taggings
				appendText += ']]' + fileLogLink + ': ';
				editsummary += ' of [[:' + Morebits.pageNameNorm + ']].';
			} else {
				appendText += '|This]] attack page' + fileLogLink + ': ';
				editsummary += ' of an attack page.';
			}
			if (params.normalizeds.length > 1) {
				appendText += 'multiple criteria (';
				$.each(params.normalizeds, function(index, norm) {
					appendText += '[[वि:शीह#' + norm.toUpperCase() + '|' + norm.toUpperCase() + ']], ';
				});
				appendText = appendText.substr(0, appendText.length - 2);  // remove trailing comma
				appendText += ')';
			} else if (params.normalizeds[0] === 'db') {
				appendText += '{{tl|db-reason}}';
			} else {
				appendText += '[[वि:शीह#' + params.normalizeds[0].toUpperCase() + '|शीह ' + params.normalizeds[0].toUpperCase() + ']] ({{tl|db-' + params.values[0] + '}})';
			}

			// If params is "empty" it will still be full of empty arrays, but ask anyway
			if (params.templateParams) {
				// Treat custom rationale individually
				if (params.normalizeds[0] && params.normalizeds[0] === 'db') {
					extraInfo += formatParamLog('Custom', 'rationale', params.templateParams[0]['1']);
				} else {
					params.templateParams.forEach(function(item, index) {
						var keys = Object.keys(item);
						if (keys[0] !== undefined && keys[0].length > 0) {
							// Second loop required since some items (G12, g6f) may have multiple keys
							keys.forEach(function(key, keyIndex) {
								if (keys[keyIndex] === 'blanked' || keys[keyIndex] === 'ts') {
									return true; // Not worth logging
								}
								extraInfo += formatParamLog(params.normalizeds[index].toUpperCase(), keys[keyIndex], item[key]);
							});
						}
					});
				}
			}

			if (params.requestsalt) {
				appendText += '; निर्माण-सुरक्षा हेतु ([[WP:SALT|salting]]) अनुरोध किया गया';
			}
			if (extraInfo) {
				appendText += '; अन्य अतिरिक्त जानकारी:' + extraInfo;
			}
			if (initialContrib) {
				appendText += '; सदस्य {{user|1=' + initialContrib + '}} को सूचित किया गया';
			}
			appendText += ' ~~~~~\n';

			usl.changeTags = Twinkle.changeTags;
			usl.log(appendText, editsummary);
		}
	}
};

// validate subgroups in the form passed into the speedy deletion tag
Twinkle.speedy.getParameters = function twinklespeedyGetParameters(form, values) {
	var parameters = [];

	$.each(values, function(index, value) {
		var currentParams = [];
		switch (value) {
			case 'reason':
				if (form['csd.reason_1']) {
					var dbrationale = form['csd.reason_1'].value;
					if (!dbrationale || !dbrationale.trim()) {
						alert('वैयक्तिक तर्क/कारण:  कृपया एक कारण बतायें जो शीह मापदंड में आता हो।');
						parameters = null;
						return false;
					}
					currentParams['1'] = dbrationale;
				}
				break;
			case 'duplicate':  // A4 प्रतिलिपि लेख
				if (form['csd.duplicate_pagename']) {
					var duplicate = form['csd.duplicate_pagename'].value;
					if (!duplicate || !duplicate.trim()) {
						alert('शीह ल4 (प्रतिलिपि):  कृपया दूसरे पृष्ठ का नाम बतायें जिसकी प्रतिलिपि यह लेख है। ');
						parameters = null;
						return false;
					}
					currentParams['1'] = duplicate;
				}
				break;
			case 'userreq':  // U1 सदस्य अनुरोध
				if (form['csd.userreq_rationale']) {
					var u1rationale = form['csd.userreq_rationale'].value;
					if (mw.config.get('wgNamespaceNumber') === 3 && !(/\//).test(mw.config.get('wgTitle')) &&
							(!u1rationale || !u1rationale.trim())) {
						alert('शीह स1:  कृपया हटाने का कारण बतायें');
						parameters = null;
						return false;
					}
					currentParams.rationale = u1rationale;
				}
				break;

			case 'commons':  // F2
				if (form['csd.commons_filename']) {
					var filename = form['csd.commons_filename'].value;
					if (filename && filename.trim() && filename !== Morebits.pageNameNorm) {
						currentParams['1'] = new RegExp('^\\s*', 'i').test(filename) ? filename : '' + filename;
					}
				}
				break;


			case 'freealt':  // F5
				if (form['csd.freealt_filename']) {
					var filename = form['csd.freealt_filename'].value;
					if (filename && filename.trim() && filename !== Morebits.pageNameNorm) {
						currentParams['1'] = new RegExp('^\\s*' + Morebits.namespaceRegex(6) + ':', 'i').test(filename) ? filename : '' + filename;
					}
				}
				break;


			case 'imgcopyvio':  // G6F
				if (form['csd.imgcopyvio_url'] && form['csd.imgcopyvio_rationale']) {
					var g6furl = form['csd.imgcopyvio_url'].value;
					var g6frationale = form['csd.imgcopyvio_rationale'].value;
					if ((!g6furl || !g6furl.trim()) && (!g6frationale || !g6frationale.trim())) {
						alert('शीह व6फ़: जब आप व6फ़ के तहत शीह नामांकन कर रहे हों, आपको यूआरएल अथवा कारण (या दोनों ही) देना होगा जहाँ से फ़ाइल कॉपी की गयी है।');
						parameters = null;
						return false;
					}
					if (form['csd.imgcopyvio_url'].value) {
						currentParams.url = g6furl;
					}
					if (form['csd.imgcopyvio_rationale'].value) {
						currentParams.rationale = g6frationale;
					}
				}
				break;
			case 'copyvio':  // G6
				if (form['csd.copyvio_url']) {
					var copypaste = form['csd.copyvio_url'].value;
					if (!copypaste || !copypaste.trim()) {
						alert('शीह व6 (कॉपीपेस्ट):  कृपया स्रोत उपलब्ध करायें');
						parameters = null;
						return false;
					}
					currentParams.sourcepage = copypaste;
				}
				break;
				
			default:
				break;
		}
		parameters.push(currentParams);
	});
	return parameters;
};

// Function for processing talk page notification template parameters
// key1/value1: for {{db-criterion-[notice|deleted]}} (via {{db-csd-[notice|deleted]-custom}})
// utparams.param: for {{db-[notice|deleted]-multiple}}
Twinkle.speedy.getUserTalkParameters = function twinklespeedyGetUserTalkParameters(normalized, parameters) {
	var utparams = [];

	// Special cases
	if (normalized === 'db') {
		utparams['2'] = parameters['1'];
	} else if (normalized === 'g6') {
		utparams.key1 = 'to';
		utparams.value1 = Morebits.pageNameNorm;
	} else if (normalized === 'g12') {
		['url', 'url2', 'url3'].forEach(function(item, idx) {
			if (parameters[item]) {
				idx++;
				utparams['key' + idx] = item;
				utparams['value' + idx] = utparams[item] = parameters[item];
			}
		});
	} else {
		// Handle the rest
		var param;
		switch (normalized) {
			case 'g4':
				param = 'xfd';
				break;
			case 'a2':
				param = 'source';
				break;
			case 'a5':
				param = 'location';
				break;
			default:
				break;
		}
		// No harm in providing a usertalk template with the others' parameters
		if (param && parameters[param]) {
			utparams.key1 = param;
			utparams.value1 = utparams[param] = parameters[param];
		}
	}
	return utparams;
};

/**
 * @param {Event} e
 * @returns {Array}
 */
Twinkle.speedy.resolveCsdValues = function twinklespeedyResolveCsdValues(e) {
	var values = (e.target.form ? e.target.form : e.target).getChecked('csd');
	if (values.length === 0) {
		alert('कृपया कोई एक मापदंड चुनें!');
		return null;
	}
	return values;
};

Twinkle.speedy.callback.evaluateSysop = function twinklespeedyCallbackEvaluateSysop(e) {
	var form = e.target.form ? e.target.form : e.target;

	if (e.target.type === 'checkbox' || e.target.type === 'text' ||
			e.target.type === 'select') {
		return;
	}

	var tag_only = form.tag_only;
	if (tag_only && tag_only.checked) {
		Twinkle.speedy.callback.evaluateUser(e);
		return;
	}

	var values = Twinkle.speedy.resolveCsdValues(e);
	if (!values) {
		return;
	}
	var templateParams = Twinkle.speedy.getParameters(form, values);
	if (!templateParams) {
		return;
	}

	var normalizeds = values.map(function(value) {
		return Twinkle.speedy.normalizeHash[value];
	});

	// analyse each criterion to determine whether to watch the page, prompt for summary, or notify the creator
	var watchPage, promptForSummary;
	normalizeds.forEach(function(norm) {
		if (Twinkle.getPref('watchSpeedyPages').indexOf(norm) !== -1) {
			watchPage = Twinkle.getPref('watchSpeedyExpiry');
		}
		if (Twinkle.getPref('promptForSpeedyDeletionSummary').indexOf(norm) !== -1) {
			promptForSummary = true;
		}
	});

	var warnusertalk = form.warnusertalk.checked && normalizeds.some(function (norm, index) {
		return Twinkle.getPref('warnUserOnSpeedyDelete').indexOf(norm) !== -1 &&
			!(norm === 'g6' && values[index] !== 'copyvio');
	});

	var welcomeuser = warnusertalk && normalizeds.some(function (norm) {
		return Twinkle.getPref('welcomeUserOnSpeedyDeletionNotification').indexOf(norm) !== -1;
	});

	var params = {
		values: values,
		normalizeds: normalizeds,
		watch: watchPage,
		deleteTalkPage: form.talkpage && form.talkpage.checked,
		deleteRedirects: form.redirects.checked,
		warnUser: warnusertalk,
		welcomeuser: welcomeuser,
		promptForSummary: promptForSummary,
		templateParams: templateParams
	};

	Morebits.simpleWindow.setButtonsEnabled(false);
	Morebits.status.init(form);

	Twinkle.speedy.callbacks.sysop.main(params);
};

Twinkle.speedy.callback.evaluateUser = function twinklespeedyCallbackEvaluateUser(e) {
	var form = e.target.form ? e.target.form : e.target;

	if (e.target.type === 'checkbox' || e.target.type === 'text' ||
			e.target.type === 'select') {
		return;
	}

	var values = Twinkle.speedy.resolveCsdValues(e);
	if (!values) {
		return;
	}
	var templateParams = Twinkle.speedy.getParameters(form, values);
	if (!templateParams) {
		return;
	}

	// var multiple = form.multiple.checked;

	var normalizeds = values.map(function(value) {
		return Twinkle.speedy.normalizeHash[value];
	});

	// analyse each criterion to determine whether to watch the page/notify the creator
	var watchPage = normalizeds.some(function(norm) {
		return Twinkle.getPref('watchSpeedyPages').indexOf(norm) !== -1 && Twinkle.getPref('watchSpeedyExpiry');
	});
	var notifyuser = form.notify.checked && normalizeds.some(function(norm, index) {
		return Twinkle.getPref('notifyUserOnSpeedyDeletionNomination').indexOf(norm) !== -1 &&
			!(norm === 'g6' && values[index] !== 'copyvio');
	});
	var welcomeuser = notifyuser && normalizeds.some(function(norm) {
		return Twinkle.getPref('welcomeUserOnSpeedyDeletionNotification').indexOf(norm) !== -1;
	});
	var csdlog = Twinkle.getPref('logSpeedyNominations') && normalizeds.some(function(norm) {
		return Twinkle.getPref('noLogOnSpeedyNomination').indexOf(norm) === -1;
	});

	var params = {
		values: values,
		normalizeds: normalizeds,
		watch: watchPage,
		usertalk: notifyuser,
		welcomeuser: welcomeuser,
		lognomination: csdlog,
		requestsalt: form.salting.checked,
		templateParams: templateParams
	};

	Morebits.simpleWindow.setButtonsEnabled(false);
	Morebits.status.init(form);

	Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
	Morebits.wiki.actionCompleted.notice = 'टैग जोड़ने का कार्य पूर्ण हुआ';

	var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'पृष्ठ पर टैग जोड़ा जा रहा है');
	wikipedia_page.setChangeTags(Twinkle.changeTags); // Here to apply to triage
	wikipedia_page.setCallbackParameters(params);
	wikipedia_page.load(Twinkle.speedy.callbacks.user.main);
};

Twinkle.addInitCallback(Twinkle.speedy, 'speedy');
})(jQuery);

// </nowiki>