مدیاویکی:Gadget-friendlywelcome-2022.js
نکته: برای دیدن تغییرات، ممکن است نیاز باشد که حافظهٔ نهانی مرورگر خود را پس از انتشار پاکسازی کنید. گوگل کروم، فایرفاکس، مایکروسافت اج و سافاری: کلید ⇧ Shift را نگه دارید و روی دکمهٔ Reload در نوار ابزار مرورگر کلیک کنید. برای آگاهی از جزئیات و نحوهٔ پاکسازی حافظهٔ نهانی سایر مرورگرها، صفحهٔ ویکیپدیا:میانگیر مرورگرتان را خالی کنید را ببینید.
// <nowiki>
(function($) {
/*
****************************************
*** friendlywelcome.js: Welcome module
****************************************
* Mode of invocation: Tab ("Wel"), or from links on diff pages
* Active on: Any page with relevant user name (userspace,
* contribs, etc.) and diff pages
*/
Twinkle.welcome = function friendlywelcome() {
if (mw.util.getParamValue('friendlywelcome')) {
if (mw.util.getParamValue('friendlywelcome') === 'auto') {
Twinkle.welcome.auto();
} else {
Twinkle.welcome.semiauto();
}
} else {
Twinkle.welcome.normal();
}
};
Twinkle.welcome.auto = function() {
if (mw.util.getParamValue('action') !== 'edit') {
// userpage not empty, aborting auto-welcome
return;
}
Twinkle.welcome.welcomeUser();
};
Twinkle.welcome.semiauto = function() {
Twinkle.welcome.callback(mw.config.get('wgRelevantUserName'));
};
Twinkle.welcome.normal = function() {
if (mw.util.getParamValue('diff')) {
// check whether the contributors' talk pages exist yet
var $oList = $('#mw-diff-otitle2').find('span.mw-usertoollinks a.new:contains(بحث)').first();
var $nList = $('#mw-diff-ntitle2').find('span.mw-usertoollinks a.new:contains(بحث)').first();
if ($oList.length > 0 || $nList.length > 0) {
var spanTag = function(color, content) {
var span = document.createElement('span');
span.style.color = color;
span.appendChild(document.createTextNode(content));
return span;
};
var welcomeNode = document.createElement('strong');
var welcomeLink = document.createElement('a');
welcomeLink.appendChild(spanTag('Black', '['));
welcomeLink.appendChild(spanTag('Goldenrod', 'خوشامد'));
welcomeLink.appendChild(spanTag('Black', ']'));
welcomeNode.appendChild(welcomeLink);
if ($oList.length > 0) {
var oHref = $oList.attr('href');
var oWelcomeNode = welcomeNode.cloneNode(true);
oWelcomeNode.firstChild.setAttribute('href', oHref + '&' + $.param({
friendlywelcome: Twinkle.getPref('quickWelcomeMode') === 'auto' ? 'auto' : 'norm',
vanarticle: Morebits.pageNameNorm
}));
$oList[0].parentNode.parentNode.appendChild(document.createTextNode(' '));
$oList[0].parentNode.parentNode.appendChild(oWelcomeNode);
}
if ($nList.length > 0) {
var nHref = $nList.attr('href');
var nWelcomeNode = welcomeNode.cloneNode(true);
nWelcomeNode.firstChild.setAttribute('href', nHref + '&' + $.param({
friendlywelcome: Twinkle.getPref('quickWelcomeMode') === 'auto' ? 'auto' : 'norm',
vanarticle: Morebits.pageNameNorm
}));
$nList[0].parentNode.parentNode.appendChild(document.createTextNode(' '));
$nList[0].parentNode.parentNode.appendChild(nWelcomeNode);
}
}
}
// Users and IPs but not IP ranges
if (mw.config.exists('wgRelevantUserName') && !Morebits.ip.isRange(mw.config.get('wgRelevantUserName'))) {
Twinkle.addPortletLink(function() {
Twinkle.welcome.callback(mw.config.get('wgRelevantUserName'));
}, 'خوشامد', 'friendly-welcome', 'خوشامدگویی به کاربر');
}
};
Twinkle.welcome.welcomeUser = function welcomeUser() {
Morebits.status.init(document.getElementById('mw-content-text'));
$('#catlinks').remove();
var params = {
template: Twinkle.getPref('quickWelcomeTemplate'),
article: mw.util.getParamValue('vanarticle') || '',
mode: 'auto'
};
var userTalkPage = mw.config.get('wgFormattedNamespaces')[3] + ':' + mw.config.get('wgRelevantUserName');
Morebits.wiki.actionCompleted.redirect = userTalkPage;
Morebits.wiki.actionCompleted.notice = 'خوشامدگویی انجام شد، در حال بارگیری صفحهٔ بحث تا چند لحظهٔ دیگر';
var wikipedia_page = new Morebits.wiki.page(userTalkPage, 'اعمال تغییرات در صفحهٔ بحث');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.welcome.callbacks.main);
};
Twinkle.welcome.callback = function friendlywelcomeCallback(uid) {
if (uid === mw.config.get('wgUserName') && !confirm('آیا از خوشامدگویی به خودتان مطمئن هستید؟...')) {
return;
}
var Window = new Morebits.simpleWindow(600, 420);
Window.setTitle('خوشامدگویی به کاربر');
Window.setScriptName('توینکل');
// Window.addFooterLink('Welcoming Committee', 'WP:WC');
Window.addFooterLink('ترجیحات خوشامدگویی', 'وپ:توینکل/ترجیحات#welcome');
Window.addFooterLink('راهنمای توینکل', 'وپ:توینکل/توضیحات#خوشآمد');
Window.addFooterLink('ارائهٔ بازخورد', 'بوپ:توینکل');
var form = new Morebits.quickForm(Twinkle.welcome.callback.evaluate);
form.append({
type: 'select',
name: 'type',
label: 'نوع خوشامدگویی:',
event: Twinkle.welcome.populateWelcomeList,
list: [
{ type: 'option', value: 'standard', label: 'خوشامدگویی استاندارد', selected: !mw.util.isIPAddress(mw.config.get('wgRelevantUserName')) },
{ type: 'option', value: 'anonymous', label: 'خوشامدگیی به آیپیها', selected: mw.util.isIPAddress(mw.config.get('wgRelevantUserName')) },
/* { type: 'option', value: 'wikiProject', label: 'خوشامدگویی ویکیپروژه' }, */
{ type: 'option', value: 'nonEnglish', label: 'خوشامدگوییهای غیرفارسی' }
]
});
form.append({
type: 'div',
id: 'welcomeWorkArea',
className: 'morebits-scrollbox'
});
form.append({
type: 'input',
name: 'article',
label: '* مقاله برای پیونددهی (در صورت پشیتبانی توسط الگو):',
value: mw.util.getParamValue('vanarticle') || '',
tooltip: 'در صورت پشتیبانی توسط الگو، میتوان پیوندی به یک مقاله را در درون متن خوشامد درج کرد. برای جلوگیری از پیونددهی، این جعبه را خالی بگذارید. الگوهایی که از پیونددهی به مقاله پشتیبانی میکنند، با یک ستاره علامتگذاری شدهاند.'
});
var previewlink = document.createElement('a');
$(previewlink).click(function() {
Twinkle.welcome.callbacks.preview(result); // |result| is defined below
});
previewlink.style.cursor = 'pointer';
previewlink.textContent = 'پیشنمایش';
form.append({ type: 'div', name: 'welcomepreview', label: [ previewlink ] });
form.append({ type: 'submit' });
var result = form.render();
Window.setContent(result);
Window.display();
// initialize the welcome list
var evt = document.createEvent('Event');
evt.initEvent('change', true, true);
result.type.dispatchEvent(evt);
};
Twinkle.welcome.populateWelcomeList = function(e) {
var type = e.target.value;
var container = new Morebits.quickForm.element({ type: 'fragment' });
if ((type === 'standard' || type === 'anonymous') && Twinkle.getPref('customWelcomeList').length) {
container.append({ type: 'header', label: 'الگوهای خوشامدگویی سفارشی' });
container.append({
type: 'radio',
name: 'template',
list: Twinkle.getPref('customWelcomeList'),
event: function() {
e.target.form.article.disabled = false;
}
});
}
var sets = Twinkle.welcome.templates[type];
$.each(sets, function(label, templates) {
container.append({ type: 'header', label: label });
container.append({
type: 'radio',
name: 'template',
list: $.map(templates, function(properties, template) {
return {
value: template,
label: '{{' + template + '}}: ' + properties.description + (properties.linkedArticle ? '\u00A0*' : ''), // U+00A0 NO-BREAK SPACE
tooltip: properties.tooltip // may be undefined
};
}),
event: function(ev) {
ev.target.form.article.disabled = !templates[ev.target.value].linkedArticle;
}
});
});
var rendered = container.render();
$(e.target.form).find('div#welcomeWorkArea').empty().append(rendered);
var firstRadio = e.target.form.template[0];
firstRadio.checked = true;
var vals = sets[Object.keys(sets)[0]];
e.target.form.article.disabled = vals[firstRadio.value] ? !vals[firstRadio.value].linkedArticle : true;
};
// A list of welcome templates and their properties and syntax
// The four fields that are available are "description", "linkedArticle", "syntax", and "tooltip".
// The three magic words that can be used in the "syntax" field are:
// - $USERNAME$ - replaced by the welcomer's username, depending on user's preferences
// - $ARTICLE$ - replaced by an article name, if "linkedArticle" is true
// - $HEADER$ - adds a level 2 header (most templates already include this)
Twinkle.welcome.templates = {
standard: {
'الگوهای خوشامدگویی استاندارد': {
'خوشامد ۳': {
description: 'خوشامدگویی استاندارد',
linkedArticle: true,
syntax: '{{جا:خوشامد ۳|$USERNAME$|مقاله=$ARTICLE$}} ~~~~'
},
'خوشامد': {
description: 'یک پیام خوشامدگویی با فهرستی کوتاه از پیوندهای کاربردی',
linkedArticle: true,
syntax: '{{جا:خوشامد|$USERNAME$|مقاله=$ARTICLE$}} ~~~~'
},
'خوشامد-کوتاه': {
description: 'پیام کوتاه خوشامدگویی',
syntax: '{{جا:خوشامد-کوتاه|سرآیند=بله|$EXTRA$}}'
},
'کلوچه خوشامد': {
description: 'پیام خوشامدگویی بههمراه تعدادی پیوند کاربردی و یک بشقاب کلوچه',
syntax: '{{جا:کلوچه خوشامد}} ~~~~'
},
'خوشامدگویی': {
description: 'پیام خوشامدگویی بههمراه پیوندهای راهنما و نکات ابتدایی ویرایشی',
syntax: '{{جا:خوشامدگویی}}'
}
},
'الگوهای خوشامدگویی اختصاصی': {
'خوشامد-با تأخیر': {
description: 'خوشامدگویی به کاربران دارای مشارکتهای قابل توجه',
syntax: '{{جا:خوشامد-با تأخیر|$USERNAME$}}'
},
'خوشامد دانشجو': {
description: 'خوشامدگویی برای دانشجویانی که بهعنوان بخشی از یک پروژهٔ کلاسی دانشگاهی ویرایش میکنند',
syntax: '$HEADER$ {{جا:خوشامد دانشجو|$USERNAME$}} ~~~~'
},
'خوشامد مدرس': {
description: 'خوشامدگویی به مدرسین دوره که در یک پروژهٔ کلاسی دانشگاهی مشارکت دارند',
syntax: '$HEADER$ {{جا:خوشامد مدرس|$USERNAME$}} ~~~~'
},
/* 'welcome non-latin': {
description: 'welcome for users with a username containing non-Latin characters',
syntax: '{{subst:welcome non-latin|$USERNAME$}} ~~~~'
} */
},
'الگوهای خوشامدگویی به کاربران مشکلدار': {
'خوشامد قوانین': {
description: 'خوشامدگویی بههمراه اطلاعاتی دربارهٔ حق تکثیر، دیدگاه بیطرف، صفحهٔ تمرین و خرابکاری',
syntax: '{{جا:خوشامد قوانین|$USERNAME$}} ~~~~'
},
'نخستین نوشتار': {
description: 'برای کاربری که نخستین نوشتار او از رهنمودهای ایجاد صفحه پیروی نمیکند',
linkedArticle: true,
syntax: '{{جا:نخستین نوشتار|$ARTICLE$|$USERNAME$}}'
},
'خوشامد آزمایشی': {
description: 'برای کاربری که نخستین ویرایشهای او بهنظر آزمایشی میرسند',
linkedArticle: true,
syntax: '{{subst:welcometest|$ARTICLE$|$USERNAME$}} ~~~~'
},
'خوشامد-غیرسازنده': {
description: 'برای کاربری که اولین ویرایشهایش بهنظر خرابکاری هستند',
linkedArticle: true,
syntax: '{{جا:خوشامد-غیرسازنده|$ARTICLE$|$USERNAME$}}'
},
'خوشامد دبط': {
description: 'برای کاربری که اولین ویرایشهای او از سیاست دیدگاه بیطرف پیروی نمیکنند',
linkedArticle: true,
syntax: '{{جا:خوشامد دبط|$ARTICLE$|$USERNAME$}} ~~~~'
},
'خوشامد به هرزهنگار': {
description: 'خوشامدگویی بههمراه توضیحات بیشتر پیرامون سیاستهای ضد هرزنگاری',
linkedArticle: true,
syntax: '{{جا:خوشامد به هرزهنگار|$ARTICLE$|$USERNAME$}} ~~~~'
},
'خوشامد-بدون منبع': {
description: 'برای کاربری که برای نخستین ویرایشهای خود منبعی ارائه نکرده است',
linkedArticle: true,
syntax: '{{جا:خوشامد-بدون منبع|$ARTICLE$|$USERNAME$}} ~~~~'
},
'خوشامد-خودزندگینامه': {
description: 'برای کاربری که یک مقالهٔ خودزندگینامه ایجاد کرده است',
linkedArticle: true,
syntax: '{{جا:خوشامد-خودزندگینامه|$USERNAME$|مقاله=$ARTICLE$}} ~~~~'
},
'خوشامد-تعارض منافع': {
description: 'برای کاربری که در موضوعاتی که ممکن است با آنها تعارض منافع داشته باشد، ویرایش کرده است',
linkedArticle: true,
syntax: '{{جا:خوشامد-تعارض منافع|$USERNAME$|مقاله=$ARTICLE$}} ~~~~'
},
'خوشامد-حذف': {
description: 'برای کاربری که در حال حذف اطلاعات از مقالهها بوده است',
linkedArticle: true,
syntax: '{{جا:خوشامد-حذف|$ARTICLE$|$USERNAME$}} ~~~~'
},
'خوشامد-تصویر': {
description: 'خوشامدگویی بههمراه اطلاعات بیشتر دربارهٔ تصاویر (سیاستها و فرایندها)',
linkedArticle: true,
syntax: '{{جا:خوشامد-تصویر|$USERNAME$|مقاله=$ARTICLE$}}'
}
}
},
anonymous: {
'الگوهای خوشامد به کاربران ناشناس': {
'خوشامد-ناشناس': {
description: 'برای کاربران ناشناس؛ تشویق به ایجاد حساب کاربری',
linkedArticle: true,
syntax: '{{جا:خوشامد-ناشناس|مقاله=$ARTICLE$}} ~~~~'
},
'ممنون': {
description: 'برای کاربران ناشناس؛ کوتاه؛ تشویق به ایجاد حساب',
linkedArticle: true,
syntax: '== خوش آمدید! ==\n{{جا:ممنون|صفحه=$ARTICLE$}} ~~~~'
},
'خوشامد-ناشناس-آزمایشی': {
description: 'برای کاربران ناشناسی که ویرایشهای آزمایشی انجام دادهاند',
linkedArticle: true,
syntax: '{{جا:خوشامد-ناشناس-آزمایشی|$ARTICLE$|$USERNAME$}} ~~~~'
},
'خوشامد-ناشناس-غیرسازنده': {
description: 'برای کاربرانی ناشناسی که خرابکاری کردهاند یا ویرایشهای غیرسازنده انجام دادهاند',
linkedArticle: true,
syntax: '{{جا:خوشامد-ناشناس-غیرسازنده|$ARTICLE$|$USERNAME$}}'
},
'خوشامد-ناشناس-سازنده': {
description: 'برای کاربران ناشناسی که با خرابکاری مبارزه میکنند یا ویرایش سازنده انجام میدهند',
linkedArticle: true,
syntax: '{{جا:خوشامد-ناشناس-سازنده|مقاله=$ARTICLE$}}'
},
'خوشامد-ناشناس-حذف': {
description: 'برای کاربران ناشناسی که محتوا را از صفحهها حذف کردهاند',
linkedArticle: true,
syntax: '{{جا:خوشامد-ناشناس-حذف|$ARTICLE$|$USERNAME$}} ~~~~'
}
}
},
/* wikiProject: {
'الگوهای خوشامد اختصاصی ویکیپروژهها': {
'welcome-anatomy': {
description: 'welcome for users with an apparent interest in anatomy topics',
syntax: '{{subst:welcome-anatomy}} ~~~~'
},
'welcome-athletics': {
description: 'welcome for users with an apparent interest in athletics (track and field) topics',
syntax: '{{subst:welcome-athletics}}'
},
'welcome-au': {
description: 'welcome for users with an apparent interest in Australia topics',
syntax: '{{subst:welcome-au}} ~~~~'
},
'welcome-bd': {
description: 'welcome for users with an apparent interest in Bangladesh topics',
linkedArticle: true,
syntax: '{{subst:welcome-bd|$USERNAME$||$EXTRA$|art=$ARTICLE$}} ~~~~'
},
'welcome-bio': {
description: 'welcome for users with an apparent interest in biographical topics',
syntax: '{{subst:welcome-bio}} ~~~~'
},
'welcome-cal': {
description: 'welcome for users with an apparent interest in California topics',
syntax: '{{subst:welcome-cal}} ~~~~'
},
'welcome-conserv': {
description: 'welcome for users with an apparent interest in conservatism topics',
syntax: '{{subst:welcome-conserv}}'
},
'welcome-cycling': {
description: 'welcome for users with an apparent interest in cycling topics',
syntax: '{{subst:welcome-cycling}} ~~~~'
},
'welcome-dbz': {
description: 'welcome for users with an apparent interest in Dragon Ball topics',
syntax: '{{subst:welcome-dbz|$EXTRA$|sig=~~~~}}'
},
'welcome-et': {
description: 'welcome for users with an apparent interest in Estonia topics',
syntax: '{{subst:welcome-et}}'
},
'welcome-de': {
description: 'welcome for users with an apparent interest in Germany topics',
syntax: '{{subst:welcome-de}} ~~~~'
},
'welcome-in': {
description: 'welcome for users with an apparent interest in India topics',
linkedArticle: true,
syntax: '{{subst:welcome-in|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-math': {
description: 'welcome for users with an apparent interest in mathematical topics',
linkedArticle: true,
syntax: '{{subst:welcome-math|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-med': {
description: 'welcome for users with an apparent interest in medicine topics',
linkedArticle: true,
syntax: '{{subst:welcome-med|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-no': {
description: 'welcome for users with an apparent interest in Norway topics',
syntax: '{{subst:welcome-no}} ~~~~'
},
'welcome-pk': {
description: 'welcome for users with an apparent interest in Pakistan topics',
linkedArticle: true,
syntax: '{{subst:welcome-pk|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-phys': {
description: 'welcome for users with an apparent interest in physics topics',
linkedArticle: true,
syntax: '{{subst:welcome-phys|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-pl': {
description: 'welcome for users with an apparent interest in Poland topics',
syntax: '{{subst:welcome-pl}} ~~~~'
},
'welcome-rugbyunion': {
description: 'welcome for users with an apparent interest in rugby union topics',
syntax: '{{subst:welcome-rugbyunion}} ~~~~'
},
'welcome-ru': {
description: 'welcome for users with an apparent interest in Russia topics',
syntax: '{{subst:welcome-ru}} ~~~~'
},
'welcome-starwars': {
description: 'welcome for users with an apparent interest in Star Wars topics',
syntax: '{{subst:welcome-starwars}} ~~~~'
},
'welcome-ch': {
description: 'welcome for users with an apparent interest in Switzerland topics',
linkedArticle: true,
syntax: '{{subst:welcome-ch|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-uk': {
description: 'welcome for users with an apparent interest in Ukraine topics',
syntax: '{{subst:welcome-uk}} ~~~~'
},
'welcome-roads': {
description: 'welcome for users with an apparent interest in roads and highways topics',
syntax: '{{subst:welcome-roads}}'
},
'welcome-videogames': {
description: 'welcome for users with an apparent interest in video game topics',
syntax: '{{subst:welcome-videogames}}'
},
'TWA invite': {
description: 'invite the user to The Wikipedia Adventure (not a welcome template)',
syntax: '{{subst:WP:TWA/InviteTW|signature=~~~~}}'
}
}
}, */
nonEnglish: {
'الگوهای خوشامدگویی غیرفارسی': {
'خوشامد-غیرفارسی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها در این فهرست موجود نیست',
syntax: '{{جا:خوشامد-غیرفارسی}}'
},
'خوشامد-غیرفارسی-عربی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً عربی است',
syntax: '{{جا:خوشامد-غیرفارسی-عربی}}'
},
'خوشامد-غیرفارسی-آلبانیایی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً آلبانیایی است',
syntax: '{{جا:خوشامد-غیرفارسی-آلبانیایی}}'
},
'خوشامد-غیرفارسی-چینی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً چینی است',
syntax: '{{جا:خوشامد-غیرفارسی-چینی}}'
},
'خوشامد-غیرفارسی-هلندی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً هلندی است',
syntax: '{{جا:خوشامد-غیرفارسی-هلندی}}'
},
'خوشامد-غیرفارسی-فنلاندی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً فنلاندی است',
syntax: '{{جا:خوشامد-غیرفارسی-فنلاندی}}'
},
'خوشامد-غیرفارسی-فرانسوی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً فرانسوی است',
syntax: '{{جا:خوشامد-غیرفارسی-فرانسوی}}'
},
'خوشامد-غیرفارسی-آلمانی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً آلمانی است',
syntax: '{{جا:خوشامد-غیرفارسی-آلمانی}}'
},
'خوشامد-غیرفارسی-عبری': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً عبری است',
syntax: '{{جا:خوشامد-غیرفارسی-عبری}}'
},
'خوشامد-غیرفارسی-ژاپنی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً ژاپنی است',
syntax: '{{جا:خوشامد-غیرفارسی-ژاپنی}}'
},
'خوشامد-غیرفارسی-کرهای': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً کرهای است',
syntax: '{{جا:خوشامد-غیرفارسی-کرهای}}'
},
'خوشامد-غیرفارسی-مالایاملامی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً مالایالامی است',
syntax: '{{جا:خوشامد-غیرفارسی-مالایالامی}}'
},
'خوشامد-غیرفارسی-مراتی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً مراتی است',
syntax: '{{جا:خوشامد-غیرفارسی-مراتی}}'
},
'خوشامد-غیرفارسی-اردو': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً اردو است',
syntax: '{{جا:خوشامد-غیرفارسی-اردو}}'
},
'خوشامد-غیرفارسی-پرتغالی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً پرتغالی است',
syntax: '{{جا:خوشامد-غیرفارسی-پرتغالی}}'
},
'خوشامد-غیرفارسی-رومانیایی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً رومانیایی است',
syntax: '{{جا:خوشامد-غیرفارسی-رومانیایی}}'
},
'خوشامد-غیرفارسی-روسی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً روسی است',
syntax: '{{جا:خوشامد-غیرفارسی-روسی}}'
},
'خوشامد-غیرفارسی-اسپانیایی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً اسپانیایی است',
syntax: '{{جا:خوشامد-غیرفارسی-اسپانیایی}}'
},
'خوشامد-غیرفارسی-سوئدی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً سوئدی است',
syntax: '{{جا:خوشامد-غیرفارسی-سوئدی}}'
},
'خوشامد-غیرفارسی-اوکراینی': {
description: 'خوشامدگویی به کاربرانی که زبان مادری آنها احتمالاً اوکراینی است',
syntax: '{{جا:خوشامد-غیرفارسی-اوکراینی}}'
}
}
}
};
Twinkle.welcome.getTemplateWikitext = function(type, template, article) {
// the iteration is required as the type=standard has two groups
var properties;
$.each(Twinkle.welcome.templates[type], function(label, templates) {
properties = templates[template];
if (properties) {
return false; // break
}
});
if (properties) {
return properties.syntax.
replace('$USERNAME$', Twinkle.getPref('insertUsername') ? mw.config.get('wgUserName') : '').
replace('$ARTICLE$', article ? article : '').
replace(/\$HEADER\$\s*/, '== خوش آمدید ==\n\n').
replace('$EXTRA$', ''); // EXTRA is not implemented yet
}
return '{{جا:' + template + (article ? '|art=' + article : '') + '}}' +
(Twinkle.getPref('customWelcomeSignature') ? ' ~~~~' : '');
};
Twinkle.welcome.callbacks = {
preview: function(form) {
var previewDialog = new Morebits.simpleWindow(750, 400);
previewDialog.setTitle('پیشنمایش الگوی خوشامدگویی');
previewDialog.setScriptName('خوشامدگویی به کاربر');
previewDialog.setModality(true);
var previewdiv = document.createElement('div');
previewdiv.style.marginRight = previewdiv.style.marginLeft = '0.5em';
previewdiv.style.fontSize = 'small';
previewDialog.setContent(previewdiv);
var previewer = new Morebits.wiki.preview(previewdiv);
var input = Morebits.quickForm.getInputData(form);
previewer.beginRender(Twinkle.welcome.getTemplateWikitext(input.type, input.template, input.article), 'بحث کاربر:' + mw.config.get('wgRelevantUserName')); // Force wikitext/correct username
var submit = document.createElement('input');
submit.setAttribute('type', 'submit');
submit.setAttribute('value', 'Close');
previewDialog.addContent(submit);
previewDialog.display();
$(submit).click(function() {
previewDialog.close();
});
},
main: function(pageobj) {
var params = pageobj.getCallbackParameters();
var text = pageobj.getPageText();
// abort if mode is auto and form is not empty
if (pageobj.exists() && params.mode === 'auto') {
Morebits.status.info('هشدار', 'صفحهٔ بحث کاربر خالی نیست؛ از خوشامدگویی خودکار صرف نظر شد');
Morebits.wiki.actionCompleted.event();
return;
}
var welcomeText = Twinkle.welcome.getTemplateWikitext(params.type, params.template, params.article);
if (Twinkle.getPref('topWelcomes')) {
var hasTalkHeader = /^\{\{(Talk ?header|(?:بالای\s)?(?:صفحه )?بحث|[ب]?صب)\}\}/i.test(text);
if (hasTalkHeader) {
text = text.replace(/^\{\{(Talk ?header|(?:بالای\s)?(?:صفحه )?بحث|[ب]?صب)\}\}\n{0,2}/i, '');
text = '{{بالای صفحه بحث}}\n\n' + welcomeText + '\n\n' + text;
text = text.trim();
} else {
text = welcomeText + '\n\n' + text;
}
} else {
text += '\n' + welcomeText;
}
var summaryText = 'به ویکیپدیا خوش آمدید!';
pageobj.setPageText(text);
pageobj.setEditSummary(summaryText);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('watchWelcomes'));
pageobj.setCreateOption('recreate');
pageobj.save();
}
};
Twinkle.welcome.callback.evaluate = function friendlywelcomeCallbackEvaluate(e) {
var form = e.target;
var params = Morebits.quickForm.getInputData(form); // : type, template, article
params.mode = 'manual';
Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.status.init(form);
var userTalkPage = mw.config.get('wgFormattedNamespaces')[3] + ':' + mw.config.get('wgRelevantUserName');
Morebits.wiki.actionCompleted.redirect = userTalkPage;
Morebits.wiki.actionCompleted.notice = 'خوشامدگویی انجام شد؛ در حال بارگیری مجدد صفحهٔ بحث تا چند ثانیه دیگر';
var wikipedia_page = new Morebits.wiki.page(userTalkPage, 'اعمال تغییرات در صفحهٔ بحث');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.welcome.callbacks.main);
};
Twinkle.addInitCallback(Twinkle.welcome, 'welcome');
})(jQuery);
// </nowiki>