ميدياويكي:Gadget-redirectMaker.js

من كوبتيكبيديا
اذهب إلى التنقل اذهب إلى البحث

ملاحظة: بعد النشر، أنت قد تحتاج إلى إفراغ الكاش الخاص بمتصفحك لرؤية التغييرات.

  • فايرفوكس / سافاري: أمسك Shift أثناء ضغط Reload، أو اضغط على إما Ctrl-F5 أو Ctrl-R (⌘-R على ماك)
  • جوجل كروم: اضغط Ctrl-Shift-R (⌘-Shift-R على ماك)
  • إنترنت إكسبلورر/إيدج: أمسك Ctrl أثناء ضغط Refresh، أو اضغط Ctrl-F5
  • أوبرا: اضغط Ctrl-F5.
/**
 *إضافة بسيطة تُستخدم لإنشاء تحويلات بشكل كمي لصفحة ما
 * عند تفعيل الإضافة اذهب إلى
 * وب:منتح
 * كي تستطيع إنشاء التحويلات
 * 
 * لا تزال الإضافة في مرحلة التجربة؛ لذلك استخدمها بحذر شديد
 */
 
var link = mw.util.addPortletLink( 'p-tb', 'https://ar.wikipedia.org/wiki/ويكيبيديا:منشئ_التحويلات', 'منشئ التحويلات', 'ca-redirect', 'الانتقال إلى منشئ التحويلات'); 

if (mw.config.get('wgPageName') === "ويكيبيديا:منشئ_التحويلات"){		
		$(".mw-parser-output").append ('<table width = 100% border = 0><tr><td colspan = 2><button id = \'addButton\'>+ أضف</button><button class = \'submit\'>حفظ</button><button id = \'clearButton\'>- إفراغ</button></td></tr></table>');

		$(document).on('click','#addButton',function(){
			$('table').append("<tr><td><label for 'redirect'>اسم التحويلة </label> <input style = 'width:100%;' class = 'redirect' type = 'text'/></td><td><label for 'redirect'>اسم التحويلة </label> <input style = 'width:100%;' class = 'redirect' type = 'text'/></td></tr>");
		});
		
		$(document).on('click','#clearButton',function(){
			$('input.redirect').val("");
			$('input#target').val("");
		});


		$('table').append("<tr><td colspan = 2><label for 'target'>الصفحة الهدف </label> <input style = 'width:100%;display:table;border:solid #9f8de2;' id = 'target' type = 'text'/></td></tr>");

		$(document).on('click','.submit',function(){
			var conf = confirm ("هل أنت متأكد من صحة البيانات المدخلة؟");
				if (conf && $("#target").val() != ""){
					$("input.redirect").each (function (){
						if ($(this).val() != ""){
							new mw.Api().create( $(this).val(),
								{ summary: 'إنشاء تحويلة بواسطة [[وب:منتح]]' },
								'#تحويل [['+$("#target").val()+"]]"
							);
						}
					});
					alert ("تم إنشاء التحويلات بنجاح!");
				}
		});
}