میڈیاویکی:Gadget-twinkleprotect.js

ویکی کتب سے

یاد دہانی: محفوظ کرنے کے بعد ان تبدیلیوں کو دیکھنے کے لیے آپ کو اپنے براؤزر کا کیش (cache) صاف کرنا ہوگا۔

  • فائرفاکس/ سفاری: جب Reload پر کلک کریں تو Shift دباکر رکھیں، یا Ctrl-F5 یا Ctrl-R دبائیں (Mac پر R-⌘)
  • گوگل کروم: Ctrl-Shift-R دبائیں (Mac پر Shift-R-⌘)
  • انٹرنیٹ ایکسپلورر: جب Refresh پر کلک کریں تو Ctrl یا Ctrl-F5 دبائیں
  • اوپیرا: Tools → Preferences میں جائیں اور کیش (cache) صاف کریں
//<nowiki>


(function($){


/*
 ****************************************
 *** twinkleprotect.js: Protect/RPP module
 ****************************************
 * Mode of invocation:     Tab ("محفوظ"/"درخواست محفوظ")
 * Active on:              Non-special pages
 * Config directives in:   TwinkleConfig
 */

// Note: a lot of code in this module is re-used/called by batchprotect.

Twinkle.protect = function twinkleprotect() {
	if ( mw.config.get('wgNamespaceNumber') < 0 ) {
		return;
	}

	Twinkle.addPortletLink(Twinkle.protect.callback, Morebits.userIsInGroup('sysop') ? "محفوظ کریں" : "درخواست حفاظت", "tw-rpp",
		Morebits.userIsInGroup('sysop') ? "صفحہ کو محفوظ کریں" : "صفحہ کو محفوظ کرنے کی درخواست دیں" );
};

Twinkle.protect.callback = function twinkleprotectCallback() {
	Twinkle.protect.protectionLevel = null;

	var Window = new Morebits.simpleWindow( 620, 530 );
	Window.setTitle( Morebits.userIsInGroup( 'sysop' ) ? "محفوظ کریں، درخواست دیں یا ٹیگ چسپاں کریں" : "محفوظ کرنے کی درخواست یا اس کا ٹیگ چسپاں کریں" );
	Window.setScriptName( "پلک" );
	Window.addFooterLink( "سانچہ جات محفوظ شدگی", "سانچہ:سانچہ جات محفوظ شدگی" );
	Window.addFooterLink( "محفوظ شدگی کی حکمت عملی", "وپ:محفوظ" );
	Window.addFooterLink( "رہنمائے پلک", ":en:WP:TW/DOC#protect" );

	var form = new Morebits.quickForm( Twinkle.protect.callback.evaluate );
	var actionfield = form.append( {
			type: 'field',
			label: 'اقدام کی نوعیت'
		} );
	if( Morebits.userIsInGroup( 'sysop' ) ) {
		actionfield.append( {
				type: 'radio',
				name: 'actiontype',
				event: Twinkle.protect.callback.changeAction,
				list: [
					{
						label: 'صفحہ کو محفوظ کریں',
						value: 'protect',
						tooltip: 'صفحہ کو محفوظ کریں',
						checked: true
					}
				]
			} );
	}
	actionfield.append( {
			type: 'radio',
			name: 'actiontype',
			event: Twinkle.protect.callback.changeAction,
			list: [
				{
					label: 'صفحہ کو محفوظ کرنے کی درخواست دیں',
					value: 'request',
					tooltip: 'اگر آپ خود محفوظ کرنے کی بجائے وپ:دحص' + (Morebits.userIsInGroup('sysop') ? ' پر محفوظ کرنے کی درخواست دینا چاہیں۔' : '۔'),
					checked: !Morebits.userIsInGroup('sysop')
				},
				{
					label: 'صفحہ میں محفوظ شدگی کا سانچہ چسپاں کریں',
					value: 'tag',
					tooltip: 'اگر محفوظ کرنے والے منتظم نے صفحہ محفوظ کرنے کے بعد اس میں مناسب سانچہ لگانا بھول گیا ہو یا آپ نے ابھی اس صفحہ کو محفوظ کیا ہو تو کوئی مناسب سانچہ چسپاں کریں',
					disabled: mw.config.get('wgArticleId') === 0
				}
			]
		} );

	form.append({ type: 'field', label: 'پہلے ترتیب دیں', name: 'field_preset' });
	form.append({ type: 'field', label: '1', name: 'field1' });
	form.append({ type: 'field', label: '2', name: 'field2' });

	form.append( { type:'submit' } );

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

	// We must init the controls
	var evt = document.createEvent( "Event" );
	evt.initEvent( 'change', true, true );
	result.actiontype[0].dispatchEvent( evt );

	// get current protection level asynchronously
	if (Morebits.userIsInGroup('sysop')) {
		Morebits.wiki.actionCompleted.postfix = false;  // avoid Action: completed notice
		Morebits.status.init($('div[name="currentprot"] span').last()[0]);
	}
	Twinkle.protect.fetchProtectionLevel();
};

// Current protection level in a human-readable format
// (a string, or null if no protection; only filled for sysops)
Twinkle.protect.protectionLevel = null;  
// Contains the current protection level in an object
// Once filled, it will look something like:
// { edit: { level: "sysop", expiry: <some date>, cascade: true }, ... }
Twinkle.protect.currentProtectionLevels = {};

Twinkle.protect.fetchProtectionLevel = function twinkleprotectFetchProtectionLevel() {

	var api = new mw.Api();
	api.get({
		format: 'json',
		indexpageids: true,
		action: 'query',
		prop: 'info|flagged',
		inprop: 'protection',
		titles: mw.config.get('wgPageName')
	})
	.done(function(data){
		var pageid = data.query.pageids[0];
		var page = data.query.pages[pageid];
		var result = [];
		var current = {};

		var updateResult = function(label, level, expiry, cascade) {
			// for sysops, stringify, so they can base their decision on existing protection
			if (Morebits.userIsInGroup('sysop')) {
				var boldnode = document.createElement('b');
				boldnode.textContent = label + ": " + level;
				result.push(boldnode);
				if (expiry === 'infinity') {
					result.push(" (غیر محدود) ");
				} else {
					result.push(" (" + new Date(expiry).toUTCString() + " تک ختم ہو جائے گا) ");
				}
				if (cascade) {
					result.push("(آبشاری) ");
				}
			}
		};

		$.each(page.protection, function( index, protection ) {
			if (protection.type !== "aft") {
				current[protection.type] = {
					level: protection.level,
					expiry: protection.expiry,
					cascade: protection.cascade === ''
				};
				updateResult( Morebits.string.toUpperCaseFirstChar(protection.type), protection.level, protection.expiry, protection.cascade );
			}
		});

		if (page.flagged) {
			current.stabilize = {
				level: page.flagged.protection_level,
				expiry: page.flagged.protection_expiry
			};
			// FlaggedRevision gives bad date
			updateResult( 'Pending Changes', page.flagged.protection_level, page.flagged.protection_expiry, false );
		}

		// show the protection level to sysops
		if (Morebits.userIsInGroup('sysop')) {
			if (!result.length) {
				var boldnode = document.createElement('b');
				boldnode.textContent = "غیر محفوظ";
				result.push(boldnode);
			}
			Twinkle.protect.protectionLevel = result;
			Morebits.status.init($('div[name="currentprot"] span').last()[0]);
			Morebits.status.info("موجودہ درجہ حفاظت", Twinkle.protect.protectionLevel);
		}

		Twinkle.protect.currentProtectionLevels = current;
	});
};

Twinkle.protect.callback.changeAction = function twinkleprotectCallbackChangeAction(e) {
	var field_preset;
	var field1;
	var field2;
	var isTemplate = mw.config.get("wgNamespaceNumber") === 10 || mw.config.get("wgNamespaceNumber") === 828;

	switch (e.target.values) {
		case 'protect':
			field_preset = new Morebits.quickForm.element({ type: 'field', label: 'پہلے ترتیب دیں', name: 'field_preset' });
			field_preset.append({
					type: 'select',
					name: 'category',
					label: 'انتخاب ترتیبات:',
					event: Twinkle.protect.callback.changePreset,
					list: (mw.config.get('wgArticleId') ?
						Twinkle.protect.protectionTypes.filter(function(v) {
							return isTemplate || v.label !== 'سانچہ کی محفوظ شدگی';
						}) :
						Twinkle.protect.protectionTypesCreate)
				});

			field2 = new Morebits.quickForm.element({ type: 'field', label: 'اختیارات محفوظ شدگی', name: 'field2' });
			field2.append({ type: 'div', name: 'currentprot', label: ' ' });  // holds the current protection level, as filled out by the async callback
			// for existing pages
			if (mw.config.get('wgArticleId')) {
				field2.append({
						type: 'checkbox',
						name: 'editmodify',
						event: Twinkle.protect.formevents.editmodify,
						list: [
							{
								label: 'درجہ حفاظت میں تبدیلی',
								value: 'editmodify',
								tooltip: 'اگر یہ غیر فعال ہو تو درجہ حفاظت کی تبدیلی اور مدت اختتام اپنی حالت پر چھوڑ دیے جائیں گے۔',
								checked: true
							}
						]
					});
				var editlevel = field2.append({
						type: 'select',
						name: 'editlevel',
						label: 'تبدیلیٔ حفاظت:',
						event: Twinkle.protect.formevents.editlevel
					});
				editlevel.append({
						type: 'option',
						label: 'تمام',
						value: 'all'
					});
				editlevel.append({
						type: 'option',
						label: 'تصدیق شدہ',
						value: 'autoconfirmed'
					});
				if (isTemplate) {
					editlevel.append({
							type: 'option',
							label: 'سانچہ ترمیم کنندگان',
							value: 'templateeditor'
						});
				}
				editlevel.append({
						type: 'option',
						label: 'منتظم',
						value: 'sysop',
						selected: true
					});
				field2.append({
						type: 'select',
						name: 'editexpiry',
						label: 'وقت اختتام:',
						event: function(e) {
							if (e.target.value === 'custom') {
								Twinkle.protect.doCustomExpiry(e.target);
							}
						},
						list: [
							{ label: '1 گھنٹہ', value: '1 hour' },
							{ label: '2 گھنٹہ', value: '2 hours' },
							{ label: '3 گھنٹہ', value: '3 hours' },
							{ label: '6 گھنٹہ', value: '6 hours' },
							{ label: '12 گھنٹہ', value: '12 hours' },
							{ label: '1 دن', value: '1 day' },
							{ label: '2 دن', selected: true, value: '2 days' },
							{ label: '3 دن', value: '3 days' },
							{ label: '4 دن', value: '4 days' },
							{ label: '1 ہفتہ', value: '1 week' },
							{ label: '2 ہفتہ', value: '2 weeks' },
							{ label: '1 مہینہ', value: '1 month' },
							{ label: '2 مہینہ', value: '2 months' },
							{ label: '3 مہینہ', value: '3 months' },
							{ label: '1 سال', value: '1 year' },
							{ label: 'غیر متعین', value:'indefinite' },
							{ label: 'شخصی۔۔۔', value: 'custom' }
						]
					});
				field2.append({
						type: 'checkbox',
						name: 'movemodify',
						event: Twinkle.protect.formevents.movemodify,
						list: [
							{
								label: 'حفاظت منتقلی میں تبدیلی',
								value: 'movemodify',
								tooltip: 'اگر یہ غیر فعال ہو تو حفاظت منتقلی کا درجہ اور مدت اختتام اپنی حالت پر چھوڑ دیے جائیں گے۔',
								checked: true
							}
						]
					});
				var movelevel = field2.append({
						type: 'select',
						name: 'movelevel',
						label: 'حفاظت منتقلی:',
						event: Twinkle.protect.formevents.movelevel
					});
				movelevel.append({
						type: 'option',
						label: 'تمام',
						value: 'all'
					});
				movelevel.append({
						type: 'option',
						label: 'تصدیق شدہ',
						value: 'autoconfirmed'
					});
				if (isTemplate) {
					movelevel.append({
							type: 'option',
							label: 'سانچہ ترمیم کنندگان',
							value: 'templateeditor'
						});
				}
				movelevel.append({
						type: 'option',
						label: 'منتظم',
						value: 'sysop',
						selected: true
					});
				field2.append({
						type: 'select',
						name: 'moveexpiry',
						label: 'وقت اختتام:',
						event: function(e) {
							if (e.target.value === 'custom') {
								Twinkle.protect.doCustomExpiry(e.target);
							}
						},
						list: [
							{ label: '1 گھنٹہ', value: '1 hour' },
							{ label: '2 گھنٹہ', value: '2 hours' },
							{ label: '3 گھنٹہ', value: '3 hours' },
							{ label: '6 گھنٹہ', value: '6 hours' },
							{ label: '12 گھنٹہ', value: '12 hours' },
							{ label: '1 دن', value: '1 day' },
							{ label: '2 دن', selected: true, value: '2 days' },
							{ label: '3 دن', value: '3 days' },
							{ label: '4 دن', value: '4 days' },
							{ label: '1 ہفتہ', value: '1 week' },
							{ label: '2 ہفتہ', value: '2 weeks' },
							{ label: '1 مہینہ', value: '1 month' },
							{ label: '2 مہینہ', value: '2 months' },
							{ label: '3 مہینہ', value: '3 months' },
							{ label: '1 سال', value: '1 year' },
							{ label: 'غیر متعین', value:'indefinite' },
							{ label: 'شخصی۔۔۔', value: 'custom' }
						]
					});
				field2.append({
						type: 'checkbox',
						name: 'pcmodify',
						event: Twinkle.protect.formevents.pcmodify,
						list: [
							{
								label: 'معلق تبدیلیوں کی حفاظت میں تبدیلی',
								value: 'pcmodify',
								tooltip: 'اگر یہ غیر فعال ہو تو معلق تبدیلیوں کا درجہ اور مدت اختتام اپنی حالت پر چھوڑ دیے جائیں گے۔',
								checked: true
							}
						]
					});
				var pclevel = field2.append({
						type: 'select',
						name: 'pclevel',
						label: 'معلق تبدیلیاں:',
						event: Twinkle.protect.formevents.pclevel
					});
				pclevel.append({
						type: 'option',
						label: 'کچھ نہیں',
						value: 'none'
					});
				pclevel.append({
						type: 'option',
						label: 'درجہ 1',
						value: 'autoconfirmed',
						selected: true
					});
				pclevel.append({
						type: 'option',
						label: 'درجہ 2 (استعمال نہ کریں)',
						value: 'review'
					});
				field2.append({
						type: 'select',
						name: 'pcexpiry',
						label: 'وقت اختتام:',
						event: function(e) {
							if (e.target.value === 'custom') {
								Twinkle.protect.doCustomExpiry(e.target);
							}
						},
						list: [
							{ label: '1 گھنٹہ', value: '1 hour' },
							{ label: '2 گھنٹہ', value: '2 hours' },
							{ label: '3 گھنٹہ', value: '3 hours' },
							{ label: '6 گھنٹہ', value: '6 hours' },
							{ label: '12 گھنٹہ', value: '12 hours' },
							{ label: '1 دن', value: '1 day' },
							{ label: '2 دن', selected: true, value: '2 days' },
							{ label: '3 دن', value: '3 days' },
							{ label: '4 دن', value: '4 days' },
							{ label: '1 ہفتہ', value: '1 week' },
							{ label: '2 ہفتہ', value: '2 weeks' },
							{ label: '1 مہینہ', value: '1 month' },
							{ label: '2 مہینہ', value: '2 months' },
							{ label: '3 مہینہ', value: '3 months' },
							{ label: '1 سال', value: '1 year' },
							{ label: 'غیر متعین', value:'indefinite' },
							{ label: 'شخصی۔۔۔', value: 'custom' }
						]
					});
			} else {  // for non-existing pages
				var createlevel = field2.append({
						type: 'select',
						name: 'createlevel',
						label: 'تخلیق حفاظت:',
						event: Twinkle.protect.formevents.createlevel
					});
				createlevel.append({
						type: 'option',
						label: 'تمام',
						value: 'all'
					});
				createlevel.append({
						type: 'option',
						label: 'تصدیق شدہ',
						value: 'autoconfirmed'
					});
				if (isTemplate) {
					createlevel.append({
							type: 'option',
							label: 'سانچہ ترمیم کنندگان',
							value: 'templateeditor'
						});
				}
				createlevel.append({
						type: 'option',
						label: 'مدیر',
						value: 'sysop',
						selected: true
					});
				field2.append({
						type: 'select',
						name: 'createexpiry',
						label: 'وقت اختتام:',
						event: function(e) {
							if (e.target.value === 'custom') {
								Twinkle.protect.doCustomExpiry(e.target);
							}
						},
						list: [
							{ label: '1 گھنٹہ', value: '1 hour' },
							{ label: '2 گھنٹہ', value: '2 hours' },
							{ label: '3 گھنٹہ', value: '3 hours' },
							{ label: '6 گھنٹہ', value: '6 hours' },
							{ label: '12 گھنٹہ', value: '12 hours' },
							{ label: '1 دن', value: '1 day' },
							{ label: '2 دن', selected: true, value: '2 days' },
							{ label: '3 دن', value: '3 days' },
							{ label: '4 دن', value: '4 days' },
							{ label: '1 ہفتہ', value: '1 week' },
							{ label: '2 ہفتہ', value: '2 weeks' },
							{ label: '1 مہینہ', value: '1 month' },
							{ label: '2 مہینہ', value: '2 months' },
							{ label: '3 مہینہ', value: '3 months' },
							{ label: '1 سال', value: '1 year' },
							{ label: 'غیر متعین', value:'indefinite' },
							{ label: 'شخصی۔۔۔', value: 'custom' }
						]
					});
			}
			field2.append({
					type: 'textarea',
					name: 'protectReason',
					label: 'محفوظ کرنے کی وجہ (نوشتہ میں):'
				});
			if (!mw.config.get('wgArticleId')) {  // tagging isn't relevant for non-existing pages
				break;
			}
			/* falls through */
		case 'tag':
			field1 = new Morebits.quickForm.element({ type: 'field', label: 'ٹیگ کاری کے اختیارات', name: 'field1' });
			field1.append( {
					type: 'select',
					name: 'tagtype',
					label: 'سانچہ محفوظ شدگی کو منتخب کریں:',
					list: Twinkle.protect.protectionTags,
					event: Twinkle.protect.formevents.tagtype
				} );
			field1.append( {
					type: 'checkbox',
					list: [
						{
							name: 'small',
							label: 'اضافہ (small=yes)',
							tooltip: 'یہ |small=yes ترتیب کی بنا پر قفل کی صورت میں ظاہر ہوتا ہے',
							checked: true
						},
						{
							name: 'noinclude',
							label: 'سانچہ محفوظ کو <noinclude> میں رکھیں',
							tooltip: 'سانچہ محفوظ کو &lt;noinclude&gt; میں رکھیں، تاکہ یہ صفحہ کے ساتھ شامل نہ ہو سکے',
							checked: (mw.config.get('wgNamespaceNumber') === 10)
						}
					]
				} );
			break;

		case 'request':
			field_preset = new Morebits.quickForm.element({ type: 'field', label: 'حفاظت کی نوعیت', name: 'field_preset' });
			field_preset.append({
					type: 'select',
					name: 'category',
					label: 'وجوہات:',
					event: Twinkle.protect.callback.changePreset,
					list: (mw.config.get('wgArticleId') ? Twinkle.protect.protectionTypes : Twinkle.protect.protectionTypesCreate)
				});

			field1 = new Morebits.quickForm.element({ type: 'field', label: 'اختیارات', name: 'field1' });
			field1.append( {
					type: 'select',
					name: 'expiry',
					label: 'مدت: ',
					list: [
						{ label: 'عارضی', value: 'temporary' },
						{ label: 'غیر متعین', value: 'indefinite' },
						{ label: '', selected: true, value: '' }
					]
				} );
			field1.append({
					type: 'textarea',
					name: 'reason',
					label: 'وجہ: '
				});
			break;
		default:
			alert("Something's afoot in twinkleprotect");
			break;
	}

	var oldfield;
	if (field_preset) {
		oldfield = $(e.target.form).find('fieldset[name="field_preset"]')[0];
		oldfield.parentNode.replaceChild(field_preset.render(), oldfield);
	} else {
		$(e.target.form).find('fieldset[name="field_preset"]').css('display', 'none');
	}
	if (field1) {
		oldfield = $(e.target.form).find('fieldset[name="field1"]')[0];
		oldfield.parentNode.replaceChild(field1.render(), oldfield);
	} else {
		$(e.target.form).find('fieldset[name="field1"]').css('display', 'none');
	}
	if (field2) {
		oldfield = $(e.target.form).find('fieldset[name="field2"]')[0];
		oldfield.parentNode.replaceChild(field2.render(), oldfield);
	} else {
		$(e.target.form).find('fieldset[name="field2"]').css('display', 'none');
	}

	if (e.target.values === 'protect') {
		// fake a change event on the preset dropdown
		var evt = document.createEvent( "Event" );
		evt.initEvent( 'change', true, true );
		e.target.form.category.dispatchEvent( evt );

		// re-add protection level text, if it's available
		if (Twinkle.protect.protectionLevel) {
			Morebits.status.init($('div[name="currentprot"] span').last()[0]);
			Morebits.status.info("موجودہ درجہ حفاظت", Twinkle.protect.protectionLevel);
		}

		// reduce vertical height of dialog
		$(e.target.form).find('fieldset[name="field2"] select').parent().css({ display: 'inline-block', marginRight: '0.5em' });
	}
};

Twinkle.protect.formevents = {
	editmodify: function twinkleprotectFormEditmodifyEvent(e) {
		e.target.form.editlevel.disabled = !e.target.checked;
		e.target.form.editexpiry.disabled = !e.target.checked || (e.target.form.editlevel.value === 'all');
		e.target.form.editlevel.style.color = e.target.form.editexpiry.style.color = (e.target.checked ? "" : "transparent");
	},
	editlevel: function twinkleprotectFormEditlevelEvent(e) {
		e.target.form.editexpiry.disabled = (e.target.value === 'all');
	},
	movemodify: function twinkleprotectFormMovemodifyEvent(e) {
		e.target.form.movelevel.disabled = !e.target.checked;
		e.target.form.moveexpiry.disabled = !e.target.checked || (e.target.form.movelevel.value === 'all');
		e.target.form.movelevel.style.color = e.target.form.moveexpiry.style.color = (e.target.checked ? "" : "transparent");
	},
	movelevel: function twinkleprotectFormMovelevelEvent(e) {
		e.target.form.moveexpiry.disabled = (e.target.value === 'all');
	},
	pcmodify: function twinkleprotectFormPcmodifyEvent(e) {
		e.target.form.pclevel.disabled = !e.target.checked;
		e.target.form.pcexpiry.disabled = !e.target.checked || (e.target.form.pclevel.value === 'none');
		e.target.form.pclevel.style.color = e.target.form.pcexpiry.style.color = (e.target.checked ? "" : "transparent");
	},
	pclevel: function twinkleprotectFormPclevelEvent(e) {
		e.target.form.pcexpiry.disabled = (e.target.value === 'none');
	},
	createlevel: function twinkleprotectFormCreatelevelEvent(e) {
		e.target.form.createexpiry.disabled = (e.target.value === 'all');
	},
	tagtype: function twinkleprotectFormTagtypeEvent(e) {
		e.target.form.small.disabled = e.target.form.noinclude.disabled = (e.target.value === 'none') || (e.target.value === 'noop');
	}
};

Twinkle.protect.doCustomExpiry = function twinkleprotectDoCustomExpiry(target) {
	var custom = prompt('شخصی مدت اختتام درج کریں۔  \nآپ اضافی وقتوں کو بھی استعمال کر سکتے ہیں، مثلاً «1 منٹ» یا «19 دن»، نیز مطلق وقت «yyyymmddhhmm» بھی درج کر سکتے ہیں (مثلاً: «200602011405» 1 فروری 2006ء 14:05 یوٹی سی ہوا)', '');
	if (custom) {
		var option = document.createElement('option');
		option.setAttribute('value', custom);
		option.textContent = custom;
		target.appendChild(option);
		target.value = custom;
	} else {
		target.selectedIndex = 0;
	}
};

Twinkle.protect.protectionTypes = [
	{ label: 'محفوظ شدگی ختم کریں', value: 'unprotect' },
	{
		label: 'مکمل محفوظ کریں',
		list: [
			{ label: 'عمومی (مکمل)', value: 'pp-protected' },
			{ label: 'مباحثہ/ترمیمی جنگ (مکمل)', value: 'pp-dispute' },
			{ label: 'مستقل تخریب کاری (مکمل)', value: 'pp-vandalism' },
			{ label: 'ممنوع صارف کا تبادلۂ خیال (مکمل)', value: 'pp-usertalk' }
		]
	},
	{
		label: 'حفاظت سانچہ',
		list: [
			{ label: 'حساس سانچہ (سانچہ ترمیم کنندگان)', value: 'pp-template' }
		]
	},
	{
		label: 'نیم محفوظ شدگی',
		list: [
			{ label: 'مکمل (نیم)', value: 'pp-semi-protected' },
			{ label: 'مستقل تخریب کاری (نیم)', selected: true, value: 'pp-semi-vandalism' },
			{ label: 'بقید حیات شخصیات کی سوانح عمری کے ضوابط کی خلاف ورزی (نیم)', value: 'pp-semi-blp' },
			{ label: 'جرابی کٹھ پتلی (نیم)', value: 'pp-semi-sock' },
			{ label: 'ممنوع صارف کا تبادلۂ خیال (نیم)', value: 'pp-semi-usertalk' }
		]
	},
	{
		label: 'معلق تبدیلیاں',
		list: [
			{ label: 'عمومی (معلق)', value: 'pp-pc-protected' },
			{ label: 'مستقل تخریب کاری (نیم) (معلق)', value: 'pp-pc-vandalism' },
			{ label: 'بقید حیات شخصیات کی سوانح عمری کے ضوابط کی خلاف ورزی (معلق)', value: 'pp-pc-blp' }
		]
	},
	{
		label: 'حفاظت منتقلی',
		list: [
			{ label: 'عمومی (منتقلی)', value: 'pp-move' },
			{ label: 'مباحثہ/ترمیمی جنگ (منتقلی)', value: 'pp-move-dispute' },
			{ label: 'منتقلی صفحہ کے ذریعہ تخریب کاری (منتقلی)', value: 'pp-move-vandalism' },
			{ label: 'حساس سانچہ (منتقلی)', value: 'pp-move-indef' }
		]
	}
];

Twinkle.protect.protectionTypesCreate = [
	{ label: 'محفوظ شدگی ختم کریں', value: 'unprotect' },
	{
		label: 'تخلیق حفاظت',
		list: [
			{ label: 'عمومی (تخلیق)', value: 'pp-create' },
			{ label: 'نامناسب نام', value: 'pp-create-offensive' },
			{ label: 'پے در پے تخلیق', selected: true, value: 'pp-create-salt' },
			{ label: 'حال ہی میں حذف شدہ بقید حیات شخصیت کی سوانح عمری', value: 'pp-create-blp' }
		]
	}
];

// A page with both regular and PC protection will be assigned its regular
// protection weight plus 2 (for PC1) or 7 (for PC2)
Twinkle.protect.protectionWeight = {
	sysop: 30,
	templateeditor: 20,
	flaggedrevs_review: 15,  // Pending Changes level 2 protection alone
	autoconfirmed: 10,
	flaggedrevs_autoconfirmed: 5,  // Pending Changes level 1 protection alone
	all: 0,
	flaggedrevs_none: 0  // just in case
};

// NOTICE: keep this synched with [[MediaWiki:Protect-dropdown]]
// Also note: stabilize = Pending Changes level
Twinkle.protect.protectionPresetsInfo = {
	'pp-protected': {
		edit: 'sysop',
		move: 'sysop',
		reason: null
	},
	'pp-dispute': {
		edit: 'sysop',
		move: 'sysop',
		reason: '[[وپ:محفوظ|حکمت عملی برائے حفاظ صفحہ]]'
	},
	'pp-vandalism': {
		edit: 'sysop',
		move: 'sysop',
		reason: '[[وپ:تخریب|مستقل تخریب کاری]]'
	},
	'pp-usertalk': {
		edit: 'sysop',
		move: 'sysop',
		reason: '[[وپ:فح#وپ:حفاظت تبادلہ خیال|پابندی کے دوران میں تبادلۂ خیال صفحہ کا غلط استعمال]]'
	},
	'pp-template': {
		edit: 'templateeditor',
		move: 'templateeditor',
		reason: '[[وپ:حساس سانچے|حساس سانچے]]'
	},
	'pp-semi-vandalism': {
		edit: 'autoconfirmed',
		reason: '[[وپ:تخریب|مستقل تخریب کاری]]',
		template: 'pp-vandalism'
	},
	'pp-semi-blp': {
		edit: 'autoconfirmed',
		reason: '[[وپ:بحش|بقید حیات شخصیات کی سوانح عمری کے ضوابط کی خلاف ورزی]]',
		template: 'pp-blp'
	},
	'pp-semi-usertalk': {
		edit: 'autoconfirmed',
		move: 'sysop',
		reason: '[[وپ:فح#وپ:حفاظت تبادلہ خیال|پابندی کے دوران میں تبادلۂ خیال صفحہ کا غلط استعمال]]',
		template: 'pp-usertalk'
	},
	'pp-semi-template': {  // removed for now
		edit: 'autoconfirmed',
		move: 'sysop',
		reason: '[[وپ:حساس سانچے|حساس سانچے]]',
		template: 'pp-template'
	},
	'pp-semi-sock': {
		edit: 'autoconfirmed',
		reason: '[[وپ:خلل انداز|مستقل خلل انداز ترمیم کاری]]',
		template: 'pp-sock'
	},
	'pp-semi-protected': {
		edit: 'autoconfirmed',
		reason: null,
		template: 'pp-protected'
	},
	'pp-pc-vandalism': {
		stabilize: 'autoconfirmed',  // stabilize = Pending Changes
		reason: '[[وپ:تخریب|مستقل تخریب کاری]]',
		template: 'pp-pc1'
	},
	'pp-pc-blp': {
		stabilize: 'autoconfirmed',
		reason: '[[وپ:بحش|بقید حیات شخصیات کی سوانح عمری کے ضوابط کی خلاف ورزی]]',
		template: 'pp-pc1'
	},
	'pp-pc-protected': {
		stabilize: 'autoconfirmed',
		reason: null,
		template: 'pp-pc1'
	},
	'pp-move': {
		move: 'sysop',
		reason: null
	},
	'pp-move-dispute': {
		move: 'sysop',
		reason: '[[وپ:محفوظ|منتقلی کی جنگ]]'
	},
	'pp-move-vandalism': {
		move: 'sysop',
		reason: '[[وپ:محفوظ|منتقلی کی تخریب کاری]]'
	},
	'pp-move-indef': {
		move: 'sysop',
		reason: '[[وپ:محفوظ|حساس صفحہ]]'
	},
	'unprotect': {
		edit: 'all',
		move: 'all',
		stabilize: 'none',
		create: 'all',
		reason: null,
		template: 'none'
	},
	'pp-create-offensive': {
		create: 'sysop',
		reason: '[[وپ:محفوظ|توہین آمیز  عنوان]]'
	},
	'pp-create-salt': {
		create: 'sysop',
		reason: '[[وپ:محفوظ|پے در پے تخلیق]]'
	},
	'pp-create-blp': {
		create: 'sysop',
		reason: '[[وپ:بحش|حال ہی میں حذف شدہ بقید حیات شخصیت کی سوانح عمری]]'
	},
	'pp-create': {
		create: 'sysop',
		reason: '{{pp-create}}'
	}
};

Twinkle.protect.protectionTags = [
	{
		label: 'کچھ نہیں (محفوظ شدگی کے موجود سانچے ہٹائیں)',
		value: 'none'
	},
	{
		label: 'کچھ نہیں (محفوظ شدگی کے موجود سانچے نہ ہٹائیں)',
		value: 'noop'
	},
	{
		label: 'سانچہ جات محفوظ شدگی میں ترمیم',
		list: [
			{ label: '{{pp-vandalism}}: تخریب کاری', value: 'pp-vandalism' },
			{ label: '{{pp-dispute}}: ترمیمی جنگ/مباحثہ', value: 'pp-dispute', selected: true },
			{ label: '{{pp-blp}}: بقید حیات شخصیات کی سوانح عمری کے ضوابط کی خلاف ورزیاں', value: 'pp-blp' },
			{ label: '{{pp-sock}}: جرابی کٹھ پتلی', value: 'pp-sock' },
			{ label: '{{pp-template}}: حساس سانچے', value: 'pp-template' },
			{ label: '{{pp-usertalk}}: ممنوع صارفین کا تبادلہ خیال', value: 'pp-usertalk' },
			{ label: '{{pp-protected}}: عمومی حفاظت', value: 'pp-protected' },
			{ label: '{{pp-semi-indef}}: عمومی طویل مدتی نیم محفوظ شدگی', value: 'pp-semi-indef' }
		]
	},
	{
		label: 'معلق تبدیلیوں کے سانچے',
		list: [
			{ label: '{{pp-pc1}}: معلق تبدیلیاں درجہ 1', value: 'pp-pc1' }
		]
	},
	{
		label: 'منتقلی حفاظت کے سانچے',
		list: [
			{ label: '{{pp-move-dispute}}: مباحثہ/ترمیمی جنگ', value: 'pp-move-dispute' },
			{ label: '{{pp-move-vandalism}}: منتقلی صفحہ کی تخریب کاری', value: 'pp-move-vandalism' },
			{ label: '{{pp-move-indef}}: طویل مدتی عمومی', value: 'pp-move-indef' },
			{ label: '{{pp-move}}: دیگر', value: 'pp-move' }
		]
	}
];

Twinkle.protect.callback.changePreset = function twinkleprotectCallbackChangePreset(e) {
	var form = e.target.form;

	var actiontypes = form.actiontype;
	var actiontype;
	for( var i = 0; i < actiontypes.length; i++ )
	{
		if( !actiontypes[i].checked ) {
			continue;
		}
		actiontype = actiontypes[i].values;
		break;
	}

	if (actiontype === 'protect') {  // actually protecting the page
		var item = Twinkle.protect.protectionPresetsInfo[form.category.value];
		if (mw.config.get('wgArticleId')) {
			if (item.edit) {
				form.editmodify.checked = true;
				Twinkle.protect.formevents.editmodify({ target: form.editmodify });
				form.editlevel.value = item.edit;
				Twinkle.protect.formevents.editlevel({ target: form.editlevel });
			} else {
				form.editmodify.checked = false;
				Twinkle.protect.formevents.editmodify({ target: form.editmodify });
			}

			if (item.move) {
				form.movemodify.checked = true;
				Twinkle.protect.formevents.movemodify({ target: form.movemodify });
				form.movelevel.value = item.move;
				Twinkle.protect.formevents.movelevel({ target: form.movelevel });
			} else {
				form.movemodify.checked = false;
				Twinkle.protect.formevents.movemodify({ target: form.movemodify });
			}

			if (item.stabilize) {
				form.pcmodify.checked = true;
				Twinkle.protect.formevents.pcmodify({ target: form.pcmodify });
				form.pclevel.value = item.stabilize;
				Twinkle.protect.formevents.pclevel({ target: form.pclevel });
			} else {
				form.pcmodify.checked = false;
				Twinkle.protect.formevents.pcmodify({ target: form.pcmodify });
			}
		} else {
			if (item.create) {
				form.createlevel.value = item.create;
				Twinkle.protect.formevents.createlevel({ target: form.createlevel });
			}
		}

		var reasonField = (actiontype === "protect" ? form.protectReason : form.reason);
		if (item.reason) {
			reasonField.value = item.reason;
		} else {
			reasonField.value = '';
		}

		// sort out tagging options
		if (mw.config.get('wgArticleId')) {
			if( form.category.value === 'unprotect' ) {
				form.tagtype.value = 'none';
			} else {
				form.tagtype.value = (item.template ? item.template : form.category.value);
			}
			Twinkle.protect.formevents.tagtype({ target: form.tagtype });

			if( /template/.test( form.category.value ) ) {
				form.noinclude.checked = true;
				form.editexpiry.value = form.moveexpiry.value = form.pcexpiry.value = "indefinite";
			} else {
				form.noinclude.checked = false;
			}
		}

	} else {  // RPP request
		if( form.category.value === 'unprotect' ) {
			form.expiry.value = '';
			form.expiry.disabled = true;
		} else {
			form.expiry.disabled = false;
		}
	}
};

Twinkle.protect.callback.evaluate = function twinkleprotectCallbackEvaluate(e) {
	var form = e.target;

	var actiontypes = form.actiontype;
	var actiontype;
	for( var i = 0; i < actiontypes.length; i++ )
	{
		if( !actiontypes[i].checked ) {
			continue;
		}
		actiontype = actiontypes[i].values;
		break;
	}

	var tagparams;
	if( actiontype === 'tag' || (actiontype === 'protect' && mw.config.get('wgArticleId')) ) {
		tagparams = {
			tag: form.tagtype.value,
			reason: ((form.tagtype.value === 'pp-protected' || form.tagtype.value === 'pp-semi-protected' || form.tagtype.value === 'pp-move') && form.protectReason) ? form.protectReason.value : null,
			expiry: (actiontype === 'protect') ?
				(form.editmodify.checked ? form.editexpiry.value :
					(form.movemodify.checked ? form.moveexpiry.value :
						(form.pcmodify.checked ? form.pcexpiry.value : null)
					)
				) : null,
			small: form.small.checked,
			noinclude: form.noinclude.checked
		};
	}

	switch (actiontype) {
		case 'protect':
			// protect the page

			Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
			Morebits.wiki.actionCompleted.notice = "محفوظ شدگی مکمل";

			var statusInited = false;
			var thispage;

			var allDone = function twinkleprotectCallbackAllDone() {
				if (thispage) {
					thispage.getStatusElement().info("done");
				}
				if (tagparams) {
					Twinkle.protect.callbacks.taggingPageInitial(tagparams);
				}
			};

			var protectIt = function twinkleprotectCallbackProtectIt(next) {
				thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), "صفحہ محفوظ ہو رہا ہے");
				if (mw.config.get('wgArticleId')) {
					if (form.editmodify.checked) {
						thispage.setEditProtection(form.editlevel.value, form.editexpiry.value);
					}
					if (form.movemodify.checked) {
						thispage.setMoveProtection(form.movelevel.value, form.moveexpiry.value);
					}
				} else {
					thispage.setCreateProtection(form.createlevel.value, form.createexpiry.value);
					thispage.setWatchlist(false);
				}

				if (form.protectReason.value) {
					thispage.setEditSummary(form.protectReason.value);
				} else {
					alert("آپ کو محفوظ کرنے کی ایک وجہ درج کرنا لازمی ہے۔ یہ وجہ نوشتہ محفوظ شدگی میں درج ہوگی۔");
					return;
				}

				if (!statusInited) {
					Morebits.simpleWindow.setButtonsEnabled( false );
					Morebits.status.init( form );
					statusInited = true;
				}

				thispage.protect(next);
			};

			var stabilizeIt = function twinkleprotectCallbackStabilizeIt() {
				if (thispage) {
					thispage.getStatusElement().info("done");
				}

				thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), "معلق تبدیلیوں کو محفوظ کیا جا رہا ہے");
				thispage.setFlaggedRevs(form.pclevel.value, form.pcexpiry.value);

				if (form.protectReason.value) {
					thispage.setEditSummary(form.protectReason.value);
				} else {
					alert("آپ کو محفوظ کرنے کی ایک وجہ درج کرنا لازمی ہے۔ یہ وجہ نوشتہ محفوظ شدگی میں درج ہوگی۔");
					return;
				}

				if (!statusInited) {
					Morebits.simpleWindow.setButtonsEnabled(false);
					Morebits.status.init(form);
					statusInited = true;
				}

				thispage.stabilize(allDone);
			};

			if ((form.editmodify && form.editmodify.checked) || (form.movemodify && form.movemodify.checked) ||
				!mw.config.get('wgArticleId')) {
				if (form.pcmodify && form.pcmodify.checked) {
					protectIt(stabilizeIt);
				} else {
					protectIt(allDone);
				}
			} else if (form.pcmodify && form.pcmodify.checked) {
				stabilizeIt();
			} else {
				alert("براہ کرم پلک کو کوئی کام دیں! \nاگر آپ صفحہ میں محض ٹیگ چسپاں کرنا چاہتے ہیں تو 'صفحہ میں محفوظ شدگی کا سانچہ چسپاں کریں' کو منتخب کریں۔");
			}

			break;

		case 'tag':
			// apply a protection template

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

			Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
			Morebits.wiki.actionCompleted.followRedirect = false;
			Morebits.wiki.actionCompleted.notice = "ٹیگ چسپاں کر دیا گیا";

			Twinkle.protect.callbacks.taggingPageInitial(tagparams);
			break;

		case 'request':
			// file request at RPP
			var typename, typereason;
			switch( form.category.value ) {
				case 'pp-dispute':
				case 'pp-vandalism':
				case 'pp-usertalk':
				case 'pp-protected':
					typename = 'مکمل محفوظ';
					break;
				case 'pp-template':
					typename = 'سانچہ کی حفاظت';
					break;
				case 'pp-semi-vandalism':
				case 'pp-semi-usertalk':
				case 'pp-semi-sock':
				case 'pp-semi-blp':
				case 'pp-semi-protected':
					typename = 'نیم محفوظ';
					break;
				case 'pp-pc-vandalism':
				case 'pp-pc-blp':
				case 'pp-pc-protected':
					typename = 'معلق تبدیلیاں';
					break;
				case 'pp-move':
				case 'pp-move-dispute':
				case 'pp-move-indef':
				case 'pp-move-vandalism':
					typename = 'حفاظت منتقلی';
					break;
				case 'pp-create':
				case 'pp-create-offensive':
				case 'pp-create-blp':
				case 'pp-create-salt':
					typename = 'تخلیق حفاظت';
					break;
				case 'unprotect':
					/* falls through */
				default:
					typename = 'حفاظت ختم کریں';
					break;
			}
			switch (form.category.value) {
				case 'pp-dispute':
					typereason = 'مباحثہ/ترمیمی جنگ';
					break;
				case 'pp-vandalism':
				case 'pp-semi-vandalism':
				case 'pp-pc-vandalism':
					typereason = 'مستقل تخریب کاری';
					break;
				case 'pp-template':
					typereason = 'حساس سانچہ';
					break;
				case 'pp-usertalk':
				case 'pp-semi-usertalk':
					typereason = 'ممنوع صارف کی جانب سے تبادلۂ خیال صفحہ کا غلط استعمال';
					break;
				case 'pp-semi-sock':
					typereason = 'مستقل کٹھ پتلی بازی';
					break;
				case 'pp-semi-blp':
				case 'pp-pc-blp':
					typereason = '[[وپ:بحش|بقید حیات شخصیات کی سوانح عمری کے ضوابط کی خلاف ورزی]]';
					break;
				case 'pp-move-dispute':
					typereason = 'عنوان پر مباحثہ/ترمیمی جنگ';
					break;
				case 'pp-move-vandalism':
					typereason = 'منتقلی صفحہ کی تخریب کاری';
					break;
				case 'pp-move-indef':
					typereason = 'حساس صفحہ';
					break;
				case 'pp-create-offensive':
					typereason = 'نامناسب نام';
					break;
				case 'pp-create-blp':
					typereason = 'حال ہی میں حذف شدہ [[وپ:بحش|بقید حیات شخصیت کی سوانح عمری';
					break;
				case 'pp-create-salt':
					typereason = 'پے در پے تخلیق';
					break;
				default:
					typereason = '';
					break;
			}

			var reason = typereason;
			if( form.reason.value !== '') {
				if ( typereason !== '' ) {
					reason += "\u00A0\u2013 ";  // U+00A0 NO-BREAK SPACE; U+2013 EN RULE
				}
				reason += form.reason.value;
			}
			if( reason !== '' && reason.charAt( reason.length - 1 ) !== '.' ) {
				reason += '.';
			}

			var rppparams = {
				reason: reason,
				typename: typename,
				category: form.category.value,
				expiry: form.expiry.value
			};

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

			var rppName = 'ویکیپیڈیا:درخواست حفاظت صفحہ';

			// Updating data for the action completed event
			Morebits.wiki.actionCompleted.redirect = rppName;
			Morebits.wiki.actionCompleted.notice = "نامزدگی مکمل، تبادلہ خیال صفحہ کی جانب مراجعت کر رہے ہیں";

			var rppPage = new Morebits.wiki.page( rppName, 'حفاظت صفحہ کی درخواست درج کی جا رہی ہے');
			rppPage.setFollowRedirect( true );
			rppPage.setCallbackParameters( rppparams );
			rppPage.load( Twinkle.protect.callbacks.fileRequest );
			break;
		default:
			alert("پلک: نامعلوم درخواست");
			break;
	}
};

