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

از ویکی‌پدیا، دانشنامهٔ آزاد

نکته: برای دیدن تغییرات، ممکن است نیاز باشد که حافظهٔ نهانی مرورگر خود را پس از انتشار پاک‌سازی کنید. گوگل کروم، فایرفاکس، مایکروسافت اج و سافاری: کلید Shift را نگه دارید و روی دکمهٔ Reload در نوار ابزار مرورگر کلیک کنید. برای آگاهی از جزئیات و نحوهٔ پاک‌سازی حافظهٔ نهانی سایر مرورگرها، صفحهٔ ویکی‌پدیا:میانگیر مرورگرتان را خالی کنید را ببینید.

/*
<<<<<<<<<< derived from [[n:en:MediaWiki:Gadget-UserMessages.js]] and [[n:MediaWiki:Gadget-UserMessages.js]] for fa.wikipeida.org >>>>>>>>>>
adapted by [[user:Reza1615]] 
*/
// <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.template2_autosave == false){}else{ template2_autosave = true; }
 
// template2 Name
var utemplate22 = new Array(23)
utemplate22[0]  =  'جا:پیشنهاد حذف'
utemplate22[1]  =  'حذف سریع'
utemplate22[2]  =  'ویکی\u200cسازی'
utemplate22[3]  =  'تمیزکاری'
utemplate22[4]  =  'لحن'
utemplate22[5]  =  'طفره\u200cآمیز'
utemplate22[6]  =  'نامفهوم'
utemplate22[7]  =  'طرفداری'
utemplate22[8]  =  'درستی'
utemplate22[9]  =  'سرشناسی‏'
utemplate22[10]  =  'دیگر کاربردها'
utemplate22[11]  =  'ابهام\u200cزدایی'
utemplate22[12]  =  'منبع'
utemplate22[13]  =  'بهبود منبع'
utemplate22[14]  =  'منبع نامعتبر'
utemplate22[15]  =  'نقض حق تکثیر'
utemplate22[16]  =  'حق تکثیر مشکوک'
utemplate22[17]  =  'عنوان مقاله'
utemplate22[18]  =  'ادغام با'
utemplate22[19]  =  'ادغام از'
utemplate22[20]  =  'ادغامت'
utemplate22[21]  =  'تبلیغات'
utemplate22[22]  =  'خودستایی'
utemplate22[23]  =  'جا:ویرایش/روز'
utemplate22[24]  =  'رویداد روز'
 
 
// Text to be shown in Toolbox
var uText2= new Array(23)
uText2[0]  =  'حذف > پیشنهاد حذف'
uText2[1]  =  'حذف > حذف سریع'
uText2[2]  =  'تمیزکاری > ویکی\u200cسازی'
uText2[3]  =  'تمیزکاری > تمیزکاری'
uText2[4]  =  'مفهوم >  لحن'
uText2[5]  =  'مفهوم >  طفره\u200cآمیز'
uText2[6]  =  'مفهوم >  نامفهوم'
uText2[7]  =  'مفهوم >  طرفداری'
uText2[8]  =  'مفهوم >  درستی'
uText2[9]  =  'مفهوم >  سرشناسی‏'
uText2[10]  =  'ابهام‌زدایی > دیگر کاربردها'
uText2[11]  =  'ابهام‌زدایی > ابهام\u200cزدایی'
uText2[12]  =  'منابع > منبع'
uText2[13]  =  'منابع > بهبود منبع'
uText2[14]  =  'منابع > منبع نامعتبر'
uText2[15]  =  'منابع > نقض حق تکثیر'
uText2[16]  =  'منابع > حق تکثیر مشکوک'
uText2[17]  =  'عنوان > عنوان مقاله'
uText2[18]  =  'ادغام > ادغام با'
uText2[19]  =  'ادغام > ادغام از'
uText2[20]  =  'ادغام > ادغام تاریخچه'
uText2[21]  =  'اسپم > تبلیغات'
uText2[22]  =  'اسپم > خودستایی'
uText2[23]  =  'ویرایش > در حال ویرایش'
uText2[24]  =  'رویداد روز'
 
