پرش به محتوا

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

از دانشنامه علوم انسانی
imported>Huji
افزودن یک مورد
imported>Huji
better coding style
خط ۲۱: خط ۲۱:
*/
*/
// <source lang="javascript">
// <source lang="javascript">
//moved here from commons
//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; }
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
//end moved here from commons
// Configuration
// Configuration
 
// Should the edits be saved automatically?
// Should the edits be saved automatically?
if(window.template_autosave == false){}else{ template_autosave = true; }
if (window.template_autosave == false) {} else {
  template_autosave = true;
// Template Name
}
var uTemplate = new Array(22)
 
uTemplate[0] = 'خوشامدید'
uTemplate[1] = 'خوشامد-آی\u200cپی'
uTemplate[2] = 'امضا کنید'
uTemplate[3] = 'کاربر جدید/صفحه کلید فارسی'
uTemplate[4] = 'کاربر جدید/ابزار کمک\u200cمترجم'
uTemplate[5] = 'کاربر جدید/ابزارهای ویرایشی'
uTemplate[6] = 'از پیش\u200cنمایش استفاده کنید'
uTemplate[7] = 'کاربر جدید/ویکی\u200cنویسی'
uTemplate[8] = 'نوشتار نامناسب'
uTemplate[9] = 'بیش از حد کوتاه'
uTemplate[10] = 'کاربر جدید/حداقل\u200cهای مقاله'
uTemplate[11] = 'تبلیغ مکنید'
uTemplate[12] = 'پیام سرشناسی'
uTemplate[13] = 'کپی مکنید'
uTemplate[14] = 'کاربر جدید/لطفا کپی نکنید!'
uTemplate[15] = 'کاربر جدید/منابع معتبر'
uTemplate[16] = 'یادکرد دقیق منبع'
uTemplate[17] = 'کاربر جدید/ارجاع صحیح'
uTemplate[18] = 'کاربر جدید/مجوز نگاره'
uTemplate[19] = 'کاربر جدید/هشدار نقض حق تکثیر'
uTemplate[20] = 'کاربر جدید/مختصات\u200cدهی'
uTemplate[21] = 'کاربر جدید/رده\u200cدهی'
uTemplate[22] = 'کاربر جدید/میان\u200cویکی'
uTemplate[23] = 'اشتباه گرفته\u200cاید'
uTemplate[24] = 'هشدار نقض قانون سه برگردان'
// Text to be shown in Toolbox
var uText = new Array(22)
uText[0] = 'خوشامدید'
uText[1] = 'خوشامد-آی‌پی'
uText[2] = 'کاربر جدید > امضا کنید'
uText[3] = 'کاربر جدید > صفحه‌کلید فارسی'
uText[4] = 'کاربر جدید > ابزار کمک‌مترجم'
uText[5] = 'کاربر جدید > ابزارهای ویرایشی'
uText[6] = 'از پیش‌نمایش استفاده کنید'
uText[7] = 'مقاله > روش مقاله‌نویسی شما'
uText[8] = 'مقاله > نوشتار کتره‌ای'
uText[9] = 'مقاله > بیش از حد کوتاه'
uText[10] = 'مقاله > حداقل‌های مقاله/ترجمه'
uText[11] = 'اسپم > تبلیغ مکنید'
uText[12] = 'اسپم > سرشناسی'
uText[13] = 'حق‌تکثیر > کپی مکنید'
uText[14] = 'حق‌تکثیر > لطفا کپی نکنید!'
uText[15] = 'حق‌تکثیر > منابع معتبر، تحقیق'
uText[16] = 'حق‌تکثیر > یادکرد دقیق منبع'
uText[17] = 'حق‌تکثیر > ارجاع صحیح'
uText[18] = 'حق‌تکثیر > مجوز نگاره'
uText[19] = 'حق‌تکثیر > بارگذاری نگاره دارای حق تکثیر'
uText[20] = 'افزودن > مختصات‌دهی'
uText[21] = 'افزودن > رده‌بندی'
uText[22] = 'افزودن > میان‌ویکی'
uText[23] = 'هشدار > اشتباه گرفته‌اید'
uText[24] = 'هشدار > نقض قانون ۳برگردان'
// Mouseover help text for Toolbox
var uHelp = new Array(22)
uHelp[0] = 'خوشامدید'
uHelp[1] = 'خوشامد-آی\u200cپی'
uHelp[2] = 'کاربر جدید > امضا کنید'
uHelp[3] = 'کاربر جدید > صفحه کلید فارسی'
uHelp[4] = 'کاربر جدید > ابزار کمک\u200cمترجم'
uHelp[5] = 'کاربر جدید > ابزارهای ویرایشی'
uHelp[6] = 'از پیش\u200cنمایش استفاده کنید'
uHelp[7] = 'مقاله > روش مقاله نویسی'
uHelp[8] = 'مقاله > نوشتار کتره‌ای'
uHelp[9] = 'مقاله > بیش از حد کوتاه'
uHelp[10] = 'مقاله > حداقل\u200cهای مقاله'
uHelp[11] = 'اسپم > تبلیغ مکنید'
uHelp[12] = 'اسپم > سرشناسی'
uHelp[13] = 'حق تکثیر > کپی مکنید'
uHelp[14] = 'حق تکثیر > لطفا کپی نکنید!'
uHelp[15] = 'حق تکثیر > منابع معتبر'
uHelp[16] = 'حق تکثیر > یادکرد دقیق منبع'
uHelp[17] = 'حق تکثیر > ارجاع صحیح'
uHelp[18] = 'حق تکثیر > مجوز نگاره'
uHelp[19] = 'افزودن > مختصات\u200cدهی'
uHelp[20] = 'افزودن > رده\u200cدهی'
uHelp[21] = 'افزودن > میان\u200cویکی'
uHelp[22] = 'هشدار > اشتباه گرفته\u200cاید'
uHelp[23] = 'هشدار > نقض قانون سه برگردان'
template_pagename = "نام مقاله را بنویسید:";
template_pagename = "نام مقاله را بنویسید:";
template_what = "با چی؟";
template_what = "با چی؟";
 