Twinkle.protect.callbacks = {
	taggingPageInitial: function( tagparams ) {
		if (tagparams.tag === 'noop') {
			Morebits.status.info("محفوظ شدگی کا سانچہ چسپاں کیا جا رہا ہے", "کوئی کام نہیں");
			return;
		}

		var protectedPage = new Morebits.wiki.page( mw.config.get('wgPageName'), 'صفحہ میں ٹیگ چسپاں کیا جا رہا ہے');
		protectedPage.setCallbackParameters( tagparams );
		protectedPage.load( Twinkle.protect.callbacks.taggingPage );
	},
	taggingPage: function( protectedPage ) {
		var params = protectedPage.getCallbackParameters();
		var text = protectedPage.getPageText();
		var tag, summary;

		var oldtag_re = /\s*(?:<noinclude>)?\s*\{\{\s*(pp-[^{}]*?|protected|(?:t|v|s|p-|usertalk-v|usertalk-s|sb|move)protected(?:2)?|protected template|privacy protection)\s*?\}\}\s*(?:<\/noinclude>)?\s*/gi;
		var re_result = oldtag_re.exec(text);
		if (re_result) {
			if (confirm("{{" + re_result[1] + "}} میں موجود ہے۔ \nاسے ہٹانے کے لیے ٹھیک پر کلک کریں یا اسے یوں ہی چھوڑنا چاہیں تو منسوخ کر دیں۔")) {
				text = text.replace( oldtag_re, '' );
			}
		}

		if ( params.tag !== 'none' ) {
			tag = params.tag;
			if( params.reason ) {
				tag += '|وجہ=' + params.reason;
			}
			if( ['indefinite', 'infinite', 'never', null].indexOf(params.expiry) === -1 ) {
				tag += '|expiry={{subst:#time:j F Y|' + (/^\s*\d+\s*$/.exec(params.expiry) ? params.expiry : '+' + params.expiry) + '|en}}' + '';
			}
			if( params.small ) {
				tag += '|small=yes';
			}
		}

		if( params.tag === 'none' ) {
			summary = 'حذف سانچہ حفاظت' + Twinkle.getPref('summaryAd');
		} else {
			if( params.noinclude ) {
				text = "<noinclude>{{" + tag + "}}</noinclude>" + text;
			} else if( Morebits.wiki.isPageRedirect() ) {
				text = text + "\n{{" + tag + "}}";
			} else {
				text = "{{" + tag + "}}\n" + text;
			}
			summary = "اضافہ {{" + params.tag + "}}" + Twinkle.getPref('summaryAd');
		}

		protectedPage.setEditSummary( summary );
		protectedPage.setPageText( text );
		protectedPage.setCreateOption( 'nocreate' );
		protectedPage.suppressProtectWarning(); // no need to let admins know they are editing through protection
		protectedPage.save();
	},

	fileRequest: function( rppPage ) {

		var params = rppPage.getCallbackParameters();
		var text = rppPage.getPageText();
		var statusElement = rppPage.getStatusElement();

		var ns2tag = {
			'0': 'مضمون',
			'1': 'lat',
			'2': 'lu',
			'3': 'lut',
			'4': 'lw',
			'5': 'lwt',
			'6': 'lf',
			'7': 'lft',
			'8': 'lm',
			'9': 'lmt',
			'10': 'lt',
			'11': 'ltt',
			'12': 'lh',
			'13': 'lht',
			'14': 'lc',
			'15': 'lct',
			'100': 'lp',
			'101': 'lpt',
			'108': 'lb',
			'109': 'lbt',
			'118': 'ld',
			'119': 'ldt',
			'710': 'lttxt',
			'711': 'lttxtt',
			'828': 'lmd',
			'829': 'lmdt'
		};

		var linkTemplate = ns2tag[ mw.config.get('wgNamespaceNumber') ];
		// support other namespaces like TimedText
		// (this could support talk spaces better, but doesn't seem worth it)
		if (!linkTemplate) {
			linkTemplate = 'ln|' + Morebits.pageNameNorm.substring(0, Morebits.pageNameNorm.indexOf(':'));
		}

		var rppRe = new RegExp( '===\\s*\\{\\{\\s*' + linkTemplate + '\\s*\\|\\s*' + window.RegExp.escape( mw.config.get('wgTitle'), true ) + '\\s*\\}\\}\\s*===', 'm' );
		var tag = rppRe.exec( text );

		var rppLink = document.createElement('a');
		rppLink.setAttribute('href', mw.util.getUrl(rppPage.getPageName()) );
		rppLink.appendChild(document.createTextNode(rppPage.getPageName()));

		if ( tag ) {
			statusElement.error( [ 'اس صفحہ کی حفاظت کی درخواست', rppLink, 'پر پہلے سے موجود ہے۔ آپ کی درخواست منسوخ کی جا رہی ہے۔' ] );
			return;
		}

		var newtag = '=== {{' + linkTemplate + '|' + mw.config.get('wgTitle') + '}} ===' + "\n";
		if( ( new RegExp( '^' + window.RegExp.escape( newtag ).replace( /\s+/g, '\\s*' ), 'm' ) ).test( text ) ) {
			statusElement.error( [ 'اس صفحہ کی حفاظت کی درخواست', rppLink, 'پر پہلے سے موجود ہے۔ آپ کی درخواست منسوخ کی جا رہی ہے۔' ] );
			return;
		}

		var words;
		switch( params.expiry ) {
		case 'temporary':
			words = "عارضی ";
			break;
		case 'indefinite':
			words = "غیر محدود ";
			break;
		default:
			words = "";
			break;
		}

		words += params.typename;

		newtag += "'''" + Morebits.string.toUpperCaseFirstChar(words) + ( params.reason !== '' ? ( ":''' " +
			Morebits.string.formatReasonText(params.reason) ) : ".'''" ) + " ~~~~";

		// If either protection type results in a increased status, then post it under increase
		// else we post it under decrease
		var increase = false;
		var protInfo = Twinkle.protect.protectionPresetsInfo[params.category];

		// function to compute protection weights (see comment at Twinkle.protect.protectionWeight)
		var computeWeight = function(mainLevel, stabilizeLevel) {
			var result = Twinkle.protect.protectionWeight[mainLevel || 'all'];
			if (stabilizeLevel) {
				if (result) {
					if (stabilizeLevel.level === "autoconfirmed") {
						result += 2;
					} else if (stabilizeLevel.level === "review") {
						result += 7;
					}
				} else {
					result = Twinkle.protect.protectionWeight["flaggedrevs_" + stabilizeLevel];
				}
			}
			return result;
		};

		// compare the page's current protection weights with the protection we are requesting
		var editWeight = computeWeight(Twinkle.protect.currentProtectionLevels.edit &&
			Twinkle.protect.currentProtectionLevels.edit.level,
			Twinkle.protect.currentProtectionLevels.stabilize &&
			Twinkle.protect.currentProtectionLevels.stabilize.level);
		if (computeWeight(protInfo.edit, protInfo.stabilize) > editWeight ||
			computeWeight(protInfo.move) > computeWeight(Twinkle.protect.currentProtectionLevels.move && 
			Twinkle.protect.currentProtectionLevels.move.level) ||
			computeWeight(protInfo.create) > computeWeight(Twinkle.protect.currentProtectionLevels.create && 
			Twinkle.protect.currentProtectionLevels.create.level)) {
			increase = true;
		}

		var reg;
		if ( increase ) {
			reg = /(\n==\s*حفاظت کی درخواستیں\s*==\s*\n\s*)/;
		} else {
			reg = /(\n==\s*حفاظت ختم کرنے کی درخواستیں\s*==\s*\n\s*)/;
		}
		var originalTextLength = text.length;
		text = text.replace( reg, "$1" + newtag + "\n");
		if (text.length === originalTextLength)
		{
			var linknode = document.createElement('a');
			linknode.setAttribute("href", mw.util.getUrl("وپ:پلک/تعمیر") );
			linknode.appendChild(document.createTextNode('وکی کتب:دحص کی درستی کا طریقہ'));
			statusElement.error( [ 'وپ:دحص پر متعلقہ سرخی موجود نہیں۔ اس مسئلہ کو حل کرنے کے لیے براہ کرم صفحہ ', linknode, ' ملاحظہ فرمائیں۔' ] );
			return;
		}
		statusElement.status( 'نئی درخواست درج کی جا رہی ہے۔۔۔' );
		rppPage.setEditSummary( "درخواست " + params.typename + (params.typename === "معلق تبدیلیاں" ? ' در [[' : ' از [[') +
			Morebits.pageNameNorm + ']].' + Twinkle.getPref('summaryAd') );
		rppPage.setPageText( text );
		rppPage.setCreateOption( 'recreate' );
		rppPage.save();
	}
};
})(jQuery);


//</nowiki>