مدیاویکی:Gadget-Extra-Editbuttons.js: تفاوت میان نسخهها
ظاهر
imported>Ebrahim حذف کد جلوگیری از کاربران خاص، در این مدت که کاربر دیگری به این فهرست اضافه نشده ببینیم شاید مخاطب کد هم به چنین کاری پایان داده است خصوصاً که عملکرد ابرابزار کمی تغییر کرده است |
اصلاح پیوندها |
||
| (۲۱ نسخهٔ میانی ویرایش شده توسط ۴ کاربر نشان داده نشد) | |||
| خط ۲۹: | خط ۲۹: | ||
}); | }); | ||
} | } | ||
function redirectPost(url, data) { | function redirectPost(url, data) { | ||
var form = document.createElement('form'); | var form = document.createElement('form'); | ||
| خط ۴۳: | خط ۴۳: | ||
} | } | ||
form.submit(); | form.submit(); | ||
} | |||
function addWatchthisParamIfAlreadyIsWatched(object) { | |||
// if unwatch button exists it is in the user's watchlist right now | |||
if ($('#ca-unwatch').length) { | |||
object.wpWatchthis = ''; | |||
} | |||
return object; | |||
} | |||
function bringShowChanges(page, content, summary) { | |||
var url = new URL(mw.config.get('wgScript'), window.location); | |||
url.searchParams.set('title', page); | |||
url.searchParams.set('action', 'submit'); | |||
redirectPost(url.toString(), addWatchthisParamIfAlreadyIsWatched({ | |||
wpTextbox1: content, | |||
wpDiff: '', | |||
wpSummary: summary, | |||
wpUltimateParam: 1 | |||
})); | |||
} | } | ||
| خط ۶۳: | خط ۸۳: | ||
'ابزار پیشرفتهٔ ویرایش متن + ابزار انتقال خودکار میانویکی سنتی به ویکیداده' : | 'ابزار پیشرفتهٔ ویرایش متن + ابزار انتقال خودکار میانویکی سنتی به ویکیداده' : | ||
'ابزار پیشرفتهٔ ویرایش متن' | 'ابزار پیشرفتهٔ ویرایش متن' | ||
)).click(function (e) { | )).addClass('vector-tab-noicon').click(function (e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
Promise.all([ | Promise.all([ | ||
// افزودن میانویکی سنتی به ویکیداده به صورت خودکار | // افزودن میانویکی سنتی به ویکیداده به صورت خودکار | ||
interwikiFix ? | interwikiFix ? | ||
$.get('//dexbot.toolforge.org/interwikidata.php', { | $.get('//dexbot.toolforge.org/interwikidata.php', { | ||
page: mw.config.get('wgPageName') | page: mw.config.get('wgPageName') | ||
| خط ۷۸: | خط ۹۸: | ||
return loadPage(mw.config.get('wgPageName')); | return loadPage(mw.config.get('wgPageName')); | ||
}).then(function (content) { | }).then(function (content) { | ||
bringShowChanges( | |||
mw.config.get('wgPageName'), | |||
persianWikiTools.superTool(content), | |||
'ابرابزار' | |||
); | |||
}); | }); | ||
}); | }); | ||
| خط ۱۳۴: | خط ۱۵۰: | ||
* Makes a simple button from parameters | * Makes a simple button from parameters | ||
*/ | */ | ||
function | function createButton(callback, summaryText, replaceSummary, image, title, alt, idSuffix) { | ||
function clickCallback(e) { | function clickCallback(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
| خط ۱۷۲: | خط ۱۸۸: | ||
} | } | ||
if (document.selection && document.selection.createRange) { // IE/Opera | if (document.selection && document.selection.createRange) { // IE/Opera | ||
// get current selection | // get current selection | ||
txtarea.focus(); | txtarea.focus(); | ||
range = document.selection.createRange(); | range = document.selection.createRange(); | ||
| خط ۲۰۳: | خط ۲۱۹: | ||
// Buttons that FIX wikitext | // Buttons that FIX wikitext | ||
/* ی ک */ | /* ی ک */ | ||
tools.ykArabic = | tools.ykArabic = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianTools.toStandardPersianCharacters); | applyOnSelection(persianTools.toStandardPersianCharacters); | ||
| خط ۲۰۹: | خط ۲۲۵: | ||
'اصلاح نویسه\u200cهای عربی', | 'اصلاح نویسه\u200cهای عربی', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/8/88/Button_YehKeh.png', | ||
'اصلاح ی و ک', | 'اصلاح ی و ک', | ||
'ی و ک', | 'ی و ک', | ||
| خط ۲۱۶: | خط ۲۳۲: | ||
/* فاصلهٔ مجازی */ | /* فاصلهٔ مجازی */ | ||
tools.zwnj = | tools.zwnj = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.wikiApplyZwnj); | applyOnSelection(persianWikiTools.wikiApplyZwnj); | ||
| خط ۲۲۲: | خط ۲۳۸: | ||
'اصلاح فاصلهٔ مجازی', | 'اصلاح فاصلهٔ مجازی', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/d/d0/Button_ZWNJ.png', | ||
'فاصلهٔ مجازی', | 'فاصلهٔ مجازی', | ||
'فاصلهٔ مجازی', | 'فاصلهٔ مجازی', | ||
| خط ۲۲۹: | خط ۲۴۵: | ||
/* اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد */ | /* اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد */ | ||
tools.applyOrthography = | tools.applyOrthography = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.wikiApplyOrthography); | applyOnSelection(persianWikiTools.wikiApplyOrthography); | ||
| خط ۲۳۵: | خط ۲۵۱: | ||
'اصلاح نویسه', | 'اصلاح نویسه', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/9/94/Button_non_standard.png', | ||
'اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد', | 'اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد', | ||
'اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد', | 'اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد', | ||
| خط ۲۴۲: | خط ۲۵۸: | ||
/* اصلاح ارقام */ | /* اصلاح ارقام */ | ||
tools.dig = | tools.dig = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.wikiTextDigitsToPersian); | applyOnSelection(persianWikiTools.wikiTextDigitsToPersian); | ||
| خط ۲۴۸: | خط ۲۶۴: | ||
'اصلاح ارقام', | 'اصلاح ارقام', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/4/4a/Button_numbers.png', | ||
'اصلاح ارقام', | 'اصلاح ارقام', | ||
'ارقام', | 'ارقام', | ||
| خط ۲۵۵: | خط ۲۷۱: | ||
/* اصلاح ارقام مخصوص صفحه انتقال */ | /* اصلاح ارقام مخصوص صفحه انتقال */ | ||
tools.digMove = | tools.digMove = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.wikiConvertToPersianCharacters); | applyOnSelection(persianWikiTools.wikiConvertToPersianCharacters); | ||
| خط ۲۶۱: | خط ۲۷۷: | ||
'اصلاح ارقام', | 'اصلاح ارقام', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/4/4a/Button_numbers.png', | ||
'اصلاح ارقام', | 'اصلاح ارقام', | ||
'ارقام', | 'ارقام', | ||
'numbers' | 'numbers' | ||
); | ); | ||
//عدم تغییر در متن بحثها، سیاستها در فضاهای نام دیگر | //عدم تغییر در متن بحثها، سیاستها در فضاهای نام دیگر | ||
if (mw.config.get('wgNamespaceNumber') === 0) { | if (mw.config.get('wgNamespaceNumber') === 0) { | ||
/* برداشتن پیوند تاریخها */ | /* برداشتن پیوند تاریخها */ | ||
tools.fixBadLinks = | tools.fixBadLinks = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.fixBadLinks); | applyOnSelection(persianWikiTools.fixBadLinks); | ||
| خط ۲۷۶: | خط ۲۹۲: | ||
'[[وپ:پیوند سال|حذف پیوند تاریخها]]', | '[[وپ:پیوند سال|حذف پیوند تاریخها]]', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/1/11/Btn_toolbar_link_remove.png', | ||
'حذف پیوند تاریخها', | 'حذف پیوند تاریخها', | ||
'پیوند تاریخها', | 'پیوند تاریخها', | ||
| خط ۲۸۴: | خط ۳۰۰: | ||
/* یونیکد نشانی وب */ | /* یونیکد نشانی وب */ | ||
tools.urlFix = | tools.urlFix = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.wikiUrlMinifier); | applyOnSelection(persianWikiTools.wikiUrlMinifier); | ||
| خط ۲۹۰: | خط ۳۰۶: | ||
'اصلاح نشانی وب', | 'اصلاح نشانی وب', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/b/ba/Button_decode_URI.png', | ||
'یونی\u200cکدسازی نشانی\u200cها', | 'یونی\u200cکدسازی نشانی\u200cها', | ||
'یونی\u200cکدسازی', | 'یونی\u200cکدسازی', | ||
| خط ۲۹۷: | خط ۳۱۳: | ||
/* اصلاح علامت @ */ | /* اصلاح علامت @ */ | ||
tools.atSignFix = | tools.atSignFix = createButton( | ||
function () { | function () { | ||
applyOnSelection(function (text) { | applyOnSelection(function (text) { | ||
| خط ۳۰۵: | خط ۳۲۱: | ||
'اصلاح @', | 'اصلاح @', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/7/7f/Button_at_sign.png', | ||
'اصلاح علامت @', | 'اصلاح علامت @', | ||
'@', | '@', | ||
| خط ۳۱۲: | خط ۳۲۸: | ||
/* ابرابزار */ | /* ابرابزار */ | ||
tools.superTool = | tools.superTool = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.superTool); | applyOnSelection(persianWikiTools.superTool); | ||
| خط ۳۱۸: | خط ۳۳۴: | ||
'ابرابزار', | 'ابرابزار', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/f/fc/Button_super_tool.png', | ||
'ابرابزار', | 'ابرابزار', | ||
'ابرابزار', | 'ابرابزار', | ||
| خط ۳۲۵: | خط ۳۴۱: | ||
/* ابزار املا */ | /* ابزار املا */ | ||
tools.dictation = | tools.dictation = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.wikiDictation); | applyOnSelection(persianWikiTools.wikiDictation); | ||
| خط ۳۳۱: | خط ۳۴۷: | ||
'اصلاح املا', | 'اصلاح املا', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/a/a3/Button_Dictation-fa.png', | ||
'املا', | 'املا', | ||
'املا', | 'املا', | ||
| خط ۳۳۸: | خط ۳۵۴: | ||
/* ابرابزار مخصوص صفحه انتقال */ | /* ابرابزار مخصوص صفحه انتقال */ | ||
tools.superToolMove = | tools.superToolMove = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.superToolMove); | applyOnSelection(persianWikiTools.superToolMove); | ||
| خط ۳۴۴: | خط ۳۶۰: | ||
'ابرابزار', | 'ابرابزار', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/f/fc/Button_super_tool.png', | ||
'ابرابزار', | 'ابرابزار', | ||
'ابرابزار', | 'ابرابزار', | ||
| خط ۳۵۱: | خط ۳۶۷: | ||
/* اصلاحات قراردادن نقطه */ | /* اصلاحات قراردادن نقطه */ | ||
tools.punc = | tools.punc = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.wikiPunctuation); | applyOnSelection(persianWikiTools.wikiPunctuation); | ||
| خط ۳۵۷: | خط ۳۷۳: | ||
'اصلاح سجاوندی', | 'اصلاح سجاوندی', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/e/ed/Button_punctuation.png', | ||
'نقطه\u200cگذاری', | 'نقطه\u200cگذاری', | ||
'نقطه\u200cگذاری', | 'نقطه\u200cگذاری', | ||
| خط ۳۶۵: | خط ۳۸۱: | ||
// Buttons that add tags | // Buttons that add tags | ||
/* برچسب ویکی\u200cسازی */ | /* برچسب ویکی\u200cسازی */ | ||
tools.wikify = | tools.wikify = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val('{' + '{ویکی\u200cسازی}}\n' + $('#wpTextbox1').val()); | $('#wpTextbox1').val('{' + '{ویکی\u200cسازی}}\n' + $('#wpTextbox1').val()); | ||
| خط ۳۷۱: | خط ۳۸۷: | ||
'برچسب ویکی\u200cسازی', | 'برچسب ویکی\u200cسازی', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/3/38/Button_wikify.png', | ||
'برچسب ویکی\u200cسازی', | 'برچسب ویکی\u200cسازی', | ||
'ویکی\u200cسازی', | 'ویکی\u200cسازی', | ||
| خط ۳۷۸: | خط ۳۹۴: | ||
/* بدون منبع */ | /* بدون منبع */ | ||
tools.noSource = | tools.noSource = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val('{' + '{بدون منبع}}\n' + $('#wpTextbox1').val()); | $('#wpTextbox1').val('{' + '{بدون منبع}}\n' + $('#wpTextbox1').val()); | ||
| خط ۳۸۴: | خط ۴۰۰: | ||
'برچسب منبع', | 'برچسب منبع', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/8/8a/Button_no_source_fa.png', | ||
'برچسب بدون منبع', | 'برچسب بدون منبع', | ||
'بدون منبع', | 'بدون منبع', | ||
| خط ۳۹۱: | خط ۴۰۷: | ||
/* حذف سریع */ | /* حذف سریع */ | ||
tools.speedyDel = | tools.speedyDel = createButton( | ||
function () { | function () { | ||
var temp = $('#wpTextbox1').val(); | var temp = $('#wpTextbox1').val(); | ||
| خط ۳۹۹: | خط ۴۱۵: | ||
'حذف سریع', | 'حذف سریع', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/1/13/Button_delete.png', | ||
'برچسب حذف سریع', | 'برچسب حذف سریع', | ||
'حذف سریع', | 'حذف سریع', | ||
| خط ۴۰۶: | خط ۴۲۲: | ||
/* حذف زماندار */ | /* حذف زماندار */ | ||
tools.prod = | tools.prod = createButton( | ||
function () { | function () { | ||
var temp = $('#wpTextbox1').val(); | var temp = $('#wpTextbox1').val(); | ||
| خط ۴۱۴: | خط ۴۳۰: | ||
'حذف زمان\u200cدار', | 'حذف زمان\u200cدار', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/3/3f/Button_attendre.png', | ||
'برچسب حذف زمان\u200cدار', | 'برچسب حذف زمان\u200cدار', | ||
'حذف زمان\u200cدار', | 'حذف زمان\u200cدار', | ||
| خط ۴۲۱: | خط ۴۳۷: | ||
/* منبع تصویر نامعلوم */ | /* منبع تصویر نامعلوم */ | ||
tools.picSource = | tools.picSource = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val('{' + '{' + 'جا:منبع تصویر نامعلوم' + '}}\n' + $('#wpTextbox1').val()); | $('#wpTextbox1').val('{' + '{' + 'جا:منبع تصویر نامعلوم' + '}}\n' + $('#wpTextbox1').val()); | ||
| خط ۴۲۷: | خط ۴۴۳: | ||
'برچسب منبع', | 'برچسب منبع', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/5/59/Button_image_source.png', | ||
'برچسب منبع تصویر نامعلوم', | 'برچسب منبع تصویر نامعلوم', | ||
'منبع تصویر نامعلوم', | 'منبع تصویر نامعلوم', | ||
| خط ۴۳۴: | خط ۴۵۰: | ||
/* حق تکثیر تصویر نامعلوم */ | /* حق تکثیر تصویر نامعلوم */ | ||
tools.picCopy = | tools.picCopy = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val('{' + '{' + 'جا:حق تکثیر تصویر نامعلوم}}\n' + $('#wpTextbox1').val()); | $('#wpTextbox1').val('{' + '{' + 'جا:حق تکثیر تصویر نامعلوم}}\n' + $('#wpTextbox1').val()); | ||
| خط ۴۴۰: | خط ۴۵۶: | ||
'برچسب حق تکثیر', | 'برچسب حق تکثیر', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/7/7e/Button_image_copyright.png', | ||
'برچسب حق تکثیر تصویر نامعلوم', | 'برچسب حق تکثیر تصویر نامعلوم', | ||
'حق تکثیر تصویر نامعلوم', | 'حق تکثیر تصویر نامعلوم', | ||
| خط ۴۴۷: | خط ۴۶۳: | ||
/* تمیزکاری */ | /* تمیزکاری */ | ||
tools.cleanup = | tools.cleanup = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val('{' + '{تمیزکاری}}\n' + $('#wpTextbox1').val()); | $('#wpTextbox1').val('{' + '{تمیزکاری}}\n' + $('#wpTextbox1').val()); | ||
| خط ۴۵۳: | خط ۴۶۹: | ||
'برچسب تمیزکاری', | 'برچسب تمیزکاری', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/2/2e/Button_broom.png', | ||
'برچسب تمیزکاری', | 'برچسب تمیزکاری', | ||
'تمیزکاری', | 'تمیزکاری', | ||
| خط ۴۶۰: | خط ۴۷۶: | ||
/* اخطار نگاره */ | /* اخطار نگاره */ | ||
tools.imgWarn = | tools.imgWarn = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val(''); | $('#wpTextbox1').val(''); | ||
| خط ۴۷۱: | خط ۴۸۷: | ||
'برچسب نگاره', | 'برچسب نگاره', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/e/ec/Button_aviso.png', | ||
'اخطار نگاره', | 'اخطار نگاره', | ||
'اخطار نگاره', | 'اخطار نگاره', | ||
| خط ۴۷۸: | خط ۴۹۴: | ||
/* حق تکثیر مشکوک */ | /* حق تکثیر مشکوک */ | ||
tools.sus = | tools.sus = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val('{' + '{حق تکثیر مشکوک}}\n' + $('#wpTextbox1').val()); | $('#wpTextbox1').val('{' + '{حق تکثیر مشکوک}}\n' + $('#wpTextbox1').val()); | ||
| خط ۴۸۴: | خط ۵۰۰: | ||
'برچسب حق تکثیر', | 'برچسب حق تکثیر', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/c/c7/Button_Sus.png', | ||
'برچسب حق تکثیر مشکوک', | 'برچسب حق تکثیر مشکوک', | ||
'حق تکثیر مشکوک', | 'حق تکثیر مشکوک', | ||
| خط ۴۹۱: | خط ۵۰۷: | ||
/* نقض حق تکثیر */ | /* نقض حق تکثیر */ | ||
tools.copyR = | tools.copyR = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val(''); | $('#wpTextbox1').val(''); | ||
| خط ۵۰۲: | خط ۵۱۸: | ||
'برچسب حق تکثیر', | 'برچسب حق تکثیر', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/6/6f/Button_CopyR.png', | ||
'برچسب نقض حق تکثیر', | 'برچسب نقض حق تکثیر', | ||
'نقض حق تکثیر', | 'نقض حق تکثیر', | ||
| خط ۵۰۹: | خط ۵۲۵: | ||
/* لحن نامناسب */ | /* لحن نامناسب */ | ||
tools.tone = | tools.tone = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val('{' + '{لحن نامناسب}}\n' + $('#wpTextbox1').val()); | $('#wpTextbox1').val('{' + '{لحن نامناسب}}\n' + $('#wpTextbox1').val()); | ||
| خط ۵۱۵: | خط ۵۳۱: | ||
'برچسب لحن', | 'برچسب لحن', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/f/fc/Button_Tone.png', | ||
'برچسب لحن نامناسب', | 'برچسب لحن نامناسب', | ||
'لحن', | 'لحن', | ||
| خط ۵۲۳: | خط ۵۳۹: | ||
// Buttons that help with wiki writing | // Buttons that help with wiki writing | ||
/* تغییر جهت */ | /* تغییر جهت */ | ||
tools.toggleDirection = | tools.toggleDirection = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1, [name=wpNewTitleMain], .ace_editor').css({ | $('#wpTextbox1, [name=wpNewTitleMain], .ace_editor').css({ | ||
| خط ۵۳۲: | خط ۵۴۸: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/d/d0/Button_toggle_dir.png', | ||
'تغییر جهت جعبهٔ ویرایش', | 'تغییر جهت جعبهٔ ویرایش', | ||
'تغییرجهت', | 'تغییرجهت', | ||
'toggle-dir' | 'toggle-dir' | ||
); | |||
tools.putSelectionInBDI = createButton( | |||
function () { | |||
applyOnSelection(persianWikiTools.putSelectionInBDI); | |||
}, | |||
'جداسازی دوجهته', | |||
false, | |||
'//wiki.iki.ac.ir/w/images/3/31/Button_bdi_tag.png', | |||
'جداسازی دوجهته', | |||
'دوجهته', | |||
'put-in-bdi' | |||
); | ); | ||
/* پیوند درونی */ | /* پیوند درونی */ | ||
tools.wikiLink = | tools.wikiLink = createButton( | ||
function () { | function () { | ||
insertTags('[[', ']]', 'مقاله'); | insertTags('[[', ']]', 'مقاله'); | ||
| خط ۵۴۵: | خط ۵۷۳: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/d/d0/Button_in_wikify.png', | ||
'پیوند', | 'پیوند', | ||
'پیوند', | 'پیوند', | ||
| خط ۵۵۲: | خط ۵۸۰: | ||
/* متن خطخورده */ | /* متن خطخورده */ | ||
tools.strikeTextButton = | tools.strikeTextButton = createButton( | ||
function () { | function () { | ||
insertTags('<s>', '</s>', 'متن خط خورده'); | insertTags('<s>', '</s>', 'متن خط خورده'); | ||
| خط ۵۵۸: | خط ۵۸۶: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/c/c9/Button_strike.png', | ||
'متن خط\u200cخورده', | 'متن خط\u200cخورده', | ||
'متن خط\u200cخورده', | 'متن خط\u200cخورده', | ||
| خط ۵۶۵: | خط ۵۹۳: | ||
/* توضیح */ | /* توضیح */ | ||
tools.commentButton = | tools.commentButton = createButton( | ||
function () { | function () { | ||
insertTags('<!--', '-->', 'توضیح'); | insertTags('<!--', '-->', 'توضیح'); | ||
| خط ۵۷۱: | خط ۵۹۹: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/3/34/Button_hide_comment.png', | ||
'توضیح', | 'توضیح', | ||
'توضیح', | 'توضیح', | ||
| خط ۵۷۸: | خط ۶۰۶: | ||
/* ملزومات مقاله */ | /* ملزومات مقاله */ | ||
tools.addEssentialThings = | tools.addEssentialThings = createButton( | ||
function () { | function () { | ||
insertTags('== جستارهای وابسته ==\n\n== منابع ==\n{' + '{پانویس}}', '', ''); | insertTags('== جستارهای وابسته ==\n\n== منابع ==\n{' + '{پانویس}}', '', ''); | ||
| خط ۵۸۴: | خط ۶۱۲: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/e/ef/Add_note.jpg', | ||
'ملزومات مقاله', | 'ملزومات مقاله', | ||
'ملزومات مقاله', | 'ملزومات مقاله', | ||
| خط ۵۹۰: | خط ۶۱۸: | ||
); | ); | ||
/* خوشامدید */ | /* خوشامدید */ | ||
tools.welcome = | tools.welcome = createButton( | ||
function () { | function () { | ||
insertTags( | insertTags( | ||
| خط ۶۰۰: | خط ۶۲۸: | ||
'خوشامدگویی', | 'خوشامدگویی', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/4/4a/Smilies_Alien_cool.png', | ||
'خوشامدگویی', | 'خوشامدگویی', | ||
'خوشامد', | 'خوشامد', | ||
| خط ۶۰۶: | خط ۶۳۴: | ||
); | ); | ||
/* چپچین */ | /* چپچین */ | ||
tools.chapChin = | tools.chapChin = createButton( | ||
function () { | function () { | ||
insertTags( | insertTags( | ||
| خط ۶۱۶: | خط ۶۴۴: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/e/ea/Button_align_left.png', | ||
'چپ\u200cچین\u200cکردن متن', | 'چپ\u200cچین\u200cکردن متن', | ||
'چپ\u200cچین', | 'چپ\u200cچین', | ||
| خط ۶۲۳: | خط ۶۵۱: | ||
/* اندیس بالا */ | /* اندیس بالا */ | ||
tools.upperText = | tools.upperText = createButton( | ||
function () { | function () { | ||
insertTags('<sup>', '</sup>', 'اندیس'); | insertTags('<sup>', '</sup>', 'اندیس'); | ||
| خط ۶۲۹: | خط ۶۵۷: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/6/6a/Button_sup_letter.png', | ||
'اندیس بالا', | 'اندیس بالا', | ||
'اندیس بالا', | 'اندیس بالا', | ||
| خط ۶۳۶: | خط ۶۶۴: | ||
/* اندیس پایین */ | /* اندیس پایین */ | ||
tools.lowerText = | tools.lowerText = createButton( | ||
function () { | function () { | ||
insertTags('<sub>', '</sub>', 'اندیس'); | insertTags('<sub>', '</sub>', 'اندیس'); | ||
| خط ۶۴۲: | خط ۶۷۰: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/a/aa/Button_sub_letter.png', | ||
'اندیس پایین', | 'اندیس پایین', | ||
'اندیس پایین', | 'اندیس پایین', | ||
| خط ۶۴۹: | خط ۶۷۷: | ||
/* تغییرمسیر */ | /* تغییرمسیر */ | ||
tools.redirectButton = | tools.redirectButton = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val(''); | $('#wpTextbox1').val(''); | ||
| خط ۶۶۰: | خط ۶۸۸: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/c/c8/Button_redirect.png', | ||
'تغییرمسیر', | 'تغییرمسیر', | ||
'تغییرمسیر', | 'تغییرمسیر', | ||
| خط ۶۶۷: | خط ۶۹۵: | ||
/* سال میلادی */ | /* سال میلادی */ | ||
tools.gregYear = | tools.gregYear = createButton( | ||
function () { | function () { | ||
insertTags( | insertTags( | ||
| خط ۶۷۷: | خط ۷۰۵: | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/a/a7/Button_cal.png', | ||
'سال میلادی', | 'سال میلادی', | ||
'میلادی', | 'میلادی', | ||
| خط ۶۸۴: | خط ۷۱۲: | ||
/* مرتبسازی */ | /* مرتبسازی */ | ||
tools.sortText = | tools.sortText = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianTools. | applyOnSelection(function (text) { | ||
return persianTools.persianSort(text.split('\n')).join('\n'); | |||
}); | |||
}, | }, | ||
'', | '', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/3/33/Button_sort.png', | ||
'مرتب\u200cسازی بر اساس الفبا', | 'مرتب\u200cسازی بر اساس الفبا', | ||
'مرتب\u200cسازی', | 'مرتب\u200cسازی', | ||
| خط ۶۹۷: | خط ۷۲۷: | ||
/* شد! */ | /* شد! */ | ||
tools.shod = | tools.shod = createButton( | ||
function () { | function () { | ||
$('#wpTextbox1').val($('#wpTextbox1').val().trimRight() + '\n:{' + '{شد}} ~~' + '~~'); | $('#wpTextbox1').val($('#wpTextbox1').val().trimRight() + '\n:{' + '{شد}} ~~' + '~~'); | ||
| خط ۷۰۳: | خط ۷۳۳: | ||
'شد', | 'شد', | ||
true, | true, | ||
'// | '//wiki.iki.ac.ir/w/images/5/5b/Button_check.png', | ||
'شد', | 'شد', | ||
'شد', | 'شد', | ||
| خط ۷۰۹: | خط ۷۳۹: | ||
); | ); | ||
/* عدد انگلیسی */ | /* عدد انگلیسی */ | ||
tools.toEnNumRobust = | tools.toEnNumRobust = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.robustToEnglishDigits); | applyOnSelection(persianWikiTools.robustToEnglishDigits); | ||
| خط ۷۱۵: | خط ۷۴۵: | ||
'عدد انگلیسی', | 'عدد انگلیسی', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/f/f5/Button_enNum.png', | ||
'عدد انگلیسی', | 'عدد انگلیسی', | ||
'عدد انگلیسی', | 'عدد انگلیسی', | ||
| خط ۷۲۱: | خط ۷۵۱: | ||
); | ); | ||
/* حذف ویکیسازی */ | /* حذف ویکیسازی */ | ||
tools.removeWiki = | tools.removeWiki = createButton( | ||
function () { | function () { | ||
applyOnSelection(persianWikiTools.removeWikiSigne); | applyOnSelection(persianWikiTools.removeWikiSigne); | ||
| خط ۷۲۷: | خط ۷۵۷: | ||
'حذف ویکیسازی', | 'حذف ویکیسازی', | ||
false, | false, | ||
'// | '//wiki.iki.ac.ir/w/images/8/88/Button_NoWiki.png', | ||
'حذف ویکیسازی', | 'حذف ویکیسازی', | ||
'حذف ویکیسازی', | 'حذف ویکیسازی', | ||
| خط ۷۳۳: | خط ۷۶۳: | ||
); | ); | ||
$(function () { | $(function () { | ||
if (typeof Array.prototype.includes !== 'function') { | |||
mw.log.error('Script not supported by browser.'); | |||
return; | |||
} | |||
// کد مناسب ویرایشگر جدید متنی | // کد مناسب ویرایشگر جدید متنی | ||
/*mw.hook('ve.activationComplete').add(function () { | /*mw.hook('ve.activationComplete').add(function () { | ||
var surface = ve.init.target.getSurface(); | var surface = ve.init.target.getSurface(); | ||
if (surface.getMode() === 'source') { | if (surface.getMode() === 'source') { | ||
$('#firstHeading').append($('<img>', { src: '// | $('#firstHeading').append($('<img>', { src: '//wiki.iki.ac.ir/w/images/f/fc/Button_super_tool.png' }).click(function () { | ||
$('.ve-ce-contentBranchNode').get().forEach(function (x) { | $('.ve-ce-contentBranchNode').get().forEach(function (x) { | ||
x.innerText = persianWikiTools.superTool(x.innerText); | x.innerText = persianWikiTools.superTool(x.innerText); | ||
| خط ۷۴۹: | خط ۷۸۳: | ||
space = ' '; | space = ' '; | ||
extraEditButtons = extraEditButtons.concat(tools.toggleDirection, space, tools.ykArabic, tools.zwnj, tools.applyOrthography, | extraEditButtons = extraEditButtons.concat(tools.toggleDirection, tools.putSelectionInBDI, space, tools.ykArabic, tools.zwnj, tools.applyOrthography, | ||
tools.dig, tools.punc, tools.dictation, tools.superTool, space | tools.dig, tools.punc, tools.dictation); | ||
// حذف دکمهٔ ابرابزار در فضاهای بحث؛ از جمله فضای «ویکیپدیا» | |||
var noSuperToolNamespaces = [1, 3, 5, 7, 9, 11, 13, 15, 101, 119, 828, 829]; | |||
if (!noSuperToolNamespaces.includes(mw.config.get('wgNamespaceNumber'))) { | |||
extraEditButtons = extraEditButtons.concat(tools.superTool, space); | |||
} | |||
extraEditButtons = extraEditButtons.concat(tools.urlFix, tools.fixBadLinks, space, tools.welcome, | |||
tools.addEssentialThings, tools.noSource, tools.sus, tools.tone, tools.wikify, | tools.addEssentialThings, tools.noSource, tools.sus, tools.tone, tools.wikify, | ||
tools.shod, tools.cleanup, tools.speedyDel, tools.prod, space, tools.redirectButton, | tools.shod, tools.cleanup, tools.speedyDel, tools.prod, space, tools.redirectButton, | ||
tools.gregYear, tools.strikeTextButton, tools.chapChin, tools.commentButton, space, tools.sortText, space, tools.picCopy, tools.picSource, space, tools.toEnNumRobust); | tools.gregYear, tools.strikeTextButton, tools.chapChin, tools.commentButton, space, tools.sortText, space, tools.picCopy, tools.picSource, space, tools.toEnNumRobust); | ||
var userGroups = mw.config.get('wgUserGroups', []); | |||
// شرط برای کاربری که گشت خودکار دارد | // شرط برای کاربری که گشت خودکار دارد | ||
// ابزار حذف الگوهای ناموجود | // ابزار حذف الگوهای ناموجود | ||
if ( | if (userGroups.includes('autopatrolled') || | ||
userGroups.includes('eliminator') || | |||
userGroups.includes('sysop')) { | |||
extraEditButtons = extraEditButtons.concat(tools.removeWiki); | extraEditButtons = extraEditButtons.concat(tools.removeWiki); | ||
} | } | ||
نسخهٔ کنونی تا ۵ ژانویهٔ ۲۰۲۶، ساعت ۰۴:۴۲
// <nowiki> // DON'T REMOVE THIS LINE EVER
/*global jQuery, mediaWiki, persianWikiTools, persianTools*/
/**
* UI code for Persian tools
* Tests: [[مدیاویکی:Gadget-Extra-Editbuttons-tests.js]] [[وپ:تست]]
* See also:
* * [[مدیاویکی:Gadget-Extra-Editbuttons-persiantools.js]]
* * [[مدیاویکی:Gadget-Extra-Editbuttons-persianwikitools.js]]
* * [[مدیاویکی:Gadget-Extra-Editbuttons-dictionary.js]]
* * [[مدیاویکی:Gadget-Extra-Editbuttons-autoed.js]]
* * [[مدیاویکی:Gadget-Extra-Editbuttons-botworks.js]]
*/
(function ($, mw) {
'use strict';
//
// ابزار در حالت نمایش
//
function loadPage(title) {
return new mw.Api().get({
action: 'query',
prop: 'revisions',
titles: title,
rvprop: 'content',
format: 'json'
}).then(function (data) {
return Object.values(data.query.pages)[0].revisions[0]['*'];
});
}
function redirectPost(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();
}
function addWatchthisParamIfAlreadyIsWatched(object) {
// if unwatch button exists it is in the user's watchlist right now
if ($('#ca-unwatch').length) {
object.wpWatchthis = '';
}
return object;
}
function bringShowChanges(page, content, summary) {
var url = new URL(mw.config.get('wgScript'), window.location);
url.searchParams.set('title', page);
url.searchParams.set('action', 'submit');
redirectPost(url.toString(), addWatchthisParamIfAlreadyIsWatched({
wpTextbox1: content,
wpDiff: '',
wpSummary: summary,
wpUltimateParam: 1
}));
}
if (mw.config.get('wgAction') === 'view' &&
mw.config.get('wgIsArticle') &&
mw.config.get('wgUserEditCount') > 100 &&
mw.config.get('wgPageName') !== 'صفحهٔ_اصلی' &&
$('#mw-imagepage-nofile, #noarticletext').length === 0 &&
mw.config.get('wgNamespaceNumber') !== 6 &&
mw.config.get('wgNamespaceNumber') !== 8) {
$('#ca-abar-abzar').remove();
var interwikiFix = !$('#t-wikibase').length &&
$('.interlanguage-link').length &&
$('.wbc-editpage').length;
$(mw.util.addPortletLink(
'p-views', '#',
interwikiFix ? 'ابرابزار+انتقال میانویکی' : 'ابرابزار',
'ca-abar-abzar',
interwikiFix ?
'ابزار پیشرفتهٔ ویرایش متن + ابزار انتقال خودکار میانویکی سنتی به ویکیداده' :
'ابزار پیشرفتهٔ ویرایش متن'
)).addClass('vector-tab-noicon').click(function (e) {
e.preventDefault();
Promise.all([
// افزودن میانویکی سنتی به ویکیداده به صورت خودکار
interwikiFix ?
$.get('//dexbot.toolforge.org/interwikidata.php', {
page: mw.config.get('wgPageName')
}) : '',
// اجرای کدهای ربات
botworks.trigFillcat,
botworks.trigMissedFileUpload,
botworks.trigMissedRef
]).catch(function () {}).then(function () {
return loadPage(mw.config.get('wgPageName'));
}).then(function (content) {
bringShowChanges(
mw.config.get('wgPageName'),
persianWikiTools.superTool(content),
'ابرابزار'
);
});
});
}
//
// ابزار در حالت ویرایش
//
function insertTags(pre, post, peri) {
if ($('#wpTextbox1').length) {
$('#wpTextbox1').textSelection(
'encapsulateSelection', { pre: pre, peri: peri, post: post }
);
}
}
/**
* Adds edit summary
*/
function addEditSummary(summaryText, replaceSummary) {
var summary = $('input#wpSummary, #wpSummary > input'),
summaryPrefix = '',
pos;
if (mw.util.getParamValue('section') === 'new' ||
summaryText === '' || summary.length === 0) {
return;
}
if (summary.val().includes('*/ ')) {
pos = summary.val().indexOf('*/ ');
summaryPrefix = summary.val().substr(0, pos + 3);
}
if (replaceSummary) {
summary.val(summaryPrefix + summaryText);
} else {
if (summary.val() === summaryPrefix) {
summary.val(summary.val() + summaryText);
} else {
if (!summary.val().includes(summaryText)) { // do not repeat in edit summary
summary.val(summary.val() + '، ' + summaryText);
}
}
}
}
/**
* Makes a simple button from parameters
*/
function createButton(callback, summaryText, replaceSummary, image, title, alt, idSuffix) {
function clickCallback(e) {
e.preventDefault();
callback();
addEditSummary(summaryText, replaceSummary);
}
var img = $('<img>').on('error', function () {
img.replaceWith($('<span>', {
class: 'mw-ui-button mw-ui-small mw-ui-constructive',
text: alt,
style: 'padding: 0;'
}));
}).attr({
src: image,
title: title,
alt: alt
});
var button = $('<span>', {
id: 'persian-wiki-tools-' + idSuffix
}).click(clickCallback).append(img);
return button[0];
}
/**
* Applies the string functions defined below to the
* selected text in the edit box. If no text is selected, applies
* the function to the whole contents of edit box.
*/
function applyOnSelection(callback) {
var txtarea, range, startPos, endPos, selText;
if (document.getElementById('editform') || $('.ns-446').length) {
txtarea = document.getElementById('wpTextbox1');
} else if ($('[name=wpNewTitleMain]')[0]) {
txtarea = $('[name=wpNewTitleMain]')[0];
} else {
return;
}
if (document.selection && document.selection.createRange) { // IE/Opera
// get current selection
txtarea.focus();
range = document.selection.createRange();
selText = range.text;
if (selText) {
range.text = callback(selText);
range.select();
} else {
txtarea.value = callback(txtarea.value);
}
} else if (txtarea.selectionStart || txtarea.selectionStart === 0) { // Mozilla
// get current selection
txtarea.focus();
startPos = txtarea.selectionStart;
endPos = txtarea.selectionEnd;
selText = txtarea.value.substring(startPos, endPos);
// insert tags
if (selText) {
txtarea.value = txtarea.value.substring(0, startPos) + callback(selText) + txtarea.value.substring(endPos, txtarea.value.length);
txtarea.selectionStart = startPos + selText.length;
txtarea.selectionEnd = txtarea.selectionStart;
} else {
txtarea.value = callback(txtarea.value);
}
}
}
var tools = {};
// Buttons that FIX wikitext
/* ی ک */
tools.ykArabic = createButton(
function () {
applyOnSelection(persianTools.toStandardPersianCharacters);
},
'اصلاح نویسه\u200cهای عربی',
false,
'//wiki.iki.ac.ir/w/images/8/88/Button_YehKeh.png',
'اصلاح ی و ک',
'ی و ک',
'YehKeh'
);
/* فاصلهٔ مجازی */
tools.zwnj = createButton(
function () {
applyOnSelection(persianWikiTools.wikiApplyZwnj);
},
'اصلاح فاصلهٔ مجازی',
false,
'//wiki.iki.ac.ir/w/images/d/d0/Button_ZWNJ.png',
'فاصلهٔ مجازی',
'فاصلهٔ مجازی',
'ZWNJ'
);
/* اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد */
tools.applyOrthography = createButton(
function () {
applyOnSelection(persianWikiTools.wikiApplyOrthography);
},
'اصلاح نویسه',
false,
'//wiki.iki.ac.ir/w/images/9/94/Button_non_standard.png',
'اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد',
'اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد',
'apply-orthography'
);
/* اصلاح ارقام */
tools.dig = createButton(
function () {
applyOnSelection(persianWikiTools.wikiTextDigitsToPersian);
},
'اصلاح ارقام',
false,
'//wiki.iki.ac.ir/w/images/4/4a/Button_numbers.png',
'اصلاح ارقام',
'ارقام',
'numbers'
);
/* اصلاح ارقام مخصوص صفحه انتقال */
tools.digMove = createButton(
function () {
applyOnSelection(persianWikiTools.wikiConvertToPersianCharacters);
},
'اصلاح ارقام',
false,
'//wiki.iki.ac.ir/w/images/4/4a/Button_numbers.png',
'اصلاح ارقام',
'ارقام',
'numbers'
);
//عدم تغییر در متن بحثها، سیاستها در فضاهای نام دیگر
if (mw.config.get('wgNamespaceNumber') === 0) {
/* برداشتن پیوند تاریخها */
tools.fixBadLinks = createButton(
function () {
applyOnSelection(persianWikiTools.fixBadLinks);
},
'[[وپ:پیوند سال|حذف پیوند تاریخها]]',
false,
'//wiki.iki.ac.ir/w/images/1/11/Btn_toolbar_link_remove.png',
'حذف پیوند تاریخها',
'پیوند تاریخها',
'datelinks'
);
}
/* یونیکد نشانی وب */
tools.urlFix = createButton(
function () {
applyOnSelection(persianWikiTools.wikiUrlMinifier);
},
'اصلاح نشانی وب',
false,
'//wiki.iki.ac.ir/w/images/b/ba/Button_decode_URI.png',
'یونی\u200cکدسازی نشانی\u200cها',
'یونی\u200cکدسازی',
'decode-URI'
);
/* اصلاح علامت @ */
tools.atSignFix = createButton(
function () {
applyOnSelection(function (text) {
return text.replace(/(\S+?)@(\S+?)/g, '$1{' + '{at}}$2');
});
},
'اصلاح @',
false,
'//wiki.iki.ac.ir/w/images/7/7f/Button_at_sign.png',
'اصلاح علامت @',
'@',
'at-sign'
);
/* ابرابزار */
tools.superTool = createButton(
function () {
applyOnSelection(persianWikiTools.superTool);
},
'ابرابزار',
false,
'//wiki.iki.ac.ir/w/images/f/fc/Button_super_tool.png',
'ابرابزار',
'ابرابزار',
'super-tool'
);
/* ابزار املا */
tools.dictation = createButton(
function () {
applyOnSelection(persianWikiTools.wikiDictation);
},
'اصلاح املا',
false,
'//wiki.iki.ac.ir/w/images/a/a3/Button_Dictation-fa.png',
'املا',
'املا',
'dictation'
);
/* ابرابزار مخصوص صفحه انتقال */
tools.superToolMove = createButton(
function () {
applyOnSelection(persianWikiTools.superToolMove);
},
'ابرابزار',
false,
'//wiki.iki.ac.ir/w/images/f/fc/Button_super_tool.png',
'ابرابزار',
'ابرابزار',
'super-tool'
);
/* اصلاحات قراردادن نقطه */
tools.punc = createButton(
function () {
applyOnSelection(persianWikiTools.wikiPunctuation);
},
'اصلاح سجاوندی',
false,
'//wiki.iki.ac.ir/w/images/e/ed/Button_punctuation.png',
'نقطه\u200cگذاری',
'نقطه\u200cگذاری',
'punctuation'
);
// Buttons that add tags
/* برچسب ویکی\u200cسازی */
tools.wikify = createButton(
function () {
$('#wpTextbox1').val('{' + '{ویکی\u200cسازی}}\n' + $('#wpTextbox1').val());
},
'برچسب ویکی\u200cسازی',
false,
'//wiki.iki.ac.ir/w/images/3/38/Button_wikify.png',
'برچسب ویکی\u200cسازی',
'ویکی\u200cسازی',
'wikify'
);
/* بدون منبع */
tools.noSource = createButton(
function () {
$('#wpTextbox1').val('{' + '{بدون منبع}}\n' + $('#wpTextbox1').val());
},
'برچسب منبع',
false,
'//wiki.iki.ac.ir/w/images/8/8a/Button_no_source_fa.png',
'برچسب بدون منبع',
'بدون منبع',
'no-source'
);
/* حذف سریع */
tools.speedyDel = createButton(
function () {
var temp = $('#wpTextbox1').val();
$('#wpTextbox1').val('');
insertTags('{' + '{' + 'حذف سریع|', '}}\n' + temp, 'معیار');
},
'حذف سریع',
true,
'//wiki.iki.ac.ir/w/images/1/13/Button_delete.png',
'برچسب حذف سریع',
'حذف سریع',
'delete-vote'
);
/* حذف زماندار */
tools.prod = createButton(
function () {
var temp = $('#wpTextbox1').val();
$('#wpTextbox1').val('');
insertTags('{' + '{' + 'جا:حذف زمان\u200cدار|', '}}\n' + temp, 'معیار');
},
'حذف زمان\u200cدار',
true,
'//wiki.iki.ac.ir/w/images/3/3f/Button_attendre.png',
'برچسب حذف زمان\u200cدار',
'حذف زمان\u200cدار',
'attendre'
);
/* منبع تصویر نامعلوم */
tools.picSource = createButton(
function () {
$('#wpTextbox1').val('{' + '{' + 'جا:منبع تصویر نامعلوم' + '}}\n' + $('#wpTextbox1').val());
},
'برچسب منبع',
false,
'//wiki.iki.ac.ir/w/images/5/59/Button_image_source.png',
'برچسب منبع تصویر نامعلوم',
'منبع تصویر نامعلوم',
'image-source'
);
/* حق تکثیر تصویر نامعلوم */
tools.picCopy = createButton(
function () {
$('#wpTextbox1').val('{' + '{' + 'جا:حق تکثیر تصویر نامعلوم}}\n' + $('#wpTextbox1').val());
},
'برچسب حق تکثیر',
false,
'//wiki.iki.ac.ir/w/images/7/7e/Button_image_copyright.png',
'برچسب حق تکثیر تصویر نامعلوم',
'حق تکثیر تصویر نامعلوم',
'image-copyright'
);
/* تمیزکاری */
tools.cleanup = createButton(
function () {
$('#wpTextbox1').val('{' + '{تمیزکاری}}\n' + $('#wpTextbox1').val());
},
'برچسب تمیزکاری',
false,
'//wiki.iki.ac.ir/w/images/2/2e/Button_broom.png',
'برچسب تمیزکاری',
'تمیزکاری',
'broom'
);
/* اخطار نگاره */
tools.imgWarn = createButton(
function () {
$('#wpTextbox1').val('');
insertTags(
'{' + '{' + 'جا:اخطار نگاره|',
'}}',
'نگاره'
);
},
'برچسب نگاره',
false,
'//wiki.iki.ac.ir/w/images/e/ec/Button_aviso.png',
'اخطار نگاره',
'اخطار نگاره',
'aviso'
);
/* حق تکثیر مشکوک */
tools.sus = createButton(
function () {
$('#wpTextbox1').val('{' + '{حق تکثیر مشکوک}}\n' + $('#wpTextbox1').val());
},
'برچسب حق تکثیر',
false,
'//wiki.iki.ac.ir/w/images/c/c7/Button_Sus.png',
'برچسب حق تکثیر مشکوک',
'حق تکثیر مشکوک',
'sus'
);
/* نقض حق تکثیر */
tools.copyR = createButton(
function () {
$('#wpTextbox1').val('');
insertTags(
'{' + '{' + 'جا:نقض حق تکثیر|url=',
'}}',
'نشانی ایرنتنتی'
);
},
'برچسب حق تکثیر',
false,
'//wiki.iki.ac.ir/w/images/6/6f/Button_CopyR.png',
'برچسب نقض حق تکثیر',
'نقض حق تکثیر',
'copyr'
);
/* لحن نامناسب */
tools.tone = createButton(
function () {
$('#wpTextbox1').val('{' + '{لحن نامناسب}}\n' + $('#wpTextbox1').val());
},
'برچسب لحن',
false,
'//wiki.iki.ac.ir/w/images/f/fc/Button_Tone.png',
'برچسب لحن نامناسب',
'لحن',
'tone'
);
// Buttons that help with wiki writing
/* تغییر جهت */
tools.toggleDirection = createButton(
function () {
$('#wpTextbox1, [name=wpNewTitleMain], .ace_editor').css({
'text-align': 'start',
'direction': $('#wpTextbox1, [name=wpNewTitleMain]').css('direction') === 'rtl' ? 'ltr' : 'rtl'
});
},
'',
true,
'//wiki.iki.ac.ir/w/images/d/d0/Button_toggle_dir.png',
'تغییر جهت جعبهٔ ویرایش',
'تغییرجهت',
'toggle-dir'
);
tools.putSelectionInBDI = createButton(
function () {
applyOnSelection(persianWikiTools.putSelectionInBDI);
},
'جداسازی دوجهته',
false,
'//wiki.iki.ac.ir/w/images/3/31/Button_bdi_tag.png',
'جداسازی دوجهته',
'دوجهته',
'put-in-bdi'
);
/* پیوند درونی */
tools.wikiLink = createButton(
function () {
insertTags('[[', ']]', 'مقاله');
},
'',
true,
'//wiki.iki.ac.ir/w/images/d/d0/Button_in_wikify.png',
'پیوند',
'پیوند',
'wikify'
);
/* متن خطخورده */
tools.strikeTextButton = createButton(
function () {
insertTags('<s>', '</s>', 'متن خط خورده');
},
'',
true,
'//wiki.iki.ac.ir/w/images/c/c9/Button_strike.png',
'متن خط\u200cخورده',
'متن خط\u200cخورده',
'strike'
);
/* توضیح */
tools.commentButton = createButton(
function () {
insertTags('<!--', '-->', 'توضیح');
},
'',
true,
'//wiki.iki.ac.ir/w/images/3/34/Button_hide_comment.png',
'توضیح',
'توضیح',
'hide-comment'
);
/* ملزومات مقاله */
tools.addEssentialThings = createButton(
function () {
insertTags('== جستارهای وابسته ==\n\n== منابع ==\n{' + '{پانویس}}', '', '');
},
'',
true,
'//wiki.iki.ac.ir/w/images/e/ef/Add_note.jpg',
'ملزومات مقاله',
'ملزومات مقاله',
'add-note'
);
/* خوشامدید */
tools.welcome = createButton(
function () {
insertTags(
'{' + '{' + 'جا:خوشامد|~~' + '~~}}',
'',
''
);
},
'خوشامدگویی',
true,
'//wiki.iki.ac.ir/w/images/4/4a/Smilies_Alien_cool.png',
'خوشامدگویی',
'خوشامد',
'alien-cool'
);
/* چپچین */
tools.chapChin = createButton(
function () {
insertTags(
'{' + '{چپ\u200cچین}}\n',
'\n{' + '{پایان چپ\u200cچین}}',
'متن چپ\u200cچین\u200cشده'
);
},
'',
true,
'//wiki.iki.ac.ir/w/images/e/ea/Button_align_left.png',
'چپ\u200cچین\u200cکردن متن',
'چپ\u200cچین',
'align-left'
);
/* اندیس بالا */
tools.upperText = createButton(
function () {
insertTags('<sup>', '</sup>', 'اندیس');
},
'',
true,
'//wiki.iki.ac.ir/w/images/6/6a/Button_sup_letter.png',
'اندیس بالا',
'اندیس بالا',
'upper-letter'
);
/* اندیس پایین */
tools.lowerText = createButton(
function () {
insertTags('<sub>', '</sub>', 'اندیس');
},
'',
true,
'//wiki.iki.ac.ir/w/images/a/aa/Button_sub_letter.png',
'اندیس پایین',
'اندیس پایین',
'lower-letter'
);
/* تغییرمسیر */
tools.redirectButton = createButton(
function () {
$('#wpTextbox1').val('');
insertTags(
'#تغییرمسیر [[',
']]',
'پیوند'
);
},
'',
true,
'//wiki.iki.ac.ir/w/images/c/c8/Button_redirect.png',
'تغییرمسیر',
'تغییرمسیر',
'redirect'
);
/* سال میلادی */
tools.gregYear = createButton(
function () {
insertTags(
'[[',
' (میلادی)|]]',
'سال'
);
},
'',
true,
'//wiki.iki.ac.ir/w/images/a/a7/Button_cal.png',
'سال میلادی',
'میلادی',
'cal'
);
/* مرتبسازی */
tools.sortText = createButton(
function () {
applyOnSelection(function (text) {
return persianTools.persianSort(text.split('\n')).join('\n');
});
},
'',
true,
'//wiki.iki.ac.ir/w/images/3/33/Button_sort.png',
'مرتب\u200cسازی بر اساس الفبا',
'مرتب\u200cسازی',
'sort'
);
/* شد! */
tools.shod = createButton(
function () {
$('#wpTextbox1').val($('#wpTextbox1').val().trimRight() + '\n:{' + '{شد}} ~~' + '~~');
},
'شد',
true,
'//wiki.iki.ac.ir/w/images/5/5b/Button_check.png',
'شد',
'شد',
'check'
);
/* عدد انگلیسی */
tools.toEnNumRobust = createButton(
function () {
applyOnSelection(persianWikiTools.robustToEnglishDigits);
},
'عدد انگلیسی',
false,
'//wiki.iki.ac.ir/w/images/f/f5/Button_enNum.png',
'عدد انگلیسی',
'عدد انگلیسی',
'ToEnNumberRobust'
);
/* حذف ویکیسازی */
tools.removeWiki = createButton(
function () {
applyOnSelection(persianWikiTools.removeWikiSigne);
},
'حذف ویکیسازی',
false,
'//wiki.iki.ac.ir/w/images/8/88/Button_NoWiki.png',
'حذف ویکیسازی',
'حذف ویکیسازی',
'removeWiki'
);
$(function () {
if (typeof Array.prototype.includes !== 'function') {
mw.log.error('Script not supported by browser.');
return;
}
// کد مناسب ویرایشگر جدید متنی
/*mw.hook('ve.activationComplete').add(function () {
var surface = ve.init.target.getSurface();
if (surface.getMode() === 'source') {
$('#firstHeading').append($('<img>', { src: '//wiki.iki.ac.ir/w/images/f/fc/Button_super_tool.png' }).click(function () {
$('.ve-ce-contentBranchNode').get().forEach(function (x) {
x.innerText = persianWikiTools.superTool(x.innerText);
});
}));
}
});*/
var extraEditButtons = [],
extraMoveButtons = [],
space = ' ';
extraEditButtons = extraEditButtons.concat(tools.toggleDirection, tools.putSelectionInBDI, space, tools.ykArabic, tools.zwnj, tools.applyOrthography,
tools.dig, tools.punc, tools.dictation);
// حذف دکمهٔ ابرابزار در فضاهای بحث؛ از جمله فضای «ویکیپدیا»
var noSuperToolNamespaces = [1, 3, 5, 7, 9, 11, 13, 15, 101, 119, 828, 829];
if (!noSuperToolNamespaces.includes(mw.config.get('wgNamespaceNumber'))) {
extraEditButtons = extraEditButtons.concat(tools.superTool, space);
}
extraEditButtons = extraEditButtons.concat(tools.urlFix, tools.fixBadLinks, space, tools.welcome,
tools.addEssentialThings, tools.noSource, tools.sus, tools.tone, tools.wikify,
tools.shod, tools.cleanup, tools.speedyDel, tools.prod, space, tools.redirectButton,
tools.gregYear, tools.strikeTextButton, tools.chapChin, tools.commentButton, space, tools.sortText, space, tools.picCopy, tools.picSource, space, tools.toEnNumRobust);
var userGroups = mw.config.get('wgUserGroups', []);
// شرط برای کاربری که گشت خودکار دارد
// ابزار حذف الگوهای ناموجود
if (userGroups.includes('autopatrolled') ||
userGroups.includes('eliminator') ||
userGroups.includes('sysop')) {
extraEditButtons = extraEditButtons.concat(tools.removeWiki);
}
extraEditButtons = extraEditButtons.concat(space).concat(window.userCustomEditButtons || []);
extraMoveButtons = extraMoveButtons.concat(tools.superToolMove, space, tools.toggleDirection, space,
tools.ykArabic, tools.zwnj, tools.applyOrthography, tools.digMove, tools.punc, space, tools.dictation);
$('#persian-wiki-tools').remove();
if ($('#wpTextbox1').length) {
$('<div>', {
id: 'persian-wiki-tools',
dir: 'rtl',
style: 'float:right;'
}).append(extraEditButtons).insertBefore('#wpTextbox1');
} else if ($('#movepage').length) {
$('<span>', {
id: 'persian-wiki-tools'
}).append(extraMoveButtons).insertAfter('#wpNewTitle');
}
});
}(jQuery, mediaWiki));