مدیاویکی:Gadget-close.js
ظاهر
نکته: پس از انتشار ممکن است برای دیدن تغییرات نیاز باشد که حافظهٔ نهانی مرورگر خود را پاک کنید.
- فایرفاکس / سافاری: کلید Shift را نگه دارید و روی دکمهٔ Reload کلیک کنید، یا کلیدهای Ctrl-F5 یا Ctrl-R را با هم فشار دهید (در رایانههای اپل مکینتاش کلیدهای ⌘-R)
- گوگل کروم: کلیدهای Ctrl+Shift+R را با هم فشار دهید (در رایانههای اپل مکینتاش کلیدهای ⌘-Shift-R)
- Edge: کلید Ctrl را نگهدارید و روی دکمهٔ Refresh کلیک کنید، یا کلیدهای Ctrl-F5 را با هم فشار دهید
/* by Arash.pt & Ebraminio & Yamaha5 */
/*global $, mw, prompt, confirm*/
/*jslint regexp: true, vars: true, indent: 2, white: true*/
$(function () {
'use strict';
function answered(sectionId, type, action) {
new mw.Api().get({
format: 'json',
action: 'query',
titles: mw.config.get('wgPageName'),
prop: 'revisions',
rvprop: 'content',
rvsection: sectionId
}).then(function (data) {
var editsummary = ' (به کمک [[مدیاویکی:Gadget-close.js|ابزار جمعبندی]])';
var str = data.query.pages[Object.keys(data.query.pages)[0]].revisions[0]['*'];
var title = (str.match(/^(=+)[^=]*?(\1)$/m) || [''])[0];
var title_text = title.replace(/\=/g, '');
var the_reason = prompt("توضیح برای " + action + ":");
if (the_reason.length <= 1) { the_reason = ""; }
if (type === 'request') {
var requestStatus = confirm('آیا درخواست انجام شدهاست؟ یا ناموفق بود؟');
var the_reason2 = "";
if (!requestStatus) {
the_reason2 = "|ناموفق=بله";
}
the_reason = the_reason + ' ~~' + '~~';
str = str.replace(title, title + "\n{{بسته" + the_reason2 + "}}\n'''" + the_reason + "'''\n");
str = str + "\n{{پایان بسته}}";
editsummary = 'جمعبندی شد!' + editsummary;
} else if (type === 'talk') {
the_reason = "|" + the_reason;
str = str.replace(title, title + "\n{{بحث بسته" + the_reason + "}}");
str = str + "\n{{پایان بسته}}";
editsummary = 'جمعبندی شد!' + editsummary;
} else if (type === 'done') {
str = str + "\n:{{شد}} " + the_reason + ' ~~' + '~~';
editsummary = 'انجام شد!' + editsummary;
} else if (type === 'support') {
str = str + "\n:{{موافق}} " + the_reason + ' ~~' + '~~';
editsummary = 'موافقم' + editsummary;
} else if (type === 'oppose') {
str = str + "\n:{{مخالف}} " + the_reason + ' ~~' + '~~';
editsummary = 'مخالفم' + editsummary;
}
editsummary = '/*' + title_text + '*/' + editsummary;
return new mw.Api().post({
format: 'json',
action: 'edit',
title: mw.config.get('wgPageName'),
section: sectionId,
summary: editsummary,
text: str,
token: mw.user.tokens.get('editToken')
});
}).then(function () {
mw.notify('انجام شد');
location.reload(true);
}, function (error) {
mw.notify('به دلیلی موفقیتآمیز نبود: ' + error);
location.reload(true);
});
}
function addLink(section, sectionIndex, type, html, color, title) {
var sectionId = sectionIndex + 1;
$('<a>', {
id: 'answerIcon' + sectionId,
href: '#',
title: title,
style: 'float: left; color: ' + color,
html: html
}).click(function (e) {
e.preventDefault();
answered(sectionId, type, title);
}).insertBefore(section);
}
if (mw.config.get('wgNamespaceNumber') === 3 && mw.config.get('wgPageName').search(mw.config.get('wgUserName')) > 0) {
$('.mw-headline').each(function (i) {
addLink(this, i, 'talk', '❐', '#090', 'جمعبندی بحث');
addLink(this, i, 'done', '✓', '#003A5C', '✓ شد');
});
} else if (mw.config.get('wgNamespaceNumber') === 4) {
if ($('#catlinks a[href="/wiki/%D8%B1%D8%AF%D9%87:%D8%B1%D9%87%D9%86%D9%85%D9%88%D8%AF%D9%87%D8%A7%DB%8C_%D9%88%DB%8C%DA%A9%DB%8C%E2%80%8C%D9%BE%D8%AF%DB%8C%D8%A7"]').length===0 && //رده:رهنمودهای ویکیپدیا
$('#catlinks a[href="/wiki/%D8%B1%D8%AF%D9%87:%D8%B3%DB%8C%D8%A7%D8%B3%D8%AA%E2%80%8C%D9%87%D8%A7%DB%8C_%D9%88%DB%8C%DA%A9%DB%8C%E2%80%8C%D9%BE%D8%AF%DB%8C%D8%A7"]').length===0 && //رده:سیاستهای ویکیپدیا
$('#catlinks a[href="/wiki/%D8%B1%D8%AF%D9%87:%D8%B1%D8%A7%D9%87%D9%86%D9%85%D8%A7%DB%8C_%D9%88%DB%8C%DA%A9%DB%8C%E2%80%8C%D9%BE%D8%AF%DB%8C%D8%A7"]').length===0 && //رده:راهنمای ویکیپدیا
$('#catlinks a[href="/wiki/%D8%B1%D8%AF%D9%87:%D8%AE%D9%88%D8%AF%D8%A2%D9%85%D9%88%D8%B2_%D9%88%DB%8C%DA%A9%DB%8C%E2%80%8C%D9%BE%D8%AF%DB%8C%D8%A7"]').length===0 && //رده:خودآموز ویکیپدیا
$('#catlinks a[href="/wiki/%D8%B1%D8%AF%D9%87:%D8%A7%D9%86%D8%B4%D8%A7%D9%87%D8%A7%DB%8C_%D9%88%DB%8C%DA%A9%DB%8C%E2%80%8C%D9%BE%D8%AF%DB%8C%D8%A7"]').length===0 //رده:انشاهای ویکیپدیا
){
$('.mw-headline').each(function (i) {
if (mw.config.get('wgUserGroups').indexOf('sysop') > -1) {
addLink(this, i, 'request', '❐', '#090', 'جمعبندی بحث');
addLink(this, i, 'done', '✓', '#003A5C', '✓ شد');
}
addLink(this, i, 'support', '☺', '#090', 'موافقم');
addLink(this, i, 'oppose', '☹', '#DF0101', 'مخالفم');
});
}
} else if (mw.config.get('wgNamespaceNumber') % 2 !== 0) { // برای صفحات بحث
$('.mw-headline').each(function (i) {
addLink(this, i, 'done', '✓', '#003A5C', '✓ شد');
});
}
});