uMessage = new Array();
 
uMessage.push(['خوشامدید', 'خوشامدید', 'خوشامدید', false]);
uMessage.push(['خوشامد-آی\u200cپی', 'خوشامد-آی‌پی', 'خوشامد-آی\u200cپی', false]);
uMessage.push(['امضا کنید', 'کاربر جدید > امضا کنید', 'کاربر جدید > امضا کنید', false]);
uMessage.push(['کاربر جدید/صفحه کلید فارسی', 'کاربر جدید > صفحه‌کلید فارسی', 'کاربر جدید > صفحه کلید فارسی', false]);
uMessage.push(['کاربر جدید/ابزار کمک\u200cمترجم', 'کاربر جدید > ابزار کمک‌مترجم', 'کاربر جدید > ابزار کمک\u200cمترجم', false]);
uMessage.push(['کاربر جدید/ابزارهای ویرایشی', 'کاربر جدید > ابزارهای ویرایشی', 'کاربر جدید > ابزارهای ویرایشی', false]);
uMessage.push(['از پیش\u200cنمایش استفاده کنید', 'از پیش‌نمایش استفاده کنید', 'از پیش\u200cنمایش استفاده کنید', false]);
uMessage.push(['کاربر جدید/ویکی\u200cنویسی', 'مقاله > روش مقاله‌نویسی شما', 'مقاله > روش مقاله نویسی', template_pagename]);
uMessage.push(['نوشتار نامناسب', 'مقاله > نوشتار کتره‌ای', 'مقاله > نوشتار کتره‌ای', false]);
uMessage.push(['بیش از حد کوتاه', 'مقاله > بیش از حد کوتاه', 'مقاله > بیش از حد کوتاه', template_pagename]);
uMessage.push(['کاربر جدید/حداقل\u200cهای مقاله', 'مقاله > حداقل‌های مقاله/ترجمه', 'مقاله > حداقل\u200cهای مقاله', false]);
uMessage.push(['تبلیغ مکنید', 'اسپم > تبلیغ مکنید', 'اسپم > تبلیغ مکنید', template_pagename]);
uMessage.push(['پیام سرشناسی', 'اسپم > سرشناسی', 'اسپم > سرشناسی', template_pagename]);
uMessage.push(['کپی مکنید', 'حق‌تکثیر > کپی مکنید', 'حق تکثیر > کپی مکنید', template_pagename]);
uMessage.push(['کاربر جدید/لطفا کپی نکنید!', 'حق‌تکثیر > لطفا کپی نکنید!', 'حق تکثیر > لطفا کپی نکنید!', false]);
uMessage.push(['کاربر جدید/منابع معتبر', 'حق‌تکثیر > منابع معتبر، تحقیق', 'حق تکثیر > منابع معتبر', false]);
uMessage.push(['یادکرد دقیق منبع', 'حق‌تکثیر > یادکرد دقیق منبع', 'حق تکثیر > یادکرد دقیق منبع', template_pagename]);
uMessage.push(['کاربر جدید/ارجاع صحیح', 'حق‌تکثیر > ارجاع صحیح', 'حق تکثیر > ارجاع صحیح', false]);
uMessage.push(['کاربر جدید/مجوز نگاره', 'حق‌تکثیر > مجوز نگاره', 'حق تکثیر > مجوز نگاره', false]);
uMessage.push(['کاربر جدید/هشدار نقض حق تکثیر', 'حق‌تکثیر > بارگذاری نگاره دارای حق تکثیر', 'حق‌تکثیر > بارگذاری نگاره دارای حق تکثیر', false]);
uMessage.push(['کاربر جدید/مختصات\u200cدهی', 'افزودن > مختصات‌دهی', 'افزودن > مختصات\u200cدهی', false]);
uMessage.push(['کاربر جدید/رده\u200cدهی', 'افزودن > رده‌بندی', 'افزودن > رده\u200cدهی', false]);
uMessage.push(['کاربر جدید/میان\u200cویکی', 'افزودن > میان‌ویکی', 'افزودن > میان\u200cویکی', false]);
uMessage.push(['اشتباه گرفته\u200cاید', 'هشدار > اشتباه گرفته‌اید', 'هشدار > اشتباه گرفته\u200cاید', template_what]);
uMessage.push(['هشدار نقض قانون سه برگردان', 'هشدار > نقض قانون ۳برگردان', 'هشدار > نقض قانون سه برگردان', template_pagename]);
 
