پرش به محتوا

مدیاویکی:Gadget-UserMessages.js: تفاوت میان نسخه‌ها

از دانشنامه علوم انسانی
imported>Yamaha5
بدون خلاصۀ ویرایش
imported>Ebrahim
عدم استفاده از mw.Uri
 
(۱۵۲ نسخهٔ میانی ویرایش شده توسط ۱۰ کاربر نشان داده نشد)
خط ۱: خط ۱:
/*
/**
<<<<<<<<<< derived from [[n:en:MediaWiki:Gadget-UserMessages.js]] and [[n:MediaWiki:Gadget-UserMessages.js]] for fa.wikipeida.org >>>>>>>>>>
* This gadget is a substantial rewrite of the UserMessages gadget, influenced by
==Automatic user messages ==
* [[n:en:MediaWiki:Gadget-UserMessages.js]] and [[n:MediaWiki:Gadget-UserMessages.js]]
Installing this script as described on the talk page will give you links in the toolbox
*
for all pages in the User talk: namespace, that say 'Please tag', 'Please name', and
* Unlike the previous versions, this uses OOUI and can accept one or more
'Please link'. Clicking any of the buttons will add one of the following templates to
* parameters for the messages that are being posted on the user's talk page.
the user's talk page, signed by you:
  */
*{{tl|Welcome}}
Main code by [[User:Siebrand]], derived from [[MediaWiki:Quick-delete.js]] by
[[:en:User:Jietse Niesen|Jietse Niesen]], [[User:pfctdayelise|pfctdayelise]] and
[[User:Alphax|Alphax]].
   
Code stolen from Commons by [[User:ShakataGaNai]] for Wikinews (Fixed by Bawolff)
* [[:Category:Block templates]]
* [[:Category:User_talk_templates]]
===TODO===
* Do not add a trailing /<langcode> at the end of the subst'ed template, as they now (almost) all use the autotranslation mechanism (see [[Commons:Template_i18n/User_templates]])
*/
// <source lang="javascript">
//moved here from commons
function getParamValue(paramName, url) {
  if (typeof url == "undefined") {
    url = document.location.href;
  }
  var cmdRe = RegExp("[&?]" + paramName + "=([^&]*)");
  var m = cmdRe.exec(url);
  if (m) {
    try {
      return decodeURIComponent(m[1]);
    } catch (someError) {}
  }
  return null;
}
//end moved here from commons
// Configuration