// Mouseover help text for Toolbox
var uHelp2 = new Array(23)
uHelp2[0]  =  'حذف > پیشنهاد حذف'
uHelp2[1]  =  'حذف > حذف سریع'
uHelp2[2]  =  'تمیزکاری > ویکی\u200cسازی'
uHelp2[3]  =  'تمیزکاری > تمیزکاری'
uHelp2[4]  =  'مفهوم >  لحن'
uHelp2[5]  =  'مفهوم >  طفره\u200cآمیز'
uHelp2[6]  =  'مفهوم >  نامفهوم'
uHelp2[7]  =  'مفهوم >  طرفداری'
uHelp2[8]  =  'مفهوم >  درستی'
uHelp2[9]  =  'مفهوم >  سرشناسی‏'
uHelp2[10]  =  'ابهام‌زدایی > دیگر کاربردها'
uHelp2[11]  =  'ابهام‌زدایی > ابهام\u200cزدایی'
uHelp2[12]  =  'منابع > منبع'
uHelp2[13]  =  'منابع > بهبود منبع'
uHelp2[14]  =  'منابع > منبع نامعتبر'
uHelp2[15]  =  'منابع > نقض حق تکثیر'
uHelp2[16]  =  'منابع > حق تکثیر مشکوک'
uHelp2[17]  =  'عنوان > عنوان مقاله'
uHelp2[18]  =  'ادغام > ادغام با'
uHelp2[19]  =  'ادغام > ادغام از'
uHelp2[20]  =  'ادغام > ادغام تاریخچه'
uHelp2[21]  =  'اسپم > تبلیغات'
uHelp2[22]  =  'اسپم > خودستایی'
uHelp2[23]  =  'ویرایش > در حال ویرایش'
uHelp2[24]  =  'ویرایش > رویداد روز'
 
 
 
template2_pagename2 = "لطفاً نام مقاله مورد نظر را بنویسید";
template2_what2 = "لطفاً علت حذف را بنویسید";
template2_editing= "چند روز دیگر ویرایش مقاله تمام خواهد شد؟ ورودی فقط عدد باشد"
 
// Site info
scriptPath = "/w/index.php";
prettyPath = "/wiki/";
wikiHostname = "fa.wikipedia.org";
 
// From [[en:Wikipedia:WikiProject User scripts/Scripts/addLink]]
function addLink(where, url1, name3, id, title, key, after, url2, name4)
{
    var na2 = document.createElement('a');
    na2.href = url1;
    na2.appendChild(document.createTextNode(name3));
    var li2 = document.createElement('li');
    if(id) li2.id = id;
    li2.appendChild(na2);
 
    if (url2) { //Another link, brother of the previous.
       var na2 = document.createElement('a');
       na2.href = url2;
       na2.appendChild(document.createTextNode(name4 ? name4 : name3));
       li2.appendChild(document.createTextNode(" · ")); //separate them a bit
       li2.appendChild(na2);
    }
 
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li2,document.getElementById(after));
    } else {
        tabs.appendChild(li2);
    }
    //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 li2;
}
 
// Add the template2
function template2_mark(page_fakeaction, message_lang) {
  //if (!message_lang) return; //User pressed cancel
 
  //Now we assume message template2s to be properly autotranslated
  if (message_lang) langparam='&template2_lang=' + message_lang;
  else langparam='';
 
  var pagename2 = encodeURIComponent(mw.config.get('wgPageName'));
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  document.location = editlk + '&fakeaction=' + page_fakeaction + langparam + '&template2_type=1';
}
 
// Add template2 to user talk page
function template2_addtemplate(template2) {
  if (getParamValue('template2_lang')) {
          template2 = template2 + '/' + getParamValue('template2_lang');
  }
 
  var txt = '{{' + template2 + '}}';
  document.editform.wpTextbox1.value =  txt + '\n'+document.editform.wpTextbox1.value;
  //  the edit summary for when you mark the image. You can change it if you want.
  document.editform.wpSummary.value = 'برچسب «' + template2 + '» به مقاله با استفاده از [[ویکی‌پدیا:ابزار برچسب‌گذار|ابزار برچسب‌گذار]]';
  if (template2_autosave) document.editform.wpSave.click();
}
 