// Site info
// Site info
scriptPath = "/w/index.php";
scriptPath = "/w/index.php";
prettyPath = "/wiki/";
prettyPath = "/wiki/";
wikiHostname = "fa.wikipedia.org";
wikiHostname = "fa.wikipedia.org";
 
// From [[en:Wikipedia:WikiProject User scripts/Scripts/addLink]]
// From [[en:Wikipedia:WikiProject User scripts/Scripts/addLink]]
function addLink(where, url1, name1, id, title, key, after, url2, name2)
function addLink(where, url1, name1, id, title, key, after, url2, name2) {
{
  //* where is the id of the toolbar where the button should be added;
    //* where is the id of the toolbar where the button should be added;
  //  i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //  i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
  //
    //
  //* url1 is the URL which will be called when the button is clicked.
    //* url1 is the URL which will be called when the button is clicked.
  //  javascript: urls can be used to do more complex things.
    //  javascript: urls can be used to do more complex things.
  //
    //
  //* name1 is what will appear as the name of the button.
    //* name1 is what will appear as the name of the button.
  //
    //
  //* id is the id of the button; it's best to define one.
    //* id is the id of the button; it's best to define one.
  //  Use a prefix to make sure its unique. Optional.
    //  Use a prefix to make sure its unique. Optional.
  //
    //
  //* title is the tooltip title that gives a longer description
    //* title is the tooltip title that gives a longer description
  //  of the button; if you define a accesskey, mention it here. Optional.
    //  of the button; if you define a accesskey, mention it here. Optional.
  //
    //
  //* key is the char you want for the accesskey. Optional.
    //* key is the char you want for the accesskey. Optional.
  //
    //
  //* after is the id of the button you want to follow this one. Optional.
    //* after is the id of the button you want to follow this one. Optional.
  //
    //
  //* url2 is a second url to add. Optional
    //* url2 is a second url to add. Optional
  //
    //
  //*name2 is the name of the second url; defaults to name1. 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.
     var na = document.createElement('a');
     var na = document.createElement('a');
     na.href = url1;
     na.href = url2;
     na.appendChild(document.createTextNode(name1));
     na.appendChild(document.createTextNode(name2 ? name2 : name1));
     var li = document.createElement('li');
     li.appendChild(document.createTextNode(" · ")); //separate them a bit
    if(id) li.id = id;
     li.appendChild(na);
     li.appendChild(na);
  }
    if (url2) { //Another link, brother of the previous.
 
      var na = document.createElement('a');
  var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
      na.href = url2;
  if (after) {
      na.appendChild(document.createTextNode(name2 ? name2 : name1));
    tabs.insertBefore(li, document.getElementById(after));
      li.appendChild(document.createTextNode(" · ")); //separate them a bit
  } else {
      li.appendChild(na);
    tabs.appendChild(li);
    }
  }
  //akeytt is deprected and does nothing. who cares about access keys anyhow.
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
  /*if(id && ta) { //ta does not exist in vector?  
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        tabs.appendChild(li);
    }
    //akeytt is deprected and does nothing. who cares about access keys anyhow.
    /*if(id && ta) { //ta does not exist in vector?  
         if(key && title) { ta[id] = [key, title]; }
         if(key && title) { ta[id] = [key, title]; }
         else if(key) { ta[id] = [key, '']; }
         else if(key) { ta[id] = [key, '']; }
خط ۱۹۳: خط ۱۳۱:
     // re-render the title and accesskeys from existing code in wikibits.js
     // re-render the title and accesskeys from existing code in wikibits.js
     akeytt();*/
     akeytt();*/
    return li;
  return li;
}
}
 
// Add the template
// Add the template
function template_mark(talkpage_fakeaction, message_lang) {
function template_mark(talkpage_fakeaction, message_lang) {
   //if (!message_lang) return; //User pressed cancel
   //if (!message_lang) return; //User pressed cancel
 
   //Now we assume message templates to be properly autotranslated
   //Now we assume message templates to be properly autotranslated
   if (message_lang) langparam='&template_lang=' + message_lang;
   if (message_lang) langparam = '&template_lang=' + message_lang;
   else langparam='';
   else langparam = '';
 
   var pagename = encodeURIComponent(wgPageName);
   var pagename = encodeURIComponent(wgPageName);
   var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
   var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
   document.location = editlk + '&fakeaction=' + talkpage_fakeaction + langparam + '&template_type=1';
   document.location = editlk + '&fakeaction=' + talkpage_fakeaction + langparam + '&template_type=1';
}
}
 
// Add template to user talk page
// Add template to user talk page
function template_addTemplate(template) {
function template_addTemplate(template) {
   if (getParamValue('template_lang')) {
   if (getParamValue('template_lang')) {
          template = template + '/' + getParamValue('template_lang');
    template = template + '/' + getParamValue('template_lang');
   }
   }
 
   var txt = '{{subst:' + template + '}}';
   var txt = '{{subst:' + template + '}}';
   document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + txt + '\n~~~~';
   document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + txt + '~~' + '~~';
   //  the edit summary for when you mark the image. You can change it if you want.
   //  the edit summary for when you mark the image. You can change it if you want.
   document.editform.wpSummary.value = 'الگوی «' + template + '» به بحث کاربر افزوده شد. ([[وپ:ابزار تذکر به کاربر جدید|با استفاده از ابزار]])';
   document.editform.wpSummary.value = 'الگوی «' + template + '» به بحث کاربر افزوده شد. ([[وپ:ابزار تذکر به کاربر جدید|با استفاده از ابزار]])';
   if (template_autosave) document.editform.wpSave.click();
   if (template_autosave) document.editform.wpSave.click();
}
}
 
// Add the template
// Add the template
function template_mark2(talkpage_fakeaction, media_name, can_handle_empty_parameter, add_namespace) {
function template_mark2(talkpage_fakeaction, media_name, can_handle_empty_parameter, add_namespace) {
خط ۲۲۸: خط ۱۶۶:
   // Parameter handling for special cases
   // Parameter handling for special cases
   if (add_namespace && media_name.length > 0) media_name = 'File:' + media_name;
   if (add_namespace && media_name.length > 0) media_name = 'File:' + media_name;
 
   var pagename = encodeURIComponent(wgPageName);
   var pagename = encodeURIComponent(wgPageName);
   var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
   var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
   document.location = editlk + '&fakeaction=' + talkpage_fakeaction + '&media_name=' + encodeURIComponent (media_name) + '&template_type=2';
   document.location = editlk + '&fakeaction=' + talkpage_fakeaction + '&media_name=' + encodeURIComponent(media_name) + '&template_type=2';
}
}
 
// Add template to user talk page
// Add template to user talk page
function template_addTemplate2(template) {
function template_addTemplate2(template) {
   if (getParamValue('media_name')) {
   if (getParamValue('media_name')) {
          template = template + '|' + getParamValue('media_name');
    template = template + '|' + getParamValue('media_name');
   }
   }
 
   var txt = '{{subst:' + template + '}}';
   var txt = '{{subst:' + template + '}}';
   document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + txt + '\n~~~~';
   document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + txt + '~~' + '~~';
   //  the edit summary for when you mark the image. You can change it if you want.
   //  the edit summary for when you mark the image. You can change it if you want.
   document.editform.wpSummary.value = 'الگوی «' + template + '» به بحث کاربر افزوده شد. ([[وپ:ابزار تذکر به کاربر جدید|ابزار تذکر به کاربر جدید]])';
   document.editform.wpSummary.value = 'الگوی «' + template + '» به بحث کاربر افزوده شد. ([[وپ:ابزار تذکر به کاربر جدید|ابزار تذکر به کاربر جدید]])';
   if (template_autosave) document.editform.wpSave.click();
   if (template_autosave) document.editform.wpSave.click();
}
}
 
 
// Do the thing with the stuff here.
// Do the thing with the stuff here.
function template_onload() {
function template_onload() {
خط ۲۵۳: خط ۱۹۱:
     // new section
     // new section
     try {
     try {
    if (skin === 'vector') {
      if (skin === 'vector') {
         if (window.useFancyVectorDropdown || window.useFancyVectorDropdown === undefined) {
         if (window.useFancyVectorDropdown || window.useFancyVectorDropdown === undefined) {
            try {
          try {
                makeVectorFancySection();
            makeVectorFancySection();
                useFancyVectorDropdown = 'done'; //this is for debug. can remove
            useFancyVectorDropdown = 'done'; //this is for debug. can remove
            }
          } catch (e) {
            catch (e) {
            document.getElementById('panel').innerHTML += '<div id="p-Notify" class="portal"><h5 lang="fa" xml:lang="fa">Notify</h5><div class="body"><ul> </ul> </div> </div>';
                document.getElementById('panel').innerHTML += '<div id="p-Notify" class="portal"><h5 lang="fa" xml:lang="fa">Notify</h5><div class="body"><ul> </ul> </div> </div>';
          }
            }
        } else {
          document.getElementById('panel').innerHTML += '<div id="p-Notify" class="portal"><h5 lang="fa" xml:lang="fa">Notify</h5><div class="body">\n <ul> </ul> </div> </div>';
         }
         }
        else {
      }
            document.getElementById('panel').innerHTML += '<div id="p-Notify" class="portal"><h5 lang="fa" xml:lang="fa">Notify</h5><div class="body">\n <ul> </ul> </div> </div>';
      if (skin === 'monobook') {
      }
    }
    if (skin === 'monobook') {
         document.getElementById('column-one').innerHTML += '<div id="p-Notify" class="portlet"> <h5 lang="fa" xml:lang="fa">Notify</h5> <div class="pBody"> <ul></ul></div> </div>';
         document.getElementById('column-one').innerHTML += '<div id="p-Notify" class="portlet"> <h5 lang="fa" xml:lang="fa">Notify</h5> <div class="pBody"> <ul></ul></div> </div>';
    }
      }
     } catch (e) {} //ignore errors and just use tb if they happen.
     } catch (e) {} //ignore errors and just use tb if they happen.
     var portlet = (document.getElementById('p-Notify') ? 'p-Notify' : 'p-tb');
     var portlet = (document.getElementById('p-Notify') ? 'p-Notify' : 'p-tb');
 
     addLink(portlet, 'javascript:template_mark(\'0\')', uText[0], 'mark-warn', uHelp[0], null, null);
     for (i = 0; i < uMessage.length; i++) {
    addLink(portlet, 'javascript:template_mark(\'1\')', uText[1], 'mark-warn', uHelp[1], null, null);
      if (uMessage[i][3]) {
    addLink(portlet, 'javascript:template_mark(\'2\')', uText[2], 'mark-warn', uHelp[2], null, null);
        addLink(portlet, 'javascript:template_mark2(\'' + i + '\', prompt(\'' + uMessage[i][3] + '\', \'\'), 0, false)', uMessage[i][1], 'mark-warn', uMessage[i][2]);
    addLink(portlet, 'javascript:template_mark(\'3\')', uText[3], 'mark-warn', uHelp[3], null, null);
      } else {
    addLink(portlet, 'javascript:template_mark(\'4\')', uText[4], 'mark-warn', uHelp[4], null, null);
        addLink(portlet, 'javascript:template_mark(\'' + i + '\')', uMessage[i][1],
    addLink(portlet, 'javascript:template_mark(\'5\')', uText[5], 'mark-warn', uHelp[5], null, null);
          'mark-warn', uMessage[i][2], null, null);
    addLink(portlet, 'javascript:template_mark2(\'6\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[6], 'mark-warn', uHelp[6]);
      }
    addLink(portlet, 'javascript:template_mark(\'7\')', uText[7], 'mark-warn', uHelp[7], null, null);
     }
    addLink(portlet, 'javascript:template_mark(\'8\')', uText[8], 'mark-warn', uHelp[8], null, null);
    addLink(portlet, 'javascript:template_mark2(\'9\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[9], 'mark-warn', uHelp[9]);
    addLink(portlet, 'javascript:template_mark(\'10\')', uText[10], 'mark-warn', uHelp[10], null, null);
    addLink(portlet, 'javascript:template_mark2(\'11\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[11], 'mark-warn', uHelp[11]);
    addLink(portlet, 'javascript:template_mark2(\'12\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[12], 'mark-warn', uHelp[12]);
    addLink(portlet, 'javascript:template_mark2(\'13\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[13], 'mark-warn', uHelp[13]);
    addLink(portlet, 'javascript:template_mark(\'14\')', uText[14], 'mark-warn', uHelp[14], null, null);
    addLink(portlet, 'javascript:template_mark(\'15\')', uText[15], 'mark-warn', uHelp[15], null, null);
    addLink(portlet, 'javascript:template_mark2(\'16\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[16], 'mark-warn', uHelp[16]);
    addLink(portlet, 'javascript:template_mark(\'17\')', uText[17], 'mark-warn', uHelp[17], null, null);
    addLink(portlet, 'javascript:template_mark(\'18\')', uText[18], 'mark-warn', uHelp[18], null, null);
    addLink(portlet, 'javascript:template_mark(\'19\')', uText[19], 'mark-warn', uHelp[19], null, null);
    addLink(portlet, 'javascript:template_mark(\'20\')', uText[20], 'mark-warn', uHelp[20], null, null);
     addLink(portlet, 'javascript:template_mark(\'21\')', uText[21], 'mark-warn', uHelp[21], null, null);
    addLink(portlet, 'javascript:template_mark2(\'22\', prompt(\'' + template_what + '\', \'\'), 0, false)', uText[22], 'mark-warn', uHelp[22]);
    addLink(portlet, 'javascript:template_mark2(\'23\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[23], 'mark-warn', uHelp[23]);
   }
   }
// Important thing and stuff above.
  // Important thing and stuff above.
 
   var fakeaction = getParamValue('fakeaction');
   var fakeaction = getParamValue('fakeaction');
   var template_type = getParamValue('template_type'); // Fetch what template to add
   var template_type = getParamValue('template_type'); // Fetch what template to add
 
   var action_idx = -1;
   var action_idx = -1;
   try {
   try {
     action_idx = parseInt (fakeaction, 10);
     action_idx = parseInt(fakeaction, 10);
   } catch (some_error) {
   } catch (some_error) {
     action_idx = -1;  
     action_idx = -1;
   }
   }
   var add_idx = -1;
   var add_idx = -1;
   try {
   try {
     add_idx = parseInt (template_type, 10);
     add_idx = parseInt(template_type, 10);
   } catch (some_error) {
   } catch (some_error) {
     add_idx = -1;  
     add_idx = -1;
   }
   }
   if (add_idx >= 1 && add_idx <= 2 && action_idx >= 0 && action_idx < uTemplate.length) {
   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
     //may i take this moment to mention, this script is very very confusing - bawolff
     if (wgNamespaceNumber !== 3) {  
     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.");
       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("خطای امنیتی: فضای نامی اشتباه برای ابزار اطلاع رسانی.");
       throw new Error("خطای امنیتی: فضای نامی اشتباه برای ابزار اطلاع رسانی.");
     }
     }
     if (add_idx == 1)
     if (add_idx == 1) template_addTemplate(uMessage[action_idx][0]);
      template_addTemplate (uTemplate[action_idx]);
     else template_addTemplate2(uMessage[action_idx][0]);
     else
      template_addTemplate2 (uTemplate[action_idx]);
   }
   }
}
}
 
addOnloadHook(template_onload);
addOnloadHook(template_onload);
 
function makeVectorFancySection() {
function makeVectorFancySection() {
//wrap this in a try. this might be somewhat delicate at the moment.
  //wrap this in a try. this might be somewhat delicate at the moment.
var pNotify = document.createElement('div');
  var pNotify = document.createElement('div');
pNotify.id = 'p-Notify'
  pNotify.id = 'p-Notify'
pNotify.className = 'vectorMenu'
  pNotify.className = 'vectorMenu'
pNotify.innerHTML = ' <h5><span>Notify</span><a href="#" style="background-image:none;"/></h5> <div class="menu"> <ul lang="fa" xml:lang="fa"> </ul> </div>';
  pNotify.innerHTML = ' <h5><span>Notify</span><a href="#" style="background-image:none;"/></h5> <div class="menu"> <ul lang="fa" xml:lang="fa"> </ul> </div>';
var rightNav = document.getElementById('right-navigation');
  var rightNav = document.getElementById('right-navigation');
var pViews = document.getElementById('p-views');
  var pViews = document.getElementById('p-views');
rightNav.insertBefore(pNotify, pViews.nextSibling)  
  rightNav.insertBefore(pNotify, pViews.nextSibling)
}
}
// </source>
// </source>

نسخهٔ ۵ ژانویهٔ ۲۰۱۳، ساعت ۲۱:۵۰

/*
<<<<<<<<<< derived from [[n:en:MediaWiki:Gadget-UserMessages.js]] and [[n:MediaWiki:Gadget-UserMessages.js]] for fa.wikipeida.org >>>>>>>>>>
==Automatic user messages ==
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
'Please link'. Clicking any of the buttons will add one of the following templates to
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?
if (window.template_autosave == false) {} else {
  template_autosave = true;
}

template_pagename = "نام مقاله را بنویسید:";
template_what = "با چی؟";

uMessage = new Array();

uMessage.push(['خوشامدید', 'خوشامدید', 'خوشامدید', false]);
uMessage.push(['خوشامد-آی\u200cپی', 'خوشامد-آی‌پی', 'خوشامد-آی\u200cپی', false]);
uMessage.push(['امضا کنید', 'کاربر جدید > امضا کنید', 'کاربر جدید > امضا کنید', false]);
uMessage.push(['کاربر جدید/صفحه کلید فارسی', 'کاربر جدید > صفحه‌کلید فارسی', 'کاربر جدید > صفحه کلید فارسی', false]);
uMessage.push(['کاربر جدید/ابزار کمک\u200cمترجم', 'کاربر جدید > ابزار کمک‌مترجم', 'کاربر جدید > ابزار کمک\u200cمترجم', false]);
uMessage.push(['کاربر جدید/ابزارهای ویرایشی', 'کاربر جدید > ابزارهای ویرایشی', 'کاربر جدید > ابزارهای ویرایشی', false]);
uMessage.push(['از پیش\u200cنمایش استفاده کنید', 'از پیش‌نمایش استفاده کنید', 'از پیش\u200cنمایش استفاده کنید', false]);
uMessage.push(['کاربر جدید/ویکی\u200cنویسی', 'مقاله > روش مقاله‌نویسی شما', 'مقاله > روش مقاله نویسی', template_pagename]);
uMessage.push(['نوشتار نامناسب', 'مقاله > نوشتار کتره‌ای', 'مقاله > نوشتار کتره‌ای', false]);
uMessage.push(['بیش از حد کوتاه', 'مقاله > بیش از حد کوتاه', 'مقاله > بیش از حد کوتاه', template_pagename]);
uMessage.push(['کاربر جدید/حداقل\u200cهای مقاله', 'مقاله > حداقل‌های مقاله/ترجمه', 'مقاله > حداقل\u200cهای مقاله', false]);
uMessage.push(['تبلیغ مکنید', 'اسپم > تبلیغ مکنید', 'اسپم > تبلیغ مکنید', template_pagename]);
uMessage.push(['پیام سرشناسی', 'اسپم > سرشناسی', 'اسپم > سرشناسی', template_pagename]);
uMessage.push(['کپی مکنید', 'حق‌تکثیر > کپی مکنید', 'حق تکثیر > کپی مکنید', template_pagename]);
uMessage.push(['کاربر جدید/لطفا کپی نکنید!', 'حق‌تکثیر > لطفا کپی نکنید!', 'حق تکثیر > لطفا کپی نکنید!', false]);
uMessage.push(['کاربر جدید/منابع معتبر', 'حق‌تکثیر > منابع معتبر، تحقیق', 'حق تکثیر > منابع معتبر', false]);
uMessage.push(['یادکرد دقیق منبع', 'حق‌تکثیر > یادکرد دقیق منبع', 'حق تکثیر > یادکرد دقیق منبع', template_pagename]);
uMessage.push(['کاربر جدید/ارجاع صحیح', 'حق‌تکثیر > ارجاع صحیح', 'حق تکثیر > ارجاع صحیح', false]);
uMessage.push(['کاربر جدید/مجوز نگاره', 'حق‌تکثیر > مجوز نگاره', 'حق تکثیر > مجوز نگاره', false]);
uMessage.push(['کاربر جدید/هشدار نقض حق تکثیر', 'حق‌تکثیر > بارگذاری نگاره دارای حق تکثیر', 'حق‌تکثیر > بارگذاری نگاره دارای حق تکثیر', false]);
uMessage.push(['کاربر جدید/مختصات\u200cدهی', 'افزودن > مختصات‌دهی', 'افزودن > مختصات\u200cدهی', false]);
uMessage.push(['کاربر جدید/رده\u200cدهی', 'افزودن > رده‌بندی', 'افزودن > رده\u200cدهی', false]);
uMessage.push(['کاربر جدید/میان\u200cویکی', 'افزودن > میان‌ویکی', 'افزودن > میان\u200cویکی', false]);
uMessage.push(['اشتباه گرفته\u200cاید', 'هشدار > اشتباه گرفته‌اید', 'هشدار > اشتباه گرفته\u200cاید', template_what]);
uMessage.push(['هشدار نقض قانون سه برگردان', 'هشدار > نقض قانون ۳برگردان', 'هشدار > نقض قانون سه برگردان', template_pagename]);

// Site info
scriptPath = "/w/index.php";
prettyPath = "/wiki/";
wikiHostname = "fa.wikipedia.org";

// From [[en:Wikipedia:WikiProject User scripts/Scripts/addLink]]
function addLink(where, url1, name1, id, title, key, after, url2, name2) {
  //* where is the id of the toolbar where the button should be added;
  //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
  //
  //* url1 is the URL which will be called when the button is clicked.
  //   javascript: urls can be used to do more complex things.
  //
  //* name1 is what will appear as the name of the button.
  //
  //* id is the id of the button; it's best to define one.
  //   Use a prefix to make sure its unique. Optional.
  //
  //* title is the tooltip title that gives a longer description
  //   of the button; if you define a accesskey, mention it here. Optional.
  //
  //* 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.
    var na = document.createElement('a');
    na.href = url2;
    na.appendChild(document.createTextNode(name2 ? name2 : name1));
    li.appendChild(document.createTextNode(" · ")); //separate them a bit
    li.appendChild(na);
  }

  var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
  if (after) {
    tabs.insertBefore(li, document.getElementById(after));
  } else {
    tabs.appendChild(li);
  }
  //akeytt is deprected and does nothing. who cares about access keys anyhow.
  /*if(id && ta) { //ta does not exist in vector? 
        if(key && title) { ta[id] = [key, title]; }
        else if(key) { ta[id] = [key, '']; }
        else if(title) { ta[id] = ['', title];}
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();*/
  return li;
}

// Add the template
function template_mark(talkpage_fakeaction, message_lang) {
  //if (!message_lang) return; //User pressed cancel

  //Now we assume message templates to be properly autotranslated
  if (message_lang) langparam = '&template_lang=' + message_lang;
  else langparam = '';

  var pagename = encodeURIComponent(wgPageName);
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  document.location = editlk + '&fakeaction=' + talkpage_fakeaction + langparam + '&template_type=1';
}

// Add template to user talk page
function template_addTemplate(template) {
  if (getParamValue('template_lang')) {
    template = template + '/' + getParamValue('template_lang');
  }

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

// Add the template
function template_mark2(talkpage_fakeaction, media_name, can_handle_empty_parameter, add_namespace) {
  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
  // Parameter handling for special cases
  if (add_namespace && media_name.length > 0) media_name = 'File:' + media_name;

  var pagename = encodeURIComponent(wgPageName);
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  document.location = editlk + '&fakeaction=' + talkpage_fakeaction + '&media_name=' + encodeURIComponent(media_name) + '&template_type=2';
}

// Add template to user talk page
function template_addTemplate2(template) {
  if (getParamValue('media_name')) {
    template = template + '|' + getParamValue('media_name');
  }

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


// Do the thing with the stuff here.
function template_onload() {
  if (wgNamespaceNumber == 3) { //NS_USERTALK
    // new section
    try {
      if (skin === 'vector') {
        if (window.useFancyVectorDropdown || window.useFancyVectorDropdown === undefined) {
          try {
            makeVectorFancySection();
            useFancyVectorDropdown = 'done'; //this is for debug. can remove
          } catch (e) {
            document.getElementById('panel').innerHTML += '<div id="p-Notify" class="portal"><h5 lang="fa" xml:lang="fa">Notify</h5><div class="body"><ul> </ul> </div> </div>';
          }
        } else {
          document.getElementById('panel').innerHTML += '<div id="p-Notify" class="portal"><h5 lang="fa" xml:lang="fa">Notify</h5><div class="body">\n <ul> </ul> </div> </div>';
        }
      }
      if (skin === 'monobook') {
        document.getElementById('column-one').innerHTML += '<div id="p-Notify" class="portlet"> <h5 lang="fa" xml:lang="fa">Notify</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');

    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.

  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]);
  }
}

addOnloadHook(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'
  pNotify.innerHTML = ' <h5><span>Notify</span><a href="#" style="background-image:none;"/></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>