مدیاویکی:Gadget-close.js: تفاوت میان نسخهها
ظاهر
imported>Arash.pt صفحهای تازه حاوی «←by Arash.pt: function answered(sectionId, type){ $('#answerIcon'+sectionId).hide(); jQuery.getJSON( mw.util.wikiScript( 'api' ), {...» ایجاد کرد |
imported>Arash.pt بدون خلاصۀ ویرایش |
||
| خط ۴۶: | خط ۴۶: | ||
}else if(wgUserGroups.indexOf('rollbacker') > 0){ // for test, change it to sysop | }else if(wgUserGroups.indexOf('rollbacker') > 0){ // for test, change it to sysop | ||
$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"request\")' style='float:left;color:#090;'>●</a>"); }); | $('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"request\")' style='float:left;color:#090;'>●</a>"); }); | ||
} | } | ||
}); | }); | ||
نسخهٔ ۳ ژانویهٔ ۲۰۱۵، ساعت ۲۲:۱۷
/* 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 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){ the_reason = "|"+the_reason; }else{ the_reason = ""; }
if(type =='request'){
str = str.replace(title, title+"\n{{بسته"+the_reason+"}}");
}else{
str = str.replace(title, title+"\n{{بحث بسته"+the_reason+"}}");
}
str = str+"\n{{پایان بسته}}";
$.ajax({
url: mw.util.wikiScript( 'api' ),
data: {
format: 'json',
action: 'edit',
title: mw.config.get( 'wgPageName' ),
section: sectionId,
summary: 'test test',
text: str,
token: mw.user.tokens.get('editToken')
},
dataType: 'json',
type: 'POST',
success: function( data ) {
mw.notify( 'انجام شد' );
}
});
} );
}
$(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\")' style='float:left;color:#090;'>●</a>"); });
}else if(wgUserGroups.indexOf('rollbacker') > 0){ // for test, change it to sysop
$('.mw-headline').each(function(data){ var mq = data+1; $(this).before("<a id='answerIcon"+mq+"' href='javascript:void(0)' onclick='answered("+mq+", \"request\")' style='float:left;color:#090;'>●</a>"); });
}
});