// Add the template2
function template2_mark2(page_fakeaction, media_name, can_handle_empty_parameter, add_namespace) {
  if (media_name == null) return; // User pressed cancel
 
  // Parameter handling for special cases
  if (add_namespace && media_name.length > 0) media_name = 'File:' + media_name;
  if (media_name != '' && can_handle_empty_parameter == 0) { // User did not supply parameter and template2 cannot handle that
  var pagename2 = encodeURIComponent(mw.config.get('wgPageName'));
  var editlk2 = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  document.location = editlk2 + '&fakeaction=' + page_fakeaction + '&media_name=' + encodeURIComponent (media_name) + '&template2_type=2';
}
}
// Add template2 to user talk page
function template2_addtemplate2(template2) {
  if (getParamValue('media_name')) {
          template2 = template2 + '|' + getParamValue('media_name');
  }
 
  var txt = '{{' + template2 + '}}';
  document.editform.wpTextbox1.value =  txt + '\n'+document.editform.wpTextbox1.value;
  //  the edit summary for when you mark the image. You can change it if you want.
  document.editform.wpSummary.value = 'برچسب «' + template2 + '» به مقاله با استفاده از [[ویکی‌پدیا:ابزار برچسب‌زن|ابزار برچسب‌زن]]';
  if (template2_autosave) document.editform.wpSave.click();
}
 
 
// Do the thing with the stuff here.
function template2_onload2() {
  if (mw.config.get('wgNamespaceNumber') == 0) { //NS_USERTALK
    // new section
    try {
    if (skin === 'vector') {
        if (window.useFancyVectorDropdown || window.useFancyVectorDropdown === undefined) {
            try {
                makeVectorFancySection2();
                useFancyVectorDropdown = 'done'; //this is for debug. can remove
            }
            catch (e) {
                document.getElementById('panel2').innerHTML += '<div id="p-Tagger" class="portal"><h5 lang="fa" xml:lang="fa">Tagger</h5><div class="body"><ul> </ul> </div> </div>';
            }
        }
        else {
            document.getElementById('panel2').innerHTML += '<div id="p-Tagger" class="portal"><h5 lang="fa" xml:lang="fa">Tagger</h5><div class="body">\n <ul> </ul> </div> </div>';
       }
    }
    if (skin === 'monobook') {
        document.getElementById('column-one').innerHTML += '<div id="p-Tagger" class="portlet"> <h5 lang="fa" xml:lang="fa">Tagger</h5> <div class="pBody">	<ul></ul></div>	</div>';
    }
    } catch (e) {} //ignore errors and just use tb if they happen.
    var portlet = (document.getElementById('p-Tagger') ? 'p-Tagger' : 'p-navigation');
  //"p-cactions", "p-personal", "p-navigation", or "p-tb"
    addLink(portlet, 'javascript:template2_mark(\'0\')', uText2[0], 'mark-warn', uHelp2[0], null, null);    
    addLink(portlet, 'javascript:template2_mark2(\'1\', prompt(\'' + template2_what2+ '\', \'\'), 0, false)', uText2[1], 'mark-warn', uHelp2[1]);
    addLink(portlet, 'javascript:template2_mark(\'2\')', uText2[2], 'mark-warn', uHelp2[2], null, null);
    addLink(portlet, 'javascript:template2_mark(\'3\')', uText2[3], 'mark-warn', uHelp2[3], null, null);
    addLink(portlet, 'javascript:template2_mark(\'4\')', uText2[4], 'mark-warn', uHelp2[4], null, null);
    addLink(portlet, 'javascript:template2_mark(\'5\')', uText2[5], 'mark-warn', uHelp2[5], null, null);
    addLink(portlet, 'javascript:template2_mark(\'6\')', uText2[6], 'mark-warn', uHelp2[6], null, null);
    addLink(portlet, 'javascript:template2_mark(\'7\')', uText2[7], 'mark-warn', uHelp2[7], null, null);
    addLink(portlet, 'javascript:template2_mark(\'8\')', uText2[8], 'mark-warn', uHelp2[8], null, null);
    addLink(portlet, 'javascript:template2_mark(\'9\')', uText2[9], 'mark-warn', uHelp2[9], null, null);
    addLink(portlet, 'javascript:template2_mark(\'10\')', uText2[10], 'mark-warn', uHelp2[10], null, null);
    addLink(portlet, 'javascript:template2_mark(\'11\')', uText2[11], 'mark-warn', uHelp2[11], null, null);
    addLink(portlet, 'javascript:template2_mark(\'12\')', uText2[12], 'mark-warn', uHelp2[12], null, null);
    addLink(portlet, 'javascript:template2_mark(\'13\')', uText2[13], 'mark-warn', uHelp2[13], null, null);
    addLink(portlet, 'javascript:template2_mark(\'14\')', uText2[14], 'mark-warn', uHelp2[14], null, null);
    addLink(portlet, 'javascript:template2_mark(\'15\')', uText2[15], 'mark-warn', uHelp2[15], null, null);
    addLink(portlet, 'javascript:template2_mark(\'16\')', uText2[16], 'mark-warn', uHelp2[16], null, null);
    addLink(portlet, 'javascript:template2_mark(\'17\')', uText2[17], 'mark-warn', uHelp2[17], null, null);
    addLink(portlet, 'javascript:template2_mark2(\'18\', prompt(\'' + template2_pagename2 + '\', \'\'), 0, false)', uText2[18], 'mark-warn', uHelp2[18]);
    addLink(portlet, 'javascript:template2_mark2(\'19\', prompt(\'' + template2_pagename2 + '\', \'\'), 0, false)', uText2[19], 'mark-warn', uHelp2[19]);
    addLink(portlet, 'javascript:template2_mark2(\'20\', prompt(\'' + template2_pagename2 + '\', \'\'), 0, false)', uText2[20], 'mark-warn', uHelp2[20]);
    addLink(portlet, 'javascript:template2_mark(\'21\')', uText2[21], 'mark-warn', uHelp2[21], null, null);
    addLink(portlet, 'javascript:template2_mark(\'22\')', uText2[22], 'mark-warn', uHelp2[22], null, null);
   addLink(portlet, 'javascript:template2_mark2(\'23\', prompt(\'' + template2_editing + '\', \'\'), 0, false)', uText2[23], 'mark-warn', uHelp2[23]);
    addLink(portlet, 'javascript:template2_mark(\'24\')', uText2[24], 'mark-warn', uHelp2[24], null, null);
  }
// Important thing and stuff above.
 
  var fakeaction2 = getParamValue('fakeaction');
  var template2_type = getParamValue('template2_type');	// Fetch what template2 to add
 
  var action_idx2 = -1;
  try {
    action_idx2 = parseInt (fakeaction2, 10);
  } catch (some_error) {
    action_idx2 = -1;    
  }
  var add_idx2 = -1;
  try {
    add_idx2 = parseInt (template2_type, 10);
  } catch (some_error) {
    add_idx2 = -1;    
  }
  if (add_idx2 >= 1 && add_idx2 <= 2 && action_idx2 >= 0 && action_idx2 < utemplate22.length) {
    //may i take this moment to mention, this script is very very confusing - bawolff
    if (mw.config.get('wgNamespaceNumber') !== 0) { 
      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_idx2 == 1)
      template2_addtemplate (utemplate22[action_idx2]);
    else
      template2_addtemplate2 (utemplate22[action_idx2]);
  }
}
 
$(document).ready(template2_onload2);
 
function makeVectorFancySection2()  {
//wrap this in a try. this might be somewhat delicate at the moment.
var pTagger = document.createElement('div');
pTagger.id = 'p-Tagger'
pTagger.className = 'vectorMenu'
pTagger.innerHTML = ' <h5><span>Tagger</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 pViews2 = document.getElementById('p-views');
rightNav.insertBefore(pTagger, pViews2 .nextSibling)
}
// </source>