پرش به محتوا

مدیاویکی:Gadget-close.js: تفاوت میان نسخه‌ها

از دانشنامه علوم انسانی
imported>Ebrahim
به روزرسانی
imported>Ebrahim
جز ویرایش Ebraminio (بحث) به آخرین تغییری که Yamaha5 انجام داده بود واگردانده شد
خط ۱: خط ۱:
$(function () {
/* by Arash.pt */
'use strict';
function answered(sectionId, type){
function answered(sectionId, type) {
$('#answerIcon'+sectionId).hide();
$('#answerIcon' + sectionId).hide();
jQuery.getJSON( mw.util.wikiScript( 'api' ), {
new mw.Api().get({
format: 'json',
format: 'json',
action: 'query',
action: 'query',
titles: mw.config.get( 'wgPageName' ),
titles: mw.config.get('wgPageName'),
prop: 'revisions',
prop: 'revisions',
rvprop: 'content',
rvprop: 'content',
rvsection:sectionId
rvsection: sectionId
} ).done( function ( data ) {
}).then(function (data) {
                var editsummary='به کمک [[مدیاویکی:Gadget-close.js|ابزار جمع‌بندی]]، '
var str = data.query.pages[Object.keys(data.query.pages)[0]].revisions[0]['*'];
var str = data.query.pages[Object.keys(data.query.pages)[0]].revisions[0]['*'];
var title = (str.match(/^(=+)[^=]*?(\1)$/m) || [''])[0];
var title = str.match('==[^]\w*[^]*==')[0];
var the_reason = prompt("توضیح در مورد بستن بحث؟");
var the_reason = prompt("توضیح در مورد بستن بحث ؟");
if (the_reason.length <= 1) { the_reason = ""; }
if(the_reason.length > 1){  }else{ the_reason = ""; }
if (type === 'request') {
if(type =='request'){
var requestStatus = confirm('آیا درخواست انجام شده است؟ یا ناموفق بود؟');
var requestStatus = confirm('آیا درخواست انجام شده است؟ یا ناموفق بود؟');
var the_reason2 = "";
var the_reason2 = "";
if (!requestStatus) {
if(!requestStatus){
the_reason2 = "|ناموفق=بله";
the_reason2 = "|ناموفق=بله";
}
the_reason = the_reason +  ' ~~' + '~~';
str = str.replace(title, title+"\n{{بسته"+the_reason2+"}}\n'''"+the_reason+"'''\n");
                        str = str+"\n{{پایان بسته}}";
                        editsummary=editsummary+'جمع‌بندی شد';
}
if(type =='talk'){
the_reason = "|"+the_reason;
str = str.replace(title, title+"\n{{بحث بسته"+the_reason+"}}");
                        str = str+"\n{{پایان بسته}}";
                        editsummary=editsummary+'جمع‌بندی شد';
}
if(type =='done1'){
                        str = str+"\n:{{شد}} "+the_reason+  ' ~~' + '~~';
                        editsummary=editsummary+'انجام شد';
}
$.ajax({
url: mw.util.wikiScript( 'api' ),
data: {
format: 'json',
action: 'edit',
title: mw.config.get( 'wgPageName' ),
section: sectionId,
summary: editsummary,
text: str,
token: mw.user.tokens.get('editToken')
},
dataType: 'json',
type: 'POST',
success: function( data ) {
  mw.notify( 'انجام شد' );
  location.reload(true);
}
}
the_reason = the_reason +  ' ~~' + '~~';
str = str.replace(title, title + "\n{{بسته" + the_reason2 + "}}\n'''" + the_reason + "'''\n");
str = str + "\n{{پایان بسته}}";
}
if (type === 'talk') {
the_reason = "|" + the_reason;
str = str.replace(title, title + "\n{{بحث بسته" + the_reason + "}}");
str = str + "\n{{پایان بسته}}";
}
if (type === 'done1') {
str = str + "\n:{{شد}} " + the_reason + ' ~~' + '~~';
}
new mw.Api().post({
format: 'json',
action: 'edit',
title: mw.config.get('wgPageName'),
section: sectionId,
summary: 'جمع‌بندی به کمک [[مدیاویکی:Gadget-close.js|ابزار جمع‌بندی بحث]]',
text: str,
token: mw.user.tokens.get('editToken')
}).then(function () {
mw.notify('انجام شد');
location.reload(true);
});
});
});
}
   
   
function addLink(sectionId, type, html, color, title) {
} );
$(this).before($('<a>', {
}
id: 'answerIcon' + sectionId,
href: '#',
title: 'جمع‌بندی بحث',
style: 'float: left; color: ' + color,
html: html
}).click(function (e) {
e.preventDefault();
answered(sectionId, type);
}));
}
   
   
if (wgNamespaceNumber === 3 && wgPageName.search(wgUserName) > 0) {
$(function(){
$('.mw-headline').each(function (data) {
if(wgNamespaceNumber == 3 && wgPageName.search(wgUserName) > 0){
addLink(data + 1, 'talk', '&#x2750;', '#090', 'جمع‌بندی بحث');
$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"talk\")' title='جمع‌بندی بحث' style='float:left;color:#090;'>&#x2750;</a>"); });
addLink(data + 1, 'done1', '&#x2713;', '#003A5C', '✓ شد');
$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"done1\")' title='✓ شد' style='float:left;color:#003A5C;'>&#x2713;</a>"); });
});
} else if (wgUserGroups.indexOf('sysop') > -1) {
}else if(wgNamespaceNumber == 4 && wgUserGroups.indexOf('sysop') > -1){
$('.mw-headline').each(function (data) {
$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"request\")' title='جمع‌بندی بحث' style='float:left;color:#090;'>&#x2750;</a>"); });
addLink(data + 1, 'request', '&#x2750;', '#090', 'جمع‌بندی بحث');
$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"done1\")' title='✓ شد' style='float:left;color:#003A5C;'>&#x2713;</a>"); });
addLink(data + 1, 'done1', '&#x2713;', '#003A5C', '✓ شد');
});
}
}
});
});