// Should the edits be saved automatically?
(function($, mw) {
if (window.template_autosave == false) {} else {
  'use strict';
  template_autosave = true;
  var windowManager;
}
  var UM;
  var UMOptions = {
    install: function() {
      if (mw.config.get('wgAction') === 'view' | (mw.config.get('wgAction') === 'edit' & mw.config.get('wgCurRevisionId') === 0)) {
        $(mw.util.addPortletLink( 'p-cactions', '#', 'اعلان', 'ca-warn', 'درج یک اعلان مبتنی بر الگو', '*')).click(function(e) {
          mw.loader.using(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.api']).done(UMOptions.createWindow);
          e.preventDefault();
        });
        // Late pre-loading
        mw.loader.load(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.api']);
      }
    },
    createWindow: function() {
      function PreviewPanel(config) {
        PreviewPanel.parent.call(this, config);
       
        this.$content = $('<div>').addClass('oo-ui-PreviewPanel');
      }
      OO.inheritClass(PreviewPanel, OO.ui.PanelLayout);
      PreviewPanel.prototype.setContent = function ($content) {
        this.$element.children().detach();
        this.$element.append($content);
        windowManager.getCurrentWindow().updateSize();
      };
      function UserMessages(config) {
        UserMessages.super.call(this, config);
      }
      OO.inheritClass(UserMessages, OO.ui.ProcessDialog);
      UserMessages.static.name = 'Warn dialog';
      UserMessages.static.title = 'درج اعلان (پیام یا تذکر)';
      UserMessages.static.actions = [
        {
          action: 'warn',
          label: 'ثبت',
          flags: ['primary', 'progressive']
        },
        {
          action: 'diff',
          label: 'نمایش تفاوت',
          flags: 'safe'
        },
        {
          label: 'لغو',
          flags: 'safe'
        }
      ];
      UserMessages.prototype.initialize = function() {
        var dialog = this;
        UserMessages.super.prototype.initialize.apply(this, arguments);
       
        this.buttons = [];
        this.buttons.Groups = [];
        this.buttons.Noobs = [];
        this.buttons.Warnings = [];
        this.buttons.Tools = [];
        this.buttons.Article = [];
        this.buttons.Copyright = [];
        this.buttons.Advanced = [];
        this.buttons.Spam = [];
        this.buttons.Block = [];
        this.buttons.Rights = [];


template_pagename = "نام مقاله را بنویسید:";
        this.buttons.Groups.Noobs = new OO.ui.ButtonOptionWidget({
template_what = "با چی؟";
          label: 'تازه‌کاران',
          data: {
            group: 'Noobs'
          }
        });
        this.buttons.Groups.Warnings = new OO.ui.ButtonOptionWidget({
          label: 'هشدارها',
          data: {
            group: 'Warnings'
          }
        });
        this.buttons.Groups.Tools = new OO.ui.ButtonOptionWidget({
          label: 'ابزارها',
          data: {
            group: 'Tools'
          }
        });
        this.buttons.Groups.Article = new OO.ui.ButtonOptionWidget({
          label: 'مقاله',
          data: {
            group: 'Article'
          }
        });
        this.buttons.Groups.Copyright = new OO.ui.ButtonOptionWidget({
          label: 'حق تکثیر',
          data: {
            group: 'Copyright'
          }
        });
        this.buttons.Groups.Advanced = new OO.ui.ButtonOptionWidget({
          label: 'پیشرفته',
          data: {
            group: 'Advanced'
          }
        });
        this.buttons.Groups.Spam = new OO.ui.ButtonOptionWidget({
          label: 'هرزنگاری',
          data: {
            group: 'Spam'
          }
        });
        this.buttons.Groups.Block = new OO.ui.ButtonOptionWidget({
          label: 'بستن',
          data: {
            group: 'Block'
          }
        });
        this.buttons.Groups.Rights = new OO.ui.ButtonOptionWidget({
          label: 'دسترسی',
          data: {
            group: 'Rights'
          }
        });


uMessage = new Array();
        this.buttonSelectGroups = new OO.ui.ButtonSelectWidget({
          items: [
            this.buttons.Groups.Noobs,
            this.buttons.Groups.Warnings,
            this.buttons.Groups.Tools,
            this.buttons.Groups.Article,
            this.buttons.Groups.Copyright,
            this.buttons.Groups.Advanced,
            this.buttons.Groups.Spam
          ]
        });
        if ($(mw.config.get('wgUserGroups')).filter(['eliminator', 'sysop']).length > 0) {
          this.buttonSelectGroups.addItems([
            this.buttons.Groups.Block
          ]);
        }
        if ($(mw.config.get( 'wgUserGroups' )).filter(['sysop']).length > 0) {
          this.buttonSelectGroups.addItems([
            this.buttons.Groups.Rights
          ]);
        }
        this.buttonSelectGroups.selectItem(this.buttons.Groups.Noobs);
        this.buttonSelectGroups.on('choose', function(item) {
          dialog.buttonSelectChoices = new OO.ui.ButtonSelectWidget({
            items: dialog.buttonSelectChoicesItems[item.data.group]
          });
          dialog.buttonSelectChoices.selectItem();
          dialog.panelChoices.$element.children().detach();
          dialog.panelChoices.$element.append(dialog.buttonSelectChoices.$element);
          dialog.setChooseAction();
          dialog.panelParams.toggle(false);
          dialog.previewResult.toggle(false);
          windowManager.getCurrentWindow().updateSize();
        });


uMessage.push(['خوشامدید', 'خوشامد > کاربر', 'خوشامدید', false]);
        this.buttons.Noobs.WelcomeUser = new OO.ui.ButtonOptionWidget({
uMessage.push(['خوشامد-آی\u200cپی', 'خوشامد > آی‌پی', 'خوشامد-آی\u200cپی', false]);
          label: 'خوشامد (کاربر)',
uMessage.push(['امضا کنید', 'کاربر جدید > امضا کنید', 'کاربر جدید > امضا کنید', false]);
          data: {
uMessage.push(['کاربر جدید/صفحه کلید فارسی', 'کاربر جدید > صفحه‌کلید فارسی', 'کاربر جدید > صفحه کلید فارسی', false]);
            template: 'خوشامد',
uMessage.push(['کاربر جدید/به ویکی‌فا', 'کاربر جدید  > ابزار به ویکی‌فا', 'کاربر جدید > ابزار به ویکی‌فا', false]);
            params: [
uMessage.push(['کاربر جدید/ابزار کمک\u200cمترجم', 'کاربر جدید > ابزار کمک‌مترجم', 'کاربر جدید > ابزار کمک\u200cمترجم', false]);
              {
uMessage.push(['کاربر جدید/ابزارهای ویرایشی', 'کاربر جدید > ابزارهای ویرایشی', 'کاربر جدید > ابزارهای ویرایشی', false]);
                id: '1',
uMessage.push(['از پیش\u200cنمایش استفاده کنید', 'از پیش‌نمایش استفاده کنید', 'از پیش\u200cنمایش استفاده کنید', false]);
                label: 'پیام تکمیلی (اختیاری)'
uMessage.push(['تذکر خلاصه ویرایش', 'خلاصه ویرایش بنویسید', 'تذکر خلاصه ویرایش', false]);
              }
uMessage.push(['کاربر جدید/ویکی\u200cنویسی', 'مقاله > روش مقاله‌نویسی شما', 'مقاله > روش مقاله نویسی', template_pagename]);
            ]
uMessage.push(['نوشتار نامناسب', 'مقاله > نوشتار کتره‌ای', 'مقاله > نوشتار کتره‌ای', false]);
          }
uMessage.push(['بیش از حد کوتاه', 'مقاله > بیش از حد کوتاه', 'مقاله > بیش از حد کوتاه', template_pagename]);
        });
uMessage.push(['از تغییرمسیر استفاده کنید', 'تغییرمسیر > ساخت تغییرمسیر برای موضع مشابه', 'تغییرمسیر > ساخت تغییرمسیر برای موضع مشابه', false]);
        this.buttons.Noobs.WelcomeIP = new OO.ui.ButtonOptionWidget({
uMessage.push(['کاربر جدید/حداقل\u200cهای مقاله', 'مقاله > حداقل‌های مقاله/ترجمه', 'مقاله > حداقل\u200cهای مقاله', false]);
          label: 'خوشامد (آی‌پی)',
uMessage.push(['تبلیغ مکنید', 'هرزنگاری > تبلیغ مکنید', 'هرزنگاری > تبلیغ مکنید', template_pagename]);
          data: {
uMessage.push(['پیام سرشناسی', 'هرزنگاری > سرشناسی', 'هرزنگاری > سرشناسی', template_pagename]);
            template: 'خوشامد-آی‌پی'
uMessage.push(['کپی مکنید', 'حق‌تکثیر > کپی مکنید', 'حق تکثیر > کپی مکنید', template_pagename]);
          }
uMessage.push(['کاربر جدید/لطفا کپی نکنید!', 'حق‌تکثیر > لطفا کپی نکنید!', 'حق تکثیر > لطفا کپی نکنید!', false]);
        });
uMessage.push(['کاربر جدید/منابع معتبر', 'حق‌تکثیر > منابع معتبر، تحقیق', 'حق تکثیر > منابع معتبر', false]);
        this.buttons.Noobs.Sign = new OO.ui.ButtonOptionWidget({
uMessage.push(['یادکرد دقیق منبع', 'حق‌تکثیر > یادکرد دقیق منبع', 'حق تکثیر > یادکرد دقیق منبع', template_pagename]);
          label: 'امضا کنید',
uMessage.push(['کاربر جدید/ارجاع صحیح', 'حق‌تکثیر > ارجاع صحیح', 'حق تکثیر > ارجاع صحیح', false]);
          data: {
uMessage.push(['کاربر جدید/مجوز نگاره', 'حق‌تکثیر > مجوز نگاره', 'حق تکثیر > مجوز نگاره', false]);
            template: 'امضا کنید',
uMessage.push(['کاربر جدید/هشدار نقض حق تکثیر', 'حق‌تکثیر > بارگذاری نگاره دارای حق تکثیر', 'حق‌تکثیر > بارگذاری نگاره دارای حق تکثیر', false]);
            params: [
uMessage.push(['کاربر جدید/مختصات\u200cدهی', 'افزودن > مختصات‌دهی', 'افزودن > مختصات\u200cدهی', false]);
              {
uMessage.push(['کاربر جدید/رده\u200cدهی', 'افزودن > رده‌بندی', 'افزودن > رده\u200cدهی', false]);
                id: '1',
uMessage.push(['کاربر جدید/میان\u200cویکی', 'افزودن > میان‌ویکی', 'افزودن > میان\u200cویکی', false]);
                label: 'پیام تکمیلی (اختیاری)'
uMessage.push(['اشتباه گرفته\u200cاید', 'هشدار > اشتباه گرفته‌اید', 'هشدار > اشتباه گرفته\u200cاید', template_what]);
              }
uMessage.push(['کاربر:جعبه کاربر/جدید/سره ننویسید', 'هرزنگاری > سره ننویسید', 'هرزنگاری > سره ننویسید', template_pagename]);  
            ]
uMessage.push(['هشدار نقض قانون سه برگردان', 'هشدار > نقض قانون ۳برگردان', 'هشدار > نقض قانون سه برگردان', template_pagename]);
          }
        });
        this.buttons.Noobs.DoNotSign = new OO.ui.ButtonOptionWidget({
          label: 'امضا مکنید',
          data: {
            template: 'امضا مکنید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.Ping = new OO.ui.ButtonOptionWidget({
          label: 'آگاه‌سازی کنید',
          data: {
            template: 'آموزش آگاه‌سازی'
          }
        });
        this.buttons.Noobs.UploadGuide = new OO.ui.ButtonOptionWidget({
          label: 'بارگذاری در ویکی‌فا (منصفانه)',
          data: {
            template: 'راهنمای بارگذاری پرونده در ویکی‌فا'
          }
        });
        this.buttons.Noobs.CommonsGuide = new OO.ui.ButtonOptionWidget({
          label: 'بارگذاری در ویکی‌انبار (آزاد)',
          data: {
            template: 'راهنمای بارگذاری پرونده در ویکی‌انبار'
          }
        });
        this.buttons.Noobs.Keyboard = new OO.ui.ButtonOptionWidget({
          label: 'صفحه کلید فارسی',
          data: {
            template: 'استفاده از صفحه کلید فارسی'
          }
        });
        this.buttons.Noobs.Preview = new OO.ui.ButtonOptionWidget({
          label: 'عدم ذخیره متعدد',
          data: {
            template: 'از پیش‌نمایش استفاده کنید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.SisterProjects = new OO.ui.ButtonOptionWidget({
          label: 'ویکی خواهر',
          data: {
            template: 'ویرایش در ویکی‌های خواهر',
            params: [
              {
                id: '1',
                label: 'نام پروژهٔ خواهر (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.EditSummary = new OO.ui.ButtonOptionWidget({
          label: 'خلاصه ویرایش',
          data: {
            template: 'تذکر خلاصه ویرایش'
          }
        });
        this.buttons.Noobs.Sandbox = new OO.ui.ButtonOptionWidget({
          label: 'صفحه تمرین',
          data: {
            template: 'صفحه تمرین'
          }
        });
        this.buttons.Noobs.FakeArticle = new OO.ui.ButtonOptionWidget({
          label: 'صفحهٔ کاربری مقاله‌نما',
          data: {
            template: 'هشدار مقاله‌نما',
            params: [
              {
                id: '1',
                label: 'نام صفحه (اختیاری)'
              }
            ]
          }
        });
this.buttons.Noobs.SeggestedLinks = new OO.ui.ButtonOptionWidget({
          label: 'پیوندهای پیشنهادی',
          data: {
            template: 'راهنمای پیوندهای پیشنهادی',
            params: [
              {
                id: '1',
                label: 'نام صفحه (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.Vandalism = new OO.ui.ButtonOptionWidget({
          label: 'هشدار خرابکاری',
          data: {
            template: 'تذکر خرابکاری'
          }
        });
        this.buttons.Warnings.VandalismFinal = new OO.ui.ButtonOptionWidget({
          label: 'آخرین هشدار خرابکاری',
          data: {
            template: 'تذکر خرابکاری (آخرین)'
          }
        });
        this.buttons.Warnings.EditWar = new OO.ui.ButtonOptionWidget({
          label: 'هشدار جنگ ویرایشی',
          data: {
            template: 'هشدار جنگ ویرایشی ۲',
            params: [
              {
                id: '1',
                label: 'نام صفحه (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.WP_3RR = new OO.ui.ButtonOptionWidget({
          label: 'هشدار نقض ۳ برگردان',
          data: {
            template: 'هشدار نقض قانون سه‌برگردان',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.Disruption = new OO.ui.ButtonOptionWidget({
          label: 'هشدار اخلالگری',
          data: {
            template: 'هشدار ویرایش اخلالگرانه',
            params: [
              {
                id: '1',
                label: 'نام صفحه (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.Responsiveness = new OO.ui.ButtonOptionWidget({
          label: 'هشدار پاسخگویی',
          data: {
            template: 'پاسخ به بحث'
          }
        });
        this.buttons.Warnings.SockPupptery = new OO.ui.ButtonOptionWidget({
          label: 'هشدار زاپاس‌بازی',
          data: {
            template: 'تذکر زاپاس'
          }
        });
        this.buttons.Warnings.NPA = new OO.ui.ButtonOptionWidget({
          label: 'هشدار حملهٔ شخصی',
          data: {
            template: 'حمله شخصی نکنید'
          }
        });
        this.buttons.Tools.VE = new OO.ui.ButtonOptionWidget({
          label: 'ویرایشگر دیداری',
          data: {
            template: 'کار با ویرایشگر دیداری'
          }
        });
        this.buttons.Tools.ToWikifa = new OO.ui.ButtonOptionWidget({
          label: 'به ویکی‌فا',
          data: {
            template: 'به ویکی‌فا'
          }
        });
        this.buttons.Tools.Translator = new OO.ui.ButtonOptionWidget({
          label: 'کمک‌مترجم',
          data: {
            template: 'ابزار کمک‌مترجم'
          }
        });
        this.buttons.Tools.ExtraEditTools = new OO.ui.ButtonOptionWidget({
          label: 'ابزارهای ویرایشی',
          data: {
            template: 'ابزارهای ویرایشی'
          }
        });
        this.buttons.Tools.Abar = new OO.ui.ButtonOptionWidget({
          label: 'ابرابزار',
          data: {
            template: 'ابرابزار'
          }
        });
        this.buttons.Tools.Applications = new OO.ui.ButtonOptionWidget({
          label: 'ابزارهای کاربردی',
          data: {
            template: 'ابزارهای کاربردی'
          }
        });
        this.buttons.Tools.ProveIt = new OO.ui.ButtonOptionWidget({
          label: 'ابزار اثباتش کن',
          data: {
            template: 'اثباتش کن'
          }
        });
        this.buttons.Tools.AWD = new OO.ui.ButtonOptionWidget({
          label: 'ویرایشگر خودکار',
          data: {
            template: 'ویرایشگر خودکار'
          }
        });
        this.buttons.Tools.Patrol = new OO.ui.ButtonOptionWidget({
          label: 'ابزار گشت سریع',
          data: {
            template: 'ابزار گشت‌زنی سریع'
          }
        });
        this.buttons.Tools.CheckDictation = new OO.ui.ButtonOptionWidget({
          label: 'اشتباه‌یاب',
          data: {
            template: 'ابزار اشتباه‌یاب'
          }
        });


// Site info
        this.buttons.Article.Featured = new OO.ui.ButtonOptionWidget({
scriptPath = "/w/index.php";
          label: 'برگزیده/خوبیده',
prettyPath = "/wiki/";
          data: {
wikiHostname = "fa.wikipedia.org";
            template: 'تذکر محتوای برگزیده'
          }
        });
        this.buttons.Article.Tutorial = new OO.ui.ButtonOptionWidget({
          label: 'آموزش ویکی‌نویسی',
          data: {
            template: 'ویکی‌نویسی'
          }
        });
        this.buttons.Article.Student = new OO.ui.ButtonOptionWidget({
          label: 'ویرایش دانشجویی',
          data: {
            template: 'ویرایش دانشجویی'
          }
        });
        this.buttons.Article.Incomplete = new OO.ui.ButtonOptionWidget({
          label: 'نوشتار نامناسب',
          data: {
            template: 'نوشتار نامناسب',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.TooShort = new OO.ui.ButtonOptionWidget({
          label: 'زیادی کوتاه',
          data: {
            template: 'بیش از حد کوتاه',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.Minima = new OO.ui.ButtonOptionWidget({
          label: 'حداقل‌ها',
          data: {
            template: 'حداقل‌های مقاله'
          }
        });
        this.buttons.Article.Deleted = new OO.ui.ButtonOptionWidget({
          label: 'حذف شده',
          data: {
            template: 'مقاله حذف شده',
            params: [
              {
                id: '1',
                label: 'پیام تکمیلی (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.Redirect = new OO.ui.ButtonOptionWidget({
          label: 'تغییرمسیر',
          data: {
            template: 'از تغییرمسیر استفاده کنید'
          }
        });
        this.buttons.Article.Move = new OO.ui.ButtonOptionWidget({
          label: 'انتقال',
          data: {
            template: 'از انتقال استفاده کنید'
          }
        });
        this.buttons.Article.Titles = new OO.ui.ButtonOptionWidget({
          label: 'القاب ممنوع',
          data: {
            template: 'هشدار القاب ممنوع'
          }
        });
        this.buttons.Article.Spoiler = new OO.ui.ButtonOptionWidget({
          label: 'مخدوش‌کردن داستان فیلم',
          data: {
            template: 'خلاصه داستان را مخدوش نکنید'
          }
        });
        this.buttons.Article.MachineTranslation = new OO.ui.ButtonOptionWidget({
          label: 'ترجمه ماشینی',
          data: {
            template: 'ترجمه ماشینی ممنوع',
            params: [
              {
                id: '1',
                label: 'عنوان صفحه (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.NoFlag = new OO.ui.ButtonOptionWidget({
          label: 'پرچم نزنید',
          data: {
            template: 'پرچم نزنید'
          }
        });
        this.buttons.Copyright.DoNotCopy = new OO.ui.ButtonOptionWidget({
          label: 'کپی مکنید',
          data: {
            template: 'کپی مکنید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Copyright.UseCitation = new OO.ui.ButtonOptionWidget({
          label: 'یادکرد دقیق',
          data: {
            template: 'یادکرد دقیق منبع',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Copyright.CiteNotCopy = new OO.ui.ButtonOptionWidget({
          label: 'ارجاع به جای کپی',
          data: {
            template: 'نحوه استفاده از مقالات علمی'
          }
        });
        this.buttons.Copyright.ReliableSources = new OO.ui.ButtonOptionWidget({
          label: 'منابع معتبر',
          data: {
            template: 'منابع معتبر'
          }
        });
        this.buttons.Copyright.CitationTutorial = new OO.ui.ButtonOptionWidget({
          label: 'آموزش یادکرد',
          data: {
            template: 'ارجاع صحیح'
          }
        });
        this.buttons.Copyright.License = new OO.ui.ButtonOptionWidget({
          label: 'مجوز نگاره',
          data: {
            template: 'مجوز نگاره'
          }
        });
        this.buttons.Copyright.Copyvio = new OO.ui.ButtonOptionWidget({
          label: 'هشدار نگاره',
          data: {
            template: 'هشدار نقض حق تکثیر'
          }
        });
        this.buttons.Copyright.Ownership = new OO.ui.ButtonOptionWidget({
          label: 'قانون مالکیت',
          data: {
            template: 'هشدار نقض قانون مالکیت محتوا'
          }
        });


// From [[en:Wikipedia:WikiProject User scripts/Scripts/addLink]]
        this.buttons.Advanced.Coord = new OO.ui.ButtonOptionWidget({
function addLink(where, url1, name1, id, title, key, after, url2, name2) {
          label: 'مختصات',
  //* where is the id of the toolbar where the button should be added;
          data: {
  //  i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
            template: 'آموزش سریع الگوی مختصات'
  //
          }
  //* url1 is the URL which will be called when the button is clicked.
        });
  //  javascript: urls can be used to do more complex things.
        this.buttons.Advanced.Categories = new OO.ui.ButtonOptionWidget({
  //
          label: 'رده‌بندی',
  //* name1 is what will appear as the name of the button.
          data: {
  //
            template: 'رده‌دهی'
  //* id is the id of the button; it's best to define one.
          }
  //  Use a prefix to make sure its unique. Optional.
        });
  //
        this.buttons.Advanced.Interwiki = new OO.ui.ButtonOptionWidget({
  //* title is the tooltip title that gives a longer description
          label: 'میان‌ویکی',
  //  of the button; if you define a accesskey, mention it here. Optional.
          data: {
  //
            template: 'افزودن میان‌ویکی'
  //* key is the char you want for the accesskey. Optional.
          }
  //
        });
  //* after is the id of the button you want to follow this one. Optional.
  //
  //* url2 is a second url to add. Optional
  //
  //*name2 is the name of the second url; defaults to name1. Optional
  var na = document.createElement('a');
  na.href = url1;
  na.appendChild(document.createTextNode(name1));
  var li = document.createElement('li');
  if (id) li.id = id;
  li.appendChild(na);


  if (url2) { //Another link, brother of the previous.
        this.buttons.Spam.Advertisement = new OO.ui.ButtonOptionWidget({
    var na = document.createElement('a');
          label: 'تبلیغ',
    na.href = url2;
          data: {
    na.appendChild(document.createTextNode(name2 ? name2 : name1));
            template: 'تبلیغ مکنید',
    li.appendChild(document.createTextNode(" · ")); //separate them a bit
            params: [
    li.appendChild(na);
              {
  }
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Notability = new OO.ui.ButtonOptionWidget({
          label: 'سرشناسی',
          data: {
            template: 'پیام سرشناسی',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              },
              {
                id: '2',
                label: 'پیام تکمیلی (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Sereh = new OO.ui.ButtonOptionWidget({
          label: 'سره‌نویسی',
          data: {
            template: 'سره ننویسید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Autobiography = new OO.ui.ButtonOptionWidget({
          label: 'خودنوشته',
          data: {
            template: 'خودنوشته'
          }
        });
        this.buttons.Spam.WP_NOT = new OO.ui.ButtonOptionWidget({
          label: 'اشتباه گرفته‌اید',
          data: {
            template: 'اشتباه گرفته‌اید',
            params: [
              {
                id: '1',
                label: 'با چه اشتباه گرفته؟ (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Username = new OO.ui.ButtonOptionWidget({
          label: 'نام کاربری',
          data: {
            template: 'نام کاربری نامناسب',
            params: [
              {
                id: '1',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Canvassing = new OO.ui.ButtonOptionWidget({
          label: 'جارزنی',
          data: {
            template: 'جارزنی'
          }
        });


  var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
        this.buttons.Block.Username = new OO.ui.ButtonOptionWidget({
  if (after) {
          label: 'نام کاربری نامناسب',
    tabs.insertBefore(li, document.getElementById(after));
          data: {
  } else {
            template: 'بستن نام تبلیغی'
    tabs.appendChild(li);
          }
  }
        });
  //akeytt is deprected and does nothing. who cares about access keys anyhow.
        this.buttons.Block.OneDay = new OO.ui.ButtonOptionWidget({
  /*if(id && ta) { //ta does not exist in vector?
          label: 'یک‌روزه',
        if(key && title) { ta[id] = [key, title]; }
          data: {
        else if(key) { ta[id] = [key, '']; }
            template: 'قطع دسترسی موقت',
        else if(title) { ta[id] = ['', title];}
            params: [
    }
              {
    // re-render the title and accesskeys from existing code in wikibits.js
                id: 'دلیل',
    akeytt();*/
                label: 'دلیل (اختیاری)'
  return li;
              }
}
            ]
          }
        });
        this.buttons.Block.Indefinite = new OO.ui.ButtonOptionWidget({
          label: 'بی‌پایان',
          data: {
            template: 'قطع دسترسی بی‌پایان',
            params: [
              {
                id: 'دلیل',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.Detailed = new OO.ui.ButtonOptionWidget({
          label: 'با ذکر مدت و دلیل',
          data: {
            template: 'قطع دسترسی',
            params: [
              {
                id: 'مدت',
                label: 'مدت (اختیاری)'
              },
              {
                id: 'دلیل',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.Partial = new OO.ui.ButtonOptionWidget({
          label: 'موردی',
          data: {
            template: 'قطع دسترسی موردی',
            params: [
              {
                id: 'صفحات',
                label: 'صفحه‌ها (مثل [[فلان]] و [[بهمان]])'
              },
              {
                id: 'فضای نام',
                label: 'فضای نام (بین موارد «و» بگذارید)'
              },
              {
              id: 'عمل‌ها',
              label: 'عمل‌ها (بین موارد «و» بگذارید)'
             
              },
              {
                id: 'مدت',
                label: 'مدت (اختیاری)'
              },
              {
                id: 'دلیل',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.AbuseFilter = new OO.ui.ButtonOptionWidget({
          label: 'اشتباه پالایه',
          data: {
            template: 'پوزش پالایه'
          }
        });


// Add the template
        this.buttons.Rights.Autopatrol = new OO.ui.ButtonOptionWidget({
function template_mark(talkpage_fakeaction, message_lang) {
          label: 'گشت خودکار',
  //if (!message_lang) return; //User pressed cancel
          data: {
            template: 'اعطای گشت خودکار'
          }
        });
        this.buttons.Rights.Revert = new OO.ui.ButtonOptionWidget({
          label: 'واگردان',
          data: {
            template: 'اعطای واگردان'
          }
        });
        this.buttons.Rights.Patroller = new OO.ui.ButtonOptionWidget({
          label: 'گشت‌زن',
          data: {
            template: 'اعطای گشت‌زن'
          }
        });
        this.buttons.Rights.TemplateEditor = new OO.ui.ButtonOptionWidget({
          label: 'ویرایشگر الگو',
          data: {
            template: 'اعطای ویرایشگر الگو'
          }
        });
        this.buttons.Rights.ExtendedMover = new OO.ui.ButtonOptionWidget({
          label: 'انتقال‌دهنده پیشرفته',
          data: {
            template: 'اعطای انتقال‌دهنده پیشرفته'
          }
        });
        this.buttons.Rights.Eliminator = new OO.ui.ButtonOptionWidget({
          label: 'ویکی‌بان',
          data: {
            template: 'اعطای ویکی‌بان'
          }
        });
        this.buttons.Rights.ReinstateEliminator = new OO.ui.ButtonOptionWidget({
          label: 'تمدید ویکی‌بانی',
          data: {
            template: 'تمدید ویکی‌بانی'
          }
        });
        this.buttons.Rights.Sysop = new OO.ui.ButtonOptionWidget({
          label: 'مدیر',
          data: {
            template: 'اعطای مدیریت'
          }
        });
        this.buttons.Rights.tofawikiAlot = new OO.ui.ButtonOptionWidget({
          label: 'به‌ویکی‌فا انبوه',
          data: {
            template: 'اعطای دسترسی به‌ویکی‌فا انبوه'
          }
        });


  //Now we assume message templates to be properly autotranslated
        this.buttonSelectChoicesItems = [];
  if (message_lang) langparam = '&template_lang=' + message_lang;
        this.buttonSelectChoicesItems.Noobs = [
  else langparam = '';
          this.buttons.Noobs.WelcomeUser,
          this.buttons.Noobs.WelcomeIP,
          this.buttons.Noobs.Sign,
          this.buttons.Noobs.DoNotSign,
          this.buttons.Noobs.Ping,
          this.buttons.Noobs.UploadGuide,
          this.buttons.Noobs.CommonsGuide,
          this.buttons.Noobs.Keyboard,
          this.buttons.Noobs.Preview,
          this.buttons.Noobs.Sandbox,
          this.buttons.Noobs.SisterProjects,
          this.buttons.Noobs.EditSummary,
          this.buttons.Noobs.FakeArticle,
          this.buttons.Noobs.SeggestedLinks
        ];
        this.buttonSelectChoicesItems.Warnings = [
          this.buttons.Warnings.Vandalism,
          this.buttons.Warnings.VandalismFinal,
          this.buttons.Warnings.EditWar,
          this.buttons.Warnings.WP_3RR,
          this.buttons.Warnings.Disruption,
          this.buttons.Warnings.Responsiveness,
          this.buttons.Warnings.SockPupptery,
          this.buttons.Warnings.NPA
        ];
        this.buttonSelectChoicesItems.Tools = [
          this.buttons.Tools.VE,
          this.buttons.Tools.ToWikifa,
          this.buttons.Tools.Translator,
          this.buttons.Tools.ExtraEditTools,
          this.buttons.Tools.Abar,
          this.buttons.Tools.Applications,
          this.buttons.Tools.ProveIt,
          this.buttons.Tools.AWD,
          this.buttons.Tools.Patrol,
          this.buttons.Tools.CheckDictation
        ];
        this.buttonSelectChoicesItems.Article = [
          this.buttons.Article.Featured,
          this.buttons.Article.Tutorial,
          this.buttons.Article.Student,
          this.buttons.Article.Incomplete,
          this.buttons.Article.TooShort,
          this.buttons.Article.Minima,
          this.buttons.Article.Deleted,
          this.buttons.Article.Redirect,
          this.buttons.Article.Move,
          this.buttons.Article.Titles,
          this.buttons.Article.Spoiler,
          this.buttons.Article.MachineTranslation,
          this.buttons.Article.NoFlag
        ];
        this.buttonSelectChoicesItems.Copyright = [
          this.buttons.Copyright.DoNotCopy,
          this.buttons.Copyright.UseCitation,
          this.buttons.Copyright.CiteNotCopy,
          this.buttons.Copyright.ReliableSources,
          this.buttons.Copyright.CitationTutorial,
          this.buttons.Copyright.License,
          this.buttons.Copyright.Copyvio,
          this.buttons.Copyright.Ownership
        ];
        this.buttonSelectChoicesItems.Advanced = [
          this.buttons.Advanced.Coord,
          this.buttons.Advanced.Categories,
          this.buttons.Advanced.Interwiki
        ];
        this.buttonSelectChoicesItems.Spam = [
          this.buttons.Spam.Advertisement,
          this.buttons.Spam.Notability,
          this.buttons.Spam.Sereh,
          this.buttons.Spam.Autobiography,
          this.buttons.Spam.WP_NOT,
          this.buttons.Spam.Username,
          this.buttons.Spam.Canvassing
        ];
        this.buttonSelectChoicesItems.Block = [
          this.buttons.Block.Username,
          this.buttons.Block.OneDay,
          this.buttons.Block.Indefinite,
          this.buttons.Block.Detailed,
          this.buttons.Block.Partial,
          this.buttons.Block.AbuseFilter
        ];
        this.buttonSelectChoicesItems.Rights = [
          this.buttons.Rights.Autopatrol,
          this.buttons.Rights.Revert,
          this.buttons.Rights.Patroller,
          this.buttons.Rights.TemplateEditor,
          this.buttons.Rights.ExtendedMover,
          this.buttons.Rights.Eliminator,
          this.buttons.Rights.ReinstateEliminator,
          this.buttons.Rights.Sysop,
          this.buttons.Rights.tofawikiAlot
        ];


  var pagename = encodeURIComponent(wgPageName);
        // The default choice
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
        this.buttonSelectChoices = new OO.ui.ButtonSelectWidget({
  document.location = editlk + '&fakeaction=' + talkpage_fakeaction + langparam + '&template_type=1';
          items: this.buttonSelectChoicesItems.Noobs
}
        });


// Add template to user talk page
        this.setChooseAction = function() {
function template_addTemplate(template) {
          dialog.buttonSelectChoices.on('choose', function(item) {
  if (getParamValue('template_lang')) {
            dialog.previewResult.toggle(false);
    template = template + '/' + getParamValue('template_lang');
            if (item.data !== undefined & item.data.params !== undefined) {
  }
              dialog.panelParams.toggle(true);
              dialog.buttonPreview.toggle(true);
              dialog.buttonReset.toggle(true);
              for (var i = 0; i < item.data.params.length; i++) {
                dialog.textParamLayouts[i].toggle(true);
                dialog.textParamLayouts[i].setLabel(item.data.params[i].label);
                dialog.textParamLayouts[i].setData(item.data.params[i].id);
              }
              for (i = item.data.params.length; i < 5; i++) {
                dialog.textParamLayouts[i].toggle(false);
              }
            } else {
              for (var k = 0; k < 5; k++) {
                dialog.textParamLayouts[k].toggle(false);
              }
              dialog.panelParams.toggle(true);
              dialog.buttonPreview.toggle(true);
              dialog.buttonReset.toggle(true);
            }
            windowManager.getCurrentWindow().updateSize();
          });        
        };
        this.setChooseAction();


  var txt = '{{subst:' + template + '}}';
        // The parameters
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + txt + '~~' + '~~';
        this.textParams = [];
  // the edit summary for when you mark the image. You can change it if you want.
        this.textParamLayouts = [];
  document.editform.wpSummary.value = 'الگوی «' + template + '» به بحث کاربر افزوده شد. ([[وپ:ابزار تذکر به کاربر جدید|با استفاده از ابزار]])';
  if (template_autosave) document.editform.wpSave.click();
}


// Add the template
        this.textParams[0] = new OO.ui.TextInputWidget({
function template_mark2(talkpage_fakeaction, media_name, can_handle_empty_parameter, add_namespace) {
          placeholder: 'متنی وارد کنید'
  if (media_name == null) return; // User pressed cancel
        });
  if (media_name == '' && can_handle_empty_parameter != 1) return; // User did not supply parameter and template cannot handle that
        this.textParams[1] = new OO.ui.TextInputWidget({
  // Parameter handling for special cases
          placeholder: 'متنی وارد کنید'
  if (add_namespace && media_name.length > 0) media_name = 'File:' + media_name;
        });
        this.textParams[2] = new OO.ui.TextInputWidget({
          placeholder: 'متنی وارد کنید'
        });
        this.textParams[3] = new OO.ui.TextInputWidget({
          placeholder: 'متنی وارد کنید'
        });
        this.textParams[4] = new OO.ui.TextInputWidget({
          placeholder: 'متنی وارد کنید'
        });
        this.textParamLayouts[0] = new OO.ui.FieldLayout( this.textParams[0], {
          label: 'پارامتر اول'
        });
        this.textParamLayouts[1] = new OO.ui.FieldLayout( this.textParams[1], {
          label: 'پارامتر دوم'
        });
        this.textParamLayouts[2] = new OO.ui.FieldLayout( this.textParams[2], {
          label: 'پارامتر سوم'
        });
        this.textParamLayouts[3] = new OO.ui.FieldLayout( this.textParams[3], {
          label: 'پارامتر چهارم'
        });
        this.textParamLayouts[4] = new OO.ui.FieldLayout( this.textParams[4], {
          label: 'پارامتر پنجم'
        });
        this.paramFieldset = new OO.ui.FieldsetLayout({
          items: this.textParamLayouts
        });
        this.buttonPreview = new OO.ui.ButtonWidget({
          label: 'پیش‌نمایش',
          icon: 'check',
          title: 'پیش‌نمایش',
          flags: 'progressive'
        });
        this.buttonPreview.on('click', function() {
          dialog.previewResult.toggle(true);
          dialog.previewResult.setContent(''); // Makes any previous preview results go away, so the user notices the change
          windowManager.getCurrentWindow().updateSize();
          var wikitext = UserMessages.prepareWikitext(dialog);
          var api = new mw.Api();
          api.get({
            action: 'parse',
            text: wikitext,
            pst: true
          }).done(function( data ) {
            dialog.previewResult.setContent($(data.parse.text['*']));
          });
        });
        this.buttonReset = new OO.ui.ButtonWidget({
          label: 'پاک کردن',
          icon: 'clear',
          title: 'پاک کردن',
          flags: 'destructive'
        });
        this.buttonReset.on('click', function() {
          for (var i = 0; i < 5; i++) {
              dialog.textParams[i].setValue('');
          }
          dialog.previewResult.toggle(false);
          dialog.buttonPreview.toggle(true);
          dialog.buttonReset.toggle(true);
          windowManager.getCurrentWindow().updateSize();
        });
        this.panelParams = new OO.ui.PanelLayout({
          expanded: true,
          padded: true
        });
        this.previewResult = new PreviewPanel({
          expanded: true,
          padded: true,
          $content: ''
        });
        this.previewResult.toggle(false);
        this.panelParams.$element.append(this.paramFieldset.$element);
        this.panelParams.$element.append(this.buttonPreview.$element);
        this.panelParams.$element.append(this.buttonReset.$element);
        for (var i = 0; i < 5; i++) {
            this.textParamLayouts[i].toggle(false);
        }
        this.buttonPreview.toggle(false);
        this.buttonReset.toggle(false);
        this.panelGroups = new OO.ui.PanelLayout({
          expanded: true,
          padded: true,
          classes: ['panelGroups']
        });
        this.panelGroups.$element.append(this.buttonSelectGroups.$element);
        this.panelChoices = new OO.ui.PanelLayout({
          expanded: true,
          padded: true,
          classes: ['panelChoices']
        });
        this.panelChoices.$element.append(this.buttonSelectChoices.$element);
        this.panelPreview = new OO.ui.PanelLayout({
          expanded: true,
          padded: true
        });
        this.panelPreview.$element.append(this.previewResult.$element);


  var pagename = encodeURIComponent(wgPageName);
        this.stackLayout = new OO.ui.StackLayout({
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
          items: [
  document.location = editlk + '&fakeaction=' + talkpage_fakeaction + '&media_name=' + encodeURIComponent(media_name) + '&template_type=2';
            this.panelGroups,
}
            this.panelChoices,
 
            this.panelParams,
// Add template to user talk page
            this.panelPreview
function template_addTemplate2(template) {
          ],
  if (getParamValue('media_name')) {
          continuous: true,
    template = template + '|' + getParamValue('media_name');
          scrollable: false
  }
        });
 
        this.$body.append(this.stackLayout.$element);
  var txt = '{{subst:' + template + '}}';
      };
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + txt + '~~' + '~~';
      UserMessages.prepareWikitext = function(dialog) {
  //  the edit summary for when you mark the image. You can change it if you want.
        var paramNames = [];
  document.editform.wpSummary.value = 'الگوی «' + template + '» به بحث کاربر افزوده شد. ([[وپ:ابزار تذکر به کاربران|ابزار تذکر به کاربران]])';
        var paramValues = [];
  if (template_autosave) document.editform.wpSave.click();
        var btn = dialog.buttonSelectChoices.findSelectedItem().getData();
}
        var wikitext = '{{subst:' + btn.template;
 
        for (var i = 0; i < 5; i ++) {
 
          paramNames[i] = dialog.textParamLayouts[i].getData();
// Do the thing with the stuff here.
          paramValues[i] = dialog.textParams[i].getValue();
function template_onload() {
          if (dialog.textParamLayouts[i].isVisible()) {
  if (wgNamespaceNumber == 3) { //NS_USERTALK
            wikitext += '|' + paramNames[i] + '=' + paramValues[i];
     // new section
          }
     try {
        }
       if (skin === 'vector') {
        wikitext += '}}';
         if (window.useFancyVectorDropdown || window.useFancyVectorDropdown === undefined) {
        return wikitext;
           try {
      };
            makeVectorFancySection();
      UserMessages.prototype.getSetupProcess = function(data) {
            useFancyVectorDropdown = 'done'; //this is for debug. can remove
        data = data || {};
           } catch (e) {
        return UserMessages.super.prototype.getSetupProcess.call( this, data )
            document.getElementById('panel').innerHTML += '<div id="p-Notify" class="portal"><h5 lang="fa" xml:lang="fa">تذکر</h5><div class="body"><ul> </ul> </div> </div>';
          .next( function () {
            // Do something
          }, this );
      };
      UserMessages.prototype.getActionProcess = function(action) {
        var dialog = this;
        if (action === 'warn' | action === 'diff') {
          var wikitext = UserMessages.prepareWikitext(dialog);
          wikitext += '\n~~' + '~~';
          var summary = 'افزودن «[[الگو:' + dialog.buttonSelectChoices.findSelectedItem().getData().template + ']]» به کمک [[ویکی‌پدیا:ابزار اعلان به کاربران|ابزار اعلان به کاربران]]';
          if (action === 'warn') {
            return new OO.ui.Process(function() {
              UMOptions.savePage(mw.config.get('wgPageName'), wikitext, summary, function() {
                location.reload();
              });
              dialog.close({
                action: action
              }).done(function() {
                // Page will be reloaded once saved
              });
            });
          } else { // action === 'diff'
            return new OO.ui.Process(function() {
              UMOptions.showDiff(
                mw.config.get('wgPageName'),
                wikitext,
                summary
              )
            });
          }
        }
        return UserMessages.super.prototype.getActionProcess.call(this, action);
      };
      if (!windowManager) {
        windowManager = new OO.ui.WindowManager();
        $('body').append(windowManager.$element);
      }
      UM = new UserMessages({
        size: 'large'
      });
      windowManager.addWindows([UM]);
      windowManager.openWindow(UM);
     },
     redirectPost: function(url, data) {
       var form = document.createElement('form');
         document.body.appendChild(form);
        form.method = 'post';
        form.action = url;
        for (var name in data) {
           var input = document.createElement('input');
          input.type = 'hidden';
          input.name = name;
          input.value = data[name];
           form.appendChild(input);
        }
      form.submit();
},
showDiff: function(title, text, summary) {
  var url = new URL(mw.config.get('wgScript'), window.location);
  url.searchParams.set('title', title);
  url.searchParams.set('action', 'submit');
      UMOptions.redirectPost(url.toString(), {
          wpTextbox1: text,
          wpDiff: '',
          wpSummary: '',
          wpSection: 'new',
          wpUltimateParam: 1
        }
      );
    },
    savePage: function(title, text, summary, callback) {
      (new mw.Api()).post({
        action: 'edit',
        title: title,
        summary: summary,
        appendtext: '\n' + text,
        token: mw.user.tokens.get('csrfToken')
      }).done(function(data) {
        if (data.error && data.error.info) {
          if (data.error.info == 'missingtitle') {
            mw.notify('صفحه ' + title + ' موجود نیست!', {
              type: 'error'
            });
          } else {
            mw.notify(data.error.info, {
              type: 'error'
            });
           }
           }
         } else {
         } else {
           document.getElementById('panel').innerHTML += '<div id="p-Notify" class="portal"><h5 lang="fa" xml:lang="fa">تذکر</h5><div class="body">\n <ul> </ul> </div> </div>';
           callback();
         }
         }
       }
       }).fail(function(data) {
      if (skin === 'monobook') {
         mw.notify(data);
         document.getElementById('column-one').innerHTML += '<div id="p-Notify" class="portlet"> <h5 lang="fa" xml:lang="fa">تذکر</h5> <div class="pBody"> <ul></ul></div> </div>';
       });
       }
     },
     } catch (e) {} //ignore errors and just use tb if they happen.
  };
    var portlet = (document.getElementById('p-Notify') ? 'p-Notify' : 'p-tb');
  if (mw.config.get('wgNamespaceNumber') === 3 | mw.config.get('wgPageName') === 'ویکی‌پدیا:صفحه_تمرین') {
 
    $(UMOptions.install);
    for (i = 0; i < uMessage.length; i++) {
      if (uMessage[i][3]) {
        addLink(portlet, 'javascript:template_mark2(\'' + i + '\', prompt(\'' + uMessage[i][3] + '\', \'\'), 0, false)', uMessage[i][1], 'mark-warn', uMessage[i][2]);
      } else {
        addLink(portlet, 'javascript:template_mark(\'' + i + '\')', uMessage[i][1],
          'mark-warn', uMessage[i][2], null, null);
      }
    }
   }
   }
  // Important thing and stuff above.
})(jQuery, mediaWiki);
 
  var fakeaction = getParamValue('fakeaction');
  var template_type = getParamValue('template_type'); // Fetch what template to add
 
  var action_idx = -1;
  try {
    action_idx = parseInt(fakeaction, 10);
  } catch (some_error) {
    action_idx = -1;
  }
  var add_idx = -1;
  try {
    add_idx = parseInt(template_type, 10);
  } catch (some_error) {
    add_idx = -1;
  }
  if (add_idx >= 1 && add_idx <= 2 && action_idx >= 0 && action_idx < uMessage.length) {
    //may i take this moment to mention, this script is very very confusing - bawolff
    if (wgNamespaceNumber !== 3) {
      alert("The user notify script has been disabled in this namespace for security reasons. If you see this message, please tell [[n:en:User:Bawolff]] what linked you clicked on to get here.");
      throw new Error("خطای امنیتی: فضای نامی اشتباه برای ابزار اطلاع رسانی.");
    }
    if (add_idx == 1) template_addTemplate(uMessage[action_idx][0]);
    else template_addTemplate2(uMessage[action_idx][0]);
  }
}
 
$(template_onload);
 
function makeVectorFancySection() {
  //wrap this in a try. this might be somewhat delicate at the moment.
  var pNotify = document.createElement('div');
  pNotify.id = 'p-Notify'
  pNotify.className = 'vectorMenu extraMenu'
  pNotify.innerHTML = ' <a href="#" style="background-image:none;"><h5><span>تذکر</span></a></h5> <div class="menu"> <ul lang="fa" xml:lang="fa"> </ul> </div>';
  var rightNav = document.getElementById('right-navigation');
  var pViews = document.getElementById('p-views');
  rightNav.insertBefore(pNotify, pViews.nextSibling)
}
// </source>

نسخهٔ کنونی تا ۵ مارس ۲۰۲۵، ساعت ۰۷:۱۳

/**
 * This gadget is a substantial rewrite of the UserMessages gadget, influenced by
 * [[n:en:MediaWiki:Gadget-UserMessages.js]] and [[n:MediaWiki:Gadget-UserMessages.js]]
 * 
 * Unlike the previous versions, this uses OOUI and can accept one or more
 * parameters for the messages that are being posted on the user's talk page.
 */

(function($, mw) {
  'use strict';
  var windowManager;
  var UM;
  var UMOptions = {
    install: function() {
      if (mw.config.get('wgAction') === 'view' | (mw.config.get('wgAction') === 'edit' & mw.config.get('wgCurRevisionId') === 0)) {
        $(mw.util.addPortletLink( 'p-cactions', '#', 'اعلان', 'ca-warn', 'درج یک اعلان مبتنی بر الگو', '*')).click(function(e) {
          mw.loader.using(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.api']).done(UMOptions.createWindow);
          e.preventDefault();
        });
        // Late pre-loading
        mw.loader.load(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.api']);
      }
    },
    createWindow: function() {
      function PreviewPanel(config) {
        PreviewPanel.parent.call(this, config);
        
        this.$content = $('<div>').addClass('oo-ui-PreviewPanel');
      }
      OO.inheritClass(PreviewPanel, OO.ui.PanelLayout);
      PreviewPanel.prototype.setContent = function ($content) {
        this.$element.children().detach();
        this.$element.append($content);
        windowManager.getCurrentWindow().updateSize();
      };
      function UserMessages(config) {
        UserMessages.super.call(this, config);
      }
      OO.inheritClass(UserMessages, OO.ui.ProcessDialog);
      UserMessages.static.name = 'Warn dialog';
      UserMessages.static.title = 'درج اعلان (پیام یا تذکر)';
      UserMessages.static.actions = [
        {
          action: 'warn',
          label: 'ثبت',
          flags: ['primary', 'progressive']
        },
        {
          action: 'diff',
          label: 'نمایش تفاوت',
          flags: 'safe'
        },
        {
          label: 'لغو',
          flags: 'safe'
        }
      ];
      UserMessages.prototype.initialize = function() {
        var dialog = this;
        UserMessages.super.prototype.initialize.apply(this, arguments);
        
        this.buttons = [];
        this.buttons.Groups = [];
        this.buttons.Noobs = [];
        this.buttons.Warnings = [];
        this.buttons.Tools = [];
        this.buttons.Article = [];
        this.buttons.Copyright = [];
        this.buttons.Advanced = [];
        this.buttons.Spam = [];
        this.buttons.Block = [];
        this.buttons.Rights = [];

        this.buttons.Groups.Noobs = new OO.ui.ButtonOptionWidget({
          label: 'تازه‌کاران',
          data: {
            group: 'Noobs'
          }
        });
        this.buttons.Groups.Warnings = new OO.ui.ButtonOptionWidget({
          label: 'هشدارها',
          data: {
            group: 'Warnings'
          }
        });
        this.buttons.Groups.Tools = new OO.ui.ButtonOptionWidget({
          label: 'ابزارها',
          data: {
            group: 'Tools'
          }
        });
        this.buttons.Groups.Article = new OO.ui.ButtonOptionWidget({
          label: 'مقاله',
          data: {
            group: 'Article'
          }
        });
        this.buttons.Groups.Copyright = new OO.ui.ButtonOptionWidget({
          label: 'حق تکثیر',
          data: {
            group: 'Copyright'
          }
        });
        this.buttons.Groups.Advanced = new OO.ui.ButtonOptionWidget({
          label: 'پیشرفته',
          data: {
            group: 'Advanced'
          }
        });
        this.buttons.Groups.Spam = new OO.ui.ButtonOptionWidget({
          label: 'هرزنگاری',
          data: {
            group: 'Spam'
          }
        });
        this.buttons.Groups.Block = new OO.ui.ButtonOptionWidget({
          label: 'بستن',
          data: {
            group: 'Block'
          }
        });
        this.buttons.Groups.Rights = new OO.ui.ButtonOptionWidget({
          label: 'دسترسی',
          data: {
            group: 'Rights'
          }
        });

        this.buttonSelectGroups = new OO.ui.ButtonSelectWidget({
          items: [
            this.buttons.Groups.Noobs,
            this.buttons.Groups.Warnings,
            this.buttons.Groups.Tools,
            this.buttons.Groups.Article,
            this.buttons.Groups.Copyright,
            this.buttons.Groups.Advanced,
            this.buttons.Groups.Spam
          ]
        });
        if ($(mw.config.get('wgUserGroups')).filter(['eliminator', 'sysop']).length > 0) {
          this.buttonSelectGroups.addItems([
            this.buttons.Groups.Block
          ]);
        }
        if ($(mw.config.get( 'wgUserGroups' )).filter(['sysop']).length > 0) {
          this.buttonSelectGroups.addItems([
            this.buttons.Groups.Rights
          ]);
        }
        this.buttonSelectGroups.selectItem(this.buttons.Groups.Noobs);
        this.buttonSelectGroups.on('choose', function(item) {
          dialog.buttonSelectChoices = new OO.ui.ButtonSelectWidget({
            items: dialog.buttonSelectChoicesItems[item.data.group]
          });
          dialog.buttonSelectChoices.selectItem();
          dialog.panelChoices.$element.children().detach();
          dialog.panelChoices.$element.append(dialog.buttonSelectChoices.$element);
          dialog.setChooseAction();
          dialog.panelParams.toggle(false);
          dialog.previewResult.toggle(false);
          windowManager.getCurrentWindow().updateSize();
        });

        this.buttons.Noobs.WelcomeUser = new OO.ui.ButtonOptionWidget({
          label: 'خوشامد (کاربر)',
          data: {
            template: 'خوشامد',
            params: [
              {
                id: '1',
                label: 'پیام تکمیلی (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.WelcomeIP = new OO.ui.ButtonOptionWidget({
          label: 'خوشامد (آی‌پی)',
          data: {
            template: 'خوشامد-آی‌پی'
          }
        });
        this.buttons.Noobs.Sign = new OO.ui.ButtonOptionWidget({
          label: 'امضا کنید',
          data: {
            template: 'امضا کنید',
            params: [
              {
                id: '1',
                label: 'پیام تکمیلی (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.DoNotSign = new OO.ui.ButtonOptionWidget({
          label: 'امضا مکنید',
          data: {
            template: 'امضا مکنید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.Ping = new OO.ui.ButtonOptionWidget({
          label: 'آگاه‌سازی کنید',
          data: {
            template: 'آموزش آگاه‌سازی'
          }
        });
        this.buttons.Noobs.UploadGuide = new OO.ui.ButtonOptionWidget({
          label: 'بارگذاری در ویکی‌فا (منصفانه)',
          data: {
            template: 'راهنمای بارگذاری پرونده در ویکی‌فا'
          }
        });
        this.buttons.Noobs.CommonsGuide = new OO.ui.ButtonOptionWidget({
          label: 'بارگذاری در ویکی‌انبار (آزاد)',
          data: {
            template: 'راهنمای بارگذاری پرونده در ویکی‌انبار'
          }
        });
        this.buttons.Noobs.Keyboard = new OO.ui.ButtonOptionWidget({
          label: 'صفحه کلید فارسی',
          data: {
            template: 'استفاده از صفحه کلید فارسی'
          }
        });
        this.buttons.Noobs.Preview = new OO.ui.ButtonOptionWidget({
          label: 'عدم ذخیره متعدد',
          data: {
            template: 'از پیش‌نمایش استفاده کنید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.SisterProjects = new OO.ui.ButtonOptionWidget({
          label: 'ویکی خواهر',
          data: {
            template: 'ویرایش در ویکی‌های خواهر',
            params: [
              {
                id: '1',
                label: 'نام پروژهٔ خواهر (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.EditSummary = new OO.ui.ButtonOptionWidget({
          label: 'خلاصه ویرایش',
          data: {
            template: 'تذکر خلاصه ویرایش'
          }
        });
        this.buttons.Noobs.Sandbox = new OO.ui.ButtonOptionWidget({
          label: 'صفحه تمرین',
          data: {
            template: 'صفحه تمرین'
          }
        });
        this.buttons.Noobs.FakeArticle = new OO.ui.ButtonOptionWidget({
          label: 'صفحهٔ کاربری مقاله‌نما',
          data: {
            template: 'هشدار مقاله‌نما',
            params: [
              {
                id: '1',
                label: 'نام صفحه (اختیاری)'
              }
            ]
          }
        });
		this.buttons.Noobs.SeggestedLinks = new OO.ui.ButtonOptionWidget({
          label: 'پیوندهای پیشنهادی',
          data: {
            template: 'راهنمای پیوندهای پیشنهادی',
            params: [
              {
                id: '1',
                label: 'نام صفحه (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.Vandalism = new OO.ui.ButtonOptionWidget({
          label: 'هشدار خرابکاری',
          data: {
            template: 'تذکر خرابکاری'
          }
        });
        this.buttons.Warnings.VandalismFinal = new OO.ui.ButtonOptionWidget({
          label: 'آخرین هشدار خرابکاری',
          data: {
            template: 'تذکر خرابکاری (آخرین)'
          }
        });
        this.buttons.Warnings.EditWar = new OO.ui.ButtonOptionWidget({
          label: 'هشدار جنگ ویرایشی',
          data: {
            template: 'هشدار جنگ ویرایشی ۲',
            params: [
              {
                id: '1',
                label: 'نام صفحه (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.WP_3RR = new OO.ui.ButtonOptionWidget({
          label: 'هشدار نقض ۳ برگردان',
          data: {
            template: 'هشدار نقض قانون سه‌برگردان',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.Disruption = new OO.ui.ButtonOptionWidget({
          label: 'هشدار اخلالگری',
          data: {
            template: 'هشدار ویرایش اخلالگرانه',
            params: [
              {
                id: '1',
                label: 'نام صفحه (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.Responsiveness = new OO.ui.ButtonOptionWidget({
          label: 'هشدار پاسخگویی',
          data: {
            template: 'پاسخ به بحث'
          }
        });
        this.buttons.Warnings.SockPupptery = new OO.ui.ButtonOptionWidget({
          label: 'هشدار زاپاس‌بازی',
          data: {
            template: 'تذکر زاپاس'
          }
        });
        this.buttons.Warnings.NPA = new OO.ui.ButtonOptionWidget({
          label: 'هشدار حملهٔ شخصی',
          data: {
            template: 'حمله شخصی نکنید'
          }
        });
        this.buttons.Tools.VE = new OO.ui.ButtonOptionWidget({
          label: 'ویرایشگر دیداری',
          data: {
            template: 'کار با ویرایشگر دیداری'
          }
        });
        this.buttons.Tools.ToWikifa = new OO.ui.ButtonOptionWidget({
          label: 'به ویکی‌فا',
          data: {
            template: 'به ویکی‌فا'
          }
        });
        this.buttons.Tools.Translator = new OO.ui.ButtonOptionWidget({
          label: 'کمک‌مترجم',
          data: {
            template: 'ابزار کمک‌مترجم'
          }
        });
        this.buttons.Tools.ExtraEditTools = new OO.ui.ButtonOptionWidget({
          label: 'ابزارهای ویرایشی',
          data: {
            template: 'ابزارهای ویرایشی'
          }
        });
        this.buttons.Tools.Abar = new OO.ui.ButtonOptionWidget({
          label: 'ابرابزار',
          data: {
            template: 'ابرابزار'
          }
        });
        this.buttons.Tools.Applications = new OO.ui.ButtonOptionWidget({
          label: 'ابزارهای کاربردی',
          data: {
            template: 'ابزارهای کاربردی'
          }
        });
        this.buttons.Tools.ProveIt = new OO.ui.ButtonOptionWidget({
          label: 'ابزار اثباتش کن',
          data: {
            template: 'اثباتش کن'
          }
        });
        this.buttons.Tools.AWD = new OO.ui.ButtonOptionWidget({
          label: 'ویرایشگر خودکار',
          data: {
            template: 'ویرایشگر خودکار'
          }
        });
        this.buttons.Tools.Patrol = new OO.ui.ButtonOptionWidget({
          label: 'ابزار گشت سریع',
          data: {
            template: 'ابزار گشت‌زنی سریع'
          }
        });
        this.buttons.Tools.CheckDictation = new OO.ui.ButtonOptionWidget({
          label: 'اشتباه‌یاب',
          data: {
            template: 'ابزار اشتباه‌یاب'
          }
        });

        this.buttons.Article.Featured = new OO.ui.ButtonOptionWidget({
          label: 'برگزیده/خوبیده',
          data: {
            template: 'تذکر محتوای برگزیده'
          }
        });
        this.buttons.Article.Tutorial = new OO.ui.ButtonOptionWidget({
          label: 'آموزش ویکی‌نویسی',
          data: {
            template: 'ویکی‌نویسی'
          }
        });
        this.buttons.Article.Student = new OO.ui.ButtonOptionWidget({
          label: 'ویرایش دانشجویی',
          data: {
            template: 'ویرایش دانشجویی'
          }
        });
        this.buttons.Article.Incomplete = new OO.ui.ButtonOptionWidget({
          label: 'نوشتار نامناسب',
          data: {
            template: 'نوشتار نامناسب',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.TooShort = new OO.ui.ButtonOptionWidget({
          label: 'زیادی کوتاه',
          data: {
            template: 'بیش از حد کوتاه',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.Minima = new OO.ui.ButtonOptionWidget({
          label: 'حداقل‌ها',
          data: {
            template: 'حداقل‌های مقاله'
          }
        });
        this.buttons.Article.Deleted = new OO.ui.ButtonOptionWidget({
          label: 'حذف شده',
          data: {
            template: 'مقاله حذف شده',
            params: [
              {
                id: '1',
                label: 'پیام تکمیلی (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.Redirect = new OO.ui.ButtonOptionWidget({
          label: 'تغییرمسیر',
          data: {
            template: 'از تغییرمسیر استفاده کنید'
          }
        });
        this.buttons.Article.Move = new OO.ui.ButtonOptionWidget({
          label: 'انتقال',
          data: {
            template: 'از انتقال استفاده کنید'
          }
        });
        this.buttons.Article.Titles = new OO.ui.ButtonOptionWidget({
          label: 'القاب ممنوع',
          data: {
            template: 'هشدار القاب ممنوع'
          }
        });
        this.buttons.Article.Spoiler = new OO.ui.ButtonOptionWidget({
          label: 'مخدوش‌کردن داستان فیلم',
          data: {
            template: 'خلاصه داستان را مخدوش نکنید'
          }
        });
        this.buttons.Article.MachineTranslation = new OO.ui.ButtonOptionWidget({
          label: 'ترجمه ماشینی',
          data: {
            template: 'ترجمه ماشینی ممنوع',
            params: [
              {
                id: '1',
                label: 'عنوان صفحه (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.NoFlag = new OO.ui.ButtonOptionWidget({
          label: 'پرچم نزنید',
          data: {
            template: 'پرچم نزنید'
          }
        });
        this.buttons.Copyright.DoNotCopy = new OO.ui.ButtonOptionWidget({
          label: 'کپی مکنید',
          data: {
            template: 'کپی مکنید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Copyright.UseCitation = new OO.ui.ButtonOptionWidget({
          label: 'یادکرد دقیق',
          data: {
            template: 'یادکرد دقیق منبع',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Copyright.CiteNotCopy = new OO.ui.ButtonOptionWidget({
          label: 'ارجاع به جای کپی',
          data: {
            template: 'نحوه استفاده از مقالات علمی'
          }
        });
        this.buttons.Copyright.ReliableSources = new OO.ui.ButtonOptionWidget({
          label: 'منابع معتبر',
          data: {
            template: 'منابع معتبر'
          }
        });
        this.buttons.Copyright.CitationTutorial = new OO.ui.ButtonOptionWidget({
          label: 'آموزش یادکرد',
          data: {
            template: 'ارجاع صحیح'
          }
        });
        this.buttons.Copyright.License = new OO.ui.ButtonOptionWidget({
          label: 'مجوز نگاره',
          data: {
            template: 'مجوز نگاره'
          }
        });
        this.buttons.Copyright.Copyvio = new OO.ui.ButtonOptionWidget({
          label: 'هشدار نگاره',
          data: {
            template: 'هشدار نقض حق تکثیر'
          }
        });
        this.buttons.Copyright.Ownership = new OO.ui.ButtonOptionWidget({
          label: 'قانون مالکیت',
          data: {
            template: 'هشدار نقض قانون مالکیت محتوا'
          }
        });

        this.buttons.Advanced.Coord = new OO.ui.ButtonOptionWidget({
          label: 'مختصات',
          data: {
            template: 'آموزش سریع الگوی مختصات'
          }
        });
        this.buttons.Advanced.Categories = new OO.ui.ButtonOptionWidget({
          label: 'رده‌بندی',
          data: {
            template: 'رده‌دهی'
          }
        });
        this.buttons.Advanced.Interwiki = new OO.ui.ButtonOptionWidget({
          label: 'میان‌ویکی',
          data: {
            template: 'افزودن میان‌ویکی'
          }
        });

        this.buttons.Spam.Advertisement = new OO.ui.ButtonOptionWidget({
          label: 'تبلیغ',
          data: {
            template: 'تبلیغ مکنید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Notability = new OO.ui.ButtonOptionWidget({
          label: 'سرشناسی',
          data: {
            template: 'پیام سرشناسی',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              },
              {
                id: '2',
                label: 'پیام تکمیلی (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Sereh = new OO.ui.ButtonOptionWidget({
          label: 'سره‌نویسی',
          data: {
            template: 'سره ننویسید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Autobiography = new OO.ui.ButtonOptionWidget({
          label: 'خودنوشته',
          data: {
            template: 'خودنوشته'
          }
        });
        this.buttons.Spam.WP_NOT = new OO.ui.ButtonOptionWidget({
          label: 'اشتباه گرفته‌اید',
          data: {
            template: 'اشتباه گرفته‌اید',
            params: [
              {
                id: '1',
                label: 'با چه اشتباه گرفته؟ (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Username = new OO.ui.ButtonOptionWidget({
          label: 'نام کاربری',
          data: {
            template: 'نام کاربری نامناسب',
            params: [
              {
                id: '1',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Canvassing = new OO.ui.ButtonOptionWidget({
          label: 'جارزنی',
          data: {
            template: 'جارزنی'
          }
        });

        this.buttons.Block.Username = new OO.ui.ButtonOptionWidget({
          label: 'نام کاربری نامناسب',
          data: {
            template: 'بستن نام تبلیغی'
          }
        });
        this.buttons.Block.OneDay = new OO.ui.ButtonOptionWidget({
          label: 'یک‌روزه',
          data: {
            template: 'قطع دسترسی موقت',
            params: [
              {
                id: 'دلیل',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.Indefinite = new OO.ui.ButtonOptionWidget({
          label: 'بی‌پایان',
          data: {
            template: 'قطع دسترسی بی‌پایان',
            params: [
              {
                id: 'دلیل',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.Detailed = new OO.ui.ButtonOptionWidget({
          label: 'با ذکر مدت و دلیل',
          data: {
            template: 'قطع دسترسی',
            params: [
              {
                id: 'مدت',
                label: 'مدت (اختیاری)'
              },
              {
                id: 'دلیل',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.Partial = new OO.ui.ButtonOptionWidget({
          label: 'موردی',
          data: {
            template: 'قطع دسترسی موردی',
            params: [
              {
                id: 'صفحات',
                label: 'صفحه‌ها (مثل [[فلان]] و [[بهمان]])'
              },
              {
                id: 'فضای نام',
                label: 'فضای نام (بین موارد «و» بگذارید)'
              },
              {
              	id: 'عمل‌ها',
              	label: 'عمل‌ها (بین موارد «و» بگذارید)'
              	
              },
              {
                id: 'مدت',
                label: 'مدت (اختیاری)'
              },
              {
                id: 'دلیل',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.AbuseFilter = new OO.ui.ButtonOptionWidget({
          label: 'اشتباه پالایه',
          data: {
            template: 'پوزش پالایه'
          }
        });

        this.buttons.Rights.Autopatrol = new OO.ui.ButtonOptionWidget({
          label: 'گشت خودکار',
          data: {
            template: 'اعطای گشت خودکار'
          }
        });
        this.buttons.Rights.Revert = new OO.ui.ButtonOptionWidget({
          label: 'واگردان',
          data: {
            template: 'اعطای واگردان'
          }
        });
        this.buttons.Rights.Patroller = new OO.ui.ButtonOptionWidget({
          label: 'گشت‌زن',
          data: {
            template: 'اعطای گشت‌زن'
          }
        });
        this.buttons.Rights.TemplateEditor = new OO.ui.ButtonOptionWidget({
          label: 'ویرایشگر الگو',
          data: {
            template: 'اعطای ویرایشگر الگو'
          }
        });
        this.buttons.Rights.ExtendedMover = new OO.ui.ButtonOptionWidget({
          label: 'انتقال‌دهنده پیشرفته',
          data: {
            template: 'اعطای انتقال‌دهنده پیشرفته'
          }
        });
        this.buttons.Rights.Eliminator = new OO.ui.ButtonOptionWidget({
          label: 'ویکی‌بان',
          data: {
            template: 'اعطای ویکی‌بان'
          }
        });
        this.buttons.Rights.ReinstateEliminator = new OO.ui.ButtonOptionWidget({
          label: 'تمدید ویکی‌بانی',
          data: {
            template: 'تمدید ویکی‌بانی'
          }
        });
        this.buttons.Rights.Sysop = new OO.ui.ButtonOptionWidget({
          label: 'مدیر',
          data: {
            template: 'اعطای مدیریت'
          }
        });
        this.buttons.Rights.tofawikiAlot = new OO.ui.ButtonOptionWidget({
          label: 'به‌ویکی‌فا انبوه',
          data: {
            template: 'اعطای دسترسی به‌ویکی‌فا انبوه'
          }
        });

        this.buttonSelectChoicesItems = [];
        this.buttonSelectChoicesItems.Noobs = [
          this.buttons.Noobs.WelcomeUser,
          this.buttons.Noobs.WelcomeIP,
          this.buttons.Noobs.Sign,
          this.buttons.Noobs.DoNotSign,
          this.buttons.Noobs.Ping,
          this.buttons.Noobs.UploadGuide,
          this.buttons.Noobs.CommonsGuide,
          this.buttons.Noobs.Keyboard,
          this.buttons.Noobs.Preview,
          this.buttons.Noobs.Sandbox,
          this.buttons.Noobs.SisterProjects,
          this.buttons.Noobs.EditSummary,
          this.buttons.Noobs.FakeArticle,
          this.buttons.Noobs.SeggestedLinks
        ];
        this.buttonSelectChoicesItems.Warnings = [
          this.buttons.Warnings.Vandalism,
          this.buttons.Warnings.VandalismFinal,
          this.buttons.Warnings.EditWar,
          this.buttons.Warnings.WP_3RR,
          this.buttons.Warnings.Disruption,
          this.buttons.Warnings.Responsiveness,
          this.buttons.Warnings.SockPupptery,
          this.buttons.Warnings.NPA
        ];
        this.buttonSelectChoicesItems.Tools = [
          this.buttons.Tools.VE,
          this.buttons.Tools.ToWikifa,
          this.buttons.Tools.Translator,
          this.buttons.Tools.ExtraEditTools,
          this.buttons.Tools.Abar,
          this.buttons.Tools.Applications,
          this.buttons.Tools.ProveIt,
          this.buttons.Tools.AWD,
          this.buttons.Tools.Patrol,
          this.buttons.Tools.CheckDictation
        ];
        this.buttonSelectChoicesItems.Article = [
          this.buttons.Article.Featured,
          this.buttons.Article.Tutorial,
          this.buttons.Article.Student,
          this.buttons.Article.Incomplete,
          this.buttons.Article.TooShort,
          this.buttons.Article.Minima,
          this.buttons.Article.Deleted,
          this.buttons.Article.Redirect,
          this.buttons.Article.Move,
          this.buttons.Article.Titles,
          this.buttons.Article.Spoiler,
          this.buttons.Article.MachineTranslation,
          this.buttons.Article.NoFlag
        ];
        this.buttonSelectChoicesItems.Copyright = [
          this.buttons.Copyright.DoNotCopy,
          this.buttons.Copyright.UseCitation,
          this.buttons.Copyright.CiteNotCopy,
          this.buttons.Copyright.ReliableSources,
          this.buttons.Copyright.CitationTutorial,
          this.buttons.Copyright.License,
          this.buttons.Copyright.Copyvio,
          this.buttons.Copyright.Ownership
        ];
        this.buttonSelectChoicesItems.Advanced = [
          this.buttons.Advanced.Coord,
          this.buttons.Advanced.Categories,
          this.buttons.Advanced.Interwiki
        ];
        this.buttonSelectChoicesItems.Spam = [
          this.buttons.Spam.Advertisement,
          this.buttons.Spam.Notability,
          this.buttons.Spam.Sereh,
          this.buttons.Spam.Autobiography,
          this.buttons.Spam.WP_NOT,
          this.buttons.Spam.Username,
          this.buttons.Spam.Canvassing
        ];
        this.buttonSelectChoicesItems.Block = [
          this.buttons.Block.Username,
          this.buttons.Block.OneDay,
          this.buttons.Block.Indefinite,
          this.buttons.Block.Detailed,
          this.buttons.Block.Partial,
          this.buttons.Block.AbuseFilter
        ];
        this.buttonSelectChoicesItems.Rights = [
          this.buttons.Rights.Autopatrol,
          this.buttons.Rights.Revert,
          this.buttons.Rights.Patroller,
          this.buttons.Rights.TemplateEditor,
          this.buttons.Rights.ExtendedMover,
          this.buttons.Rights.Eliminator,
          this.buttons.Rights.ReinstateEliminator,
          this.buttons.Rights.Sysop,
          this.buttons.Rights.tofawikiAlot
        ];

        // The default choice
        this.buttonSelectChoices = new OO.ui.ButtonSelectWidget({
          items: this.buttonSelectChoicesItems.Noobs
        });

        this.setChooseAction = function() {
          dialog.buttonSelectChoices.on('choose', function(item) {
            dialog.previewResult.toggle(false);
            if (item.data !== undefined & item.data.params !== undefined) {
              dialog.panelParams.toggle(true);
              dialog.buttonPreview.toggle(true);
              dialog.buttonReset.toggle(true);
              for (var i = 0; i < item.data.params.length; i++) {
                dialog.textParamLayouts[i].toggle(true);
                dialog.textParamLayouts[i].setLabel(item.data.params[i].label);
                dialog.textParamLayouts[i].setData(item.data.params[i].id);
              }
              for (i = item.data.params.length; i < 5; i++) {
                dialog.textParamLayouts[i].toggle(false);
              }
            } else {
              for (var k = 0; k < 5; k++) {
                dialog.textParamLayouts[k].toggle(false);
              }
              dialog.panelParams.toggle(true);
              dialog.buttonPreview.toggle(true);
              dialog.buttonReset.toggle(true);
            }
            windowManager.getCurrentWindow().updateSize();
          });          
        };
        this.setChooseAction();

        // The parameters
        this.textParams = [];
        this.textParamLayouts = [];

        this.textParams[0] = new OO.ui.TextInputWidget({
          placeholder: 'متنی وارد کنید'
        });
        this.textParams[1] = new OO.ui.TextInputWidget({
          placeholder: 'متنی وارد کنید'
        });
        this.textParams[2] = new OO.ui.TextInputWidget({
          placeholder: 'متنی وارد کنید'
        });
        this.textParams[3] = new OO.ui.TextInputWidget({
          placeholder: 'متنی وارد کنید'
        });
        this.textParams[4] = new OO.ui.TextInputWidget({
          placeholder: 'متنی وارد کنید'
        });
        this.textParamLayouts[0] = new OO.ui.FieldLayout( this.textParams[0], {
          label: 'پارامتر اول'
        });
        this.textParamLayouts[1] = new OO.ui.FieldLayout( this.textParams[1], {
          label: 'پارامتر دوم'
        });
        this.textParamLayouts[2] = new OO.ui.FieldLayout( this.textParams[2], {
          label: 'پارامتر سوم'
        });
        this.textParamLayouts[3] = new OO.ui.FieldLayout( this.textParams[3], {
          label: 'پارامتر چهارم'
        });
        this.textParamLayouts[4] = new OO.ui.FieldLayout( this.textParams[4], {
          label: 'پارامتر پنجم'
        });
        this.paramFieldset = new OO.ui.FieldsetLayout({
          items: this.textParamLayouts
        });
        this.buttonPreview = new OO.ui.ButtonWidget({
          label: 'پیش‌نمایش',
          icon: 'check',
          title: 'پیش‌نمایش',
          flags: 'progressive'
        });
        this.buttonPreview.on('click', function() {
          dialog.previewResult.toggle(true);
          dialog.previewResult.setContent(''); // Makes any previous preview results go away, so the user notices the change
          windowManager.getCurrentWindow().updateSize();
          var wikitext = UserMessages.prepareWikitext(dialog);
          var api = new mw.Api();
          api.get({
            action: 'parse',
            text: wikitext,
            pst: true
          }).done(function( data ) {
            dialog.previewResult.setContent($(data.parse.text['*']));
          });
        });
        this.buttonReset = new OO.ui.ButtonWidget({
          label: 'پاک کردن',
          icon: 'clear',
          title: 'پاک کردن',
          flags: 'destructive'
        });
        this.buttonReset.on('click', function() {
          for (var i = 0; i < 5; i++) {
              dialog.textParams[i].setValue('');
          }
          dialog.previewResult.toggle(false);
          dialog.buttonPreview.toggle(true);
          dialog.buttonReset.toggle(true);
          windowManager.getCurrentWindow().updateSize();
        });
        this.panelParams = new OO.ui.PanelLayout({
          expanded: true,
          padded: true
        });
        this.previewResult = new PreviewPanel({
          expanded: true,
          padded: true,
          $content: ''
        });
        this.previewResult.toggle(false);
        this.panelParams.$element.append(this.paramFieldset.$element);
        this.panelParams.$element.append(this.buttonPreview.$element);
        this.panelParams.$element.append(this.buttonReset.$element);
        for (var i = 0; i < 5; i++) {
            this.textParamLayouts[i].toggle(false);
        }
        this.buttonPreview.toggle(false);
        this.buttonReset.toggle(false);
        this.panelGroups = new OO.ui.PanelLayout({
          expanded: true,
          padded: true,
          classes: ['panelGroups']
        });
        this.panelGroups.$element.append(this.buttonSelectGroups.$element);
        this.panelChoices = new OO.ui.PanelLayout({
          expanded: true,
          padded: true,
          classes: ['panelChoices']
        });
        this.panelChoices.$element.append(this.buttonSelectChoices.$element);
        this.panelPreview = new OO.ui.PanelLayout({
          expanded: true,
          padded: true
        });
        this.panelPreview.$element.append(this.previewResult.$element);

        this.stackLayout = new OO.ui.StackLayout({
          items: [
            this.panelGroups,
            this.panelChoices,
            this.panelParams,
            this.panelPreview
          ],
          continuous: true,
          scrollable: false
        });
        this.$body.append(this.stackLayout.$element);
      };
      UserMessages.prepareWikitext = function(dialog) {
        var paramNames = [];
        var paramValues = [];
        var btn = dialog.buttonSelectChoices.findSelectedItem().getData();
        var wikitext = '{{subst:' + btn.template;
        for (var i = 0; i < 5; i ++) {
          paramNames[i] = dialog.textParamLayouts[i].getData();
          paramValues[i] = dialog.textParams[i].getValue();
          if (dialog.textParamLayouts[i].isVisible()) {
            wikitext += '|' + paramNames[i] + '=' + paramValues[i];
          }
        }
        wikitext += '}}';
        return wikitext;
      };
      UserMessages.prototype.getSetupProcess = function(data) {
        data = data || {};
        return UserMessages.super.prototype.getSetupProcess.call( this, data )
          .next( function () {
            // Do something
          }, this );
      };
      UserMessages.prototype.getActionProcess = function(action) {
        var dialog = this;
        if (action === 'warn' | action === 'diff') {
          var wikitext = UserMessages.prepareWikitext(dialog);
          wikitext += '\n~~' + '~~';
          var summary = 'افزودن «[[الگو:' + dialog.buttonSelectChoices.findSelectedItem().getData().template + ']]» به کمک [[ویکی‌پدیا:ابزار اعلان به کاربران|ابزار اعلان به کاربران]]';
          if (action === 'warn') {
            return new OO.ui.Process(function() {
              UMOptions.savePage(mw.config.get('wgPageName'), wikitext, summary, function() {
                location.reload();
              });
              dialog.close({
                action: action
              }).done(function() {
                // Page will be reloaded once saved
              });
            });
          } else { // action === 'diff'
            return new OO.ui.Process(function() {
              UMOptions.showDiff(
                mw.config.get('wgPageName'),
                wikitext,
                summary
              )
            });
          }
        }
        return UserMessages.super.prototype.getActionProcess.call(this, action);
      };
      if (!windowManager) {
        windowManager = new OO.ui.WindowManager();
        $('body').append(windowManager.$element);
      }
      UM = new UserMessages({
        size: 'large'
      });
      windowManager.addWindows([UM]);
      windowManager.openWindow(UM);
    },
    redirectPost: function(url, data) {
      var form = document.createElement('form');
        document.body.appendChild(form);
        form.method = 'post';
        form.action = url;
        for (var name in data) {
          var input = document.createElement('input');
          input.type = 'hidden';
          input.name = name;
          input.value = data[name];
          form.appendChild(input);
        }
      form.submit();
	},
	showDiff: function(title, text, summary) {
	  var url = new URL(mw.config.get('wgScript'), window.location);
	  url.searchParams.set('title', title);
	  url.searchParams.set('action', 'submit');
      UMOptions.redirectPost(url.toString(), {
          wpTextbox1: text,
          wpDiff: '',
          wpSummary: '',
          wpSection: 'new',
          wpUltimateParam: 1
        }
      );
    },
    savePage: function(title, text, summary, callback) {
      (new mw.Api()).post({
        action: 'edit',
        title: title,
        summary: summary,
        appendtext: '\n' + text,
        token: mw.user.tokens.get('csrfToken')
      }).done(function(data) {
        if (data.error && data.error.info) {
          if (data.error.info == 'missingtitle') {
            mw.notify('صفحه ' + title + ' موجود نیست!', {
              type: 'error'
            });
          } else {
            mw.notify(data.error.info, {
              type: 'error'
            });
          }
        } else {
          callback();
        }
      }).fail(function(data) {
        mw.notify(data);
      });
    },
  };
  if (mw.config.get('wgNamespaceNumber') === 3 | mw.config.get('wgPageName') === 'ویکی‌پدیا:صفحه_تمرین') {
    $(UMOptions.install);
  }
})(jQuery, mediaWiki);