پرش به محتوا

مدیاویکی:Gadget-UserMessages.js

از دانشنامه علوم انسانی
نسخهٔ تاریخ ۱۰ دسامبر ۲۰۱۱، ساعت ۱۸:۳۶ توسط imported>Mehran (ساخته‌شده توسط Zack (کاربر:Zack90/UserMessages.js))
(تفاوت) → نسخهٔ قدیمی‌تر | نمایش نسخهٔ فعلی (تفاوت) | نسخهٔ جدیدتر ← (تفاوت)

نکته: پس از انتشار ممکن است برای دیدن تغییرات نیاز باشد که حافظهٔ نهانی مرورگر خود را پاک کنید.

  • فایرفاکس / سافاری: کلید Shift را نگه دارید و روی دکمهٔ Reload کلیک کنید، یا کلید‌های Ctrl-F5 یا Ctrl-R را با هم فشار دهید (در رایانه‌های اپل مکینتاش کلید‌های ⌘-R)
  • گوگل کروم: کلیدهای Ctrl+Shift+R را با هم فشار دهید (در رایانه‌های اپل مکینتاش کلید‌های ⌘-Shift-R)
  • Edge: کلید Ctrl را نگه‌دارید و روی دکمهٔ Refresh کلیک کنید، یا کلید‌های Ctrl-F5 را با هم فشار دهید
/*
<<<<<<<<<< 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 Name
var uTemplate = new Array(24)
uTemplate[0] = 'خوشامد'
uTemplate[1] = 'خوشامد ۲'
uTemplate[2] = 'خوشامدید'
uTemplate[3] = 'خوشامد-آی\u200cپی'
uTemplate[4] = 'نوشتار نامناسب'
uTemplate[5] = 'هشدار نقض قانون سه برگردان'
uTemplate[6] = 'بیش از حد کوتاه'
uTemplate[7] = 'تبلیغ مکنید'
uTemplate[8] = 'کپی مکنید'
uTemplate[9] = 'از پیش\u200cنمایش استفاده کنید'
uTemplate[10] = 'یادکرد دقیق منبع'
uTemplate[11] = 'پیام سرشناسی'
uTemplate[12] = 'امضا کنید'
uTemplate[13] = 'اشتباه گرفته\u200cاید'
uTemplate[14] = 'کاربر جدید/ارجاع صحیح'
uTemplate[15] = 'کاربر جدید/صفحه کلید فارسی'
uTemplate[16] = 'کاربر جدید/مختصات\u200cدهی'
uTemplate[17] = 'کاربر جدید/ویکی\u200cنویسی'
uTemplate[18] = 'کاربر جدید/ابزار کمک\u200cمترجم'
uTemplate[19] = 'کاربر جدید/حداقل\u200cهای مقاله'
uTemplate[20] = 'کاربر جدید/لطفا کپی نکنید!'
uTemplate[21] = 'کاربر جدید/منابع معتبر'
uTemplate[22] = 'کاربر جدید/ابزارهای ویرایشی'
uTemplate[23] = 'کاربر جدید/رده\u200cدهی'
uTemplate[24] = 'کاربر جدید/مجوز نگاره'
uTemplate[25] = 'کاربر جدید/میان\u200cویکی'
 
 
// Text to be shown in Toolbox
var uText = new Array(24)
uText[0] = 'خوشامد گویی نوع اول'
uText[1] = 'خوشامد گویی نوع دوم'
uText[2] = 'خوشامد گویی نوع سوم'
uText[3] = 'خوشامد گویی به آی\u200cپی'
uText[4] = 'هشدار نوشتار نامناسب'
uText[5] = 'هشدار نقض قانون سه برگردان'
uText[6] = 'بیش از حد کوتاه'
uText[7] = 'هشدار تبلیغ مکنید'
uText[8] = 'هشدار کپی مکنید'
uText[9] = 'از پیش\u200cنمایش استفاده کنید'
uText[10] = 'یادکرد دقیق منبع'
uText[11] = 'پیام سرشناسی'
uText[12] = 'امضا کنید'
uText[13] = 'اشتباه گرفته\u200cاید'
uText[14] = 'هشدار ارجاع صحیح'
uText[15] = 'هشدار صفحه کلید فارسی'
uText[16] = 'هشدار مختصات\u200cدهی'
uText[17] = 'هشدار ویکی\u200cنویسی'
uText[18] = 'هشدار ابزار کمک\u200cمترجم'
uText[19] = 'هشدار حداقل\u200cهای مقاله'
uText[20] = 'هشدار لطفا کپی نکنید!'
uText[21] = 'هشدار منابع معتبر'
uText[22] = 'هشدار ابزارهای ویرایشی'
uText[23] = 'هشدار رده\u200cدهی'
uText[24] = 'هشدار مجوز نگاره'
uText[25] = 'هشدار میان\u200cویکی'
 
// Mouseover help text for Toolbox
var uHelp = new Array(24)
uHelp[0] = 'خوشامد گویی نوع اول'
uHelp[1] = 'خوشامد گویی نوع دوم'
uHelp[2] = 'خوشامد گویی نوع سوم'
uHelp[3] = 'خوشامد گویی به آی\u200cپی'
uHelp[4] = 'هشدار نوشتار نامناسب'
uHelp[5] = 'هشدار نقض قانون سه برگردان'
uHelp[6] = 'بیش از حد کوتاه'
uHelp[7] = 'هشدار تبلیغ مکنید'
uHelp[8] = 'هشدار کپی مکنید'
uHelp[9] = 'از پیش\u200cنمایش استفاده کنید'
uHelp[10] = 'یادکرد دقیق منبع'
uHelp[11] = 'پیام سرشناسی'
uHelp[12] = 'امضا کنید'
uHelp[13] = 'اشتباه گرفته\u200cاید'
uHelp[14] = 'هشدار ارجاع صحیح'
uHelp[15] = 'هشدار صفحه کلید فارسی'
uHelp[16] = 'هشدار مختصات\u200cدهی'
uHelp[17] = 'هشدار ویکی\u200cنویسی'
uHelp[18] = 'هشدار ابزار کمک\u200cمترجم'
uHelp[19] = 'هشدار حداقل\u200cهای مقاله'
uHelp[20] = 'هشدار لطفا کپی نکنید!'
uHelp[21] = 'هشدار منابع معتبر'
uHelp[22] = 'هشدار ابزارهای ویرایشی'
uHelp[23] = 'هشدار رده\u200cدهی'
uHelp[24] = 'هشدار مجوز نگاره'
uHelp[25] = 'هشدار میان\u200cویکی'
 
template_pagename = "نام مقاله را بنویسید:";
template_what = "با چی؟";
 
// 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 + '\n~~~~';
  //  the edit summary for when you mark the image. You can change it if you want.
  document.editform.wpSummary.value = 'الگوی «' + template + '» برای اطلاع رسانی به کاربر افزوده شد. ([[MediaWiki:Gadget-UserMessages.js|با استفاده از ابزار]])';
  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 + '\n~~~~';
  //  the edit summary for when you mark the image. You can change it if you want.
  document.editform.wpSummary.value = 'الگوی «' + template + '» برای اطلاع رسانی به کاربر افزوده شد. ([[MediaWiki:Gadget-UserMessages.js|با استفاده از ابزار]])';
  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">\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') {
        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');
 
    addLink(portlet, 'javascript:template_mark(\'0\')', uText[0], 'mark-warn', uHelp[0], null, null);
    addLink(portlet, 'javascript:template_mark(\'1\')', uText[1], 'mark-warn', uHelp[1], null, null);
    addLink(portlet, 'javascript:template_mark(\'2\')', uText[2], 'mark-warn', uHelp[2], null, null);
    addLink(portlet, 'javascript:template_mark(\'3\')', uText[3], 'mark-warn', uHelp[3], null, null);
    addLink(portlet, 'javascript:template_mark(\'4\')', uText[4], 'mark-warn', uHelp[4], null, null);
    addLink(portlet, 'javascript:template_mark2(\'5\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[5], 'mark-warn', uHelp[5]);
    addLink(portlet, 'javascript:template_mark2(\'6\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[6], 'mark-warn', uHelp[6]);
    addLink(portlet, 'javascript:template_mark2(\'7\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[7], 'mark-warn', uHelp[7]);
    addLink(portlet, 'javascript:template_mark2(\'8\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[8], 'mark-warn', uHelp[8]);
    addLink(portlet, 'javascript:template_mark2(\'9\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[9], 'mark-warn', uHelp[9]);
    addLink(portlet, 'javascript:template_mark2(\'10\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[10], 'mark-warn', uHelp[10]);
    addLink(portlet, 'javascript:template_mark2(\'11\', prompt(\'' + template_pagename + '\', \'\'), 0, false)', uText[11], 'mark-warn', uHelp[11]);
    addLink(portlet, 'javascript:template_mark(\'12\')', uText[12], 'mark-warn', uHelp[12], null, null);
    addLink(portlet, 'javascript:template_mark2(\'13\', prompt(\'' + template_what + '\', \'\'), 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_mark(\'16\')', uText[16], 'mark-warn', uHelp[16], null, null);
    addLink(portlet, 'javascript:template_mark(\'18\')', 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_mark(\'22\')', uText[22], 'mark-warn', uHelp[23], null, null);
    addLink(portlet, 'javascript:template_mark(\'23\')', uText[23], 'mark-warn', uHelp[23], null, null);
    addLink(portlet, 'javascript:template_mark(\'24\')', uText[24], 'mark-warn', uHelp[24], null, null);
    addLink(portlet, 'javascript:template_mark(\'25\')', uText[25], 'mark-warn', uHelp[25], 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 < uTemplate.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 (uTemplate[action_idx]);
    else
      template_addTemplate2 (uTemplate[action_idx]);
  }
}
 
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>