نسخهٔ ۲۱ ژانویهٔ ۲۰۱۵، ساعت ۱۷:۴۳

/* by Arash.pt */
function answered(sectionId, type){
	$('#answerIcon'+sectionId).hide();
	jQuery.getJSON( mw.util.wikiScript( 'api' ), {
		format: 'json',
		action: 'query',
		titles: mw.config.get( 'wgPageName' ),
		prop: 'revisions',
		rvprop: 'content',
		rvsection:sectionId
	} ).done( function ( data ) {
                 var editsummary='به کمک [[مدیاویکی:Gadget-close.js|ابزار جمع‌بندی]]، '
		 var str = data.query.pages[Object.keys(data.query.pages)[0]].revisions[0]['*'];
		 var title = str.match('==[^]\w*[^]*==')[0];
		 var the_reason = prompt("توضیح در مورد بستن بحث ؟");
		 if(the_reason.length > 1){  }else{	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+'جمع‌بندی شد';
		 	
		 }
		 if(type =='talk'){
		 	the_reason = "|"+the_reason;
		 	str = str.replace(title, title+"\n{{بحث بسته"+the_reason+"}}");
                        str = str+"\n{{پایان بسته}}";
                        editsummary=editsummary+'جمع‌بندی شد';
		 }
		 if(type =='done1'){
                        str = str+"\n:{{شد}} "+the_reason+  ' ~~' + '~~';
                        editsummary=editsummary+'انجام شد';
		 }
		 
		 $.ajax({
				url: mw.util.wikiScript( 'api' ),
				data: {
					format: 'json',
					action: 'edit',
					title: mw.config.get( 'wgPageName' ),
					section: sectionId,
					summary: editsummary,
					text: str,
					token: mw.user.tokens.get('editToken')
				},
				dataType: 'json',
				type: 'POST',
				success: function( data ) {
				  mw.notify( 'انجام شد' );
				  location.reload(true);
				}
			});
 
		} );
}
 
$(function(){
	if(wgNamespaceNumber == 3 && wgPageName.search(wgUserName) > 0){
		$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"talk\")' title='جمع‌بندی بحث' style='float:left;color:#090;'>&#x2750;</a>"); });
		$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"done1\")' title='✓ شد' style='float:left;color:#003A5C;'>&#x2713;</a>"); });
	
	}else if(wgNamespaceNumber == 4 && wgUserGroups.indexOf('sysop') > -1){
		$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"request\")' title='جمع‌بندی بحث' style='float:left;color:#090;'>&#x2750;</a>"); });
		$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"done1\")' title='✓ شد' style='float:left;color:#003A5C;'>&#x2713;</a>"); });
	}
});