מדיה ויקי:Gadget-QuickRCDiff.js: הבדלים בין גרסאות בדף
מראה
מאין תקציר עריכה |
מ 25 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-QuickRCDiff.js יובאו |
||
| (17 גרסאות ביניים של 5 משתמשים אינן מוצגות) | |||
| שורה 1: | שורה 1: | ||
if ($.inArray(mw.config.get('wgCanonicalSpecialPageName'),['Watchlist','Recentchanges'])!=-1) (function(){ | |||
var lastRequset, $diffDialog, $diffContent, patrolBtn, thanksBtn, diffId, diffTitle; | |||
function qRcDiffHandler(content){ | |||
mw.loader.load(['jquery.spinner', 'mediawiki.diff.styles']); | |||
$('.mw-changeslist-edit', content).not('qRcDiff').addClass('qRcDiff').click(function(e) { | |||
mw.loader.load([' | if (e.target !== this || ! $(this).find('a:contains(היסטוריה)').length) { return; } | ||
$('.mw- | |||
if (e.target !== this || ! $(this). | |||
//initalizations | //initalizations | ||
if (!$diffContent) $diffContent = $('<div>'); | if (!$diffContent) $diffContent = $('<div>'); | ||
if(!$diffDialog) { | if(!$diffDialog) { | ||
var buttons = { | var buttons = { | ||
'בדיקת העתקה': | |||
function() { | |||
window.open('http://tools.wmflabs.org/copyvios/?lang=he&project=wikipedia&title='+diffTitle+'&oldid='+diffId+'&action=search&use_engine=1&use_links=1', '_blank') | |||
}, | |||
'!': | '!': | ||
function(){ | function(){ | ||
if (! | if (!diffId){ | ||
return;//nothing to do | return;//nothing to do | ||
} | } | ||
var api=new mw.Api(); | var api = new mw.Api(); | ||
api. | api.postWithToken('patrol', { | ||
action:'patrol', | action:'patrol', | ||
revid: diffId | |||
}).done(function(data){ | }).done(function(data){ | ||
if (data && data.patrol) { | if (data && data.patrol) { | ||
| שורה 34: | שורה 33: | ||
} | } | ||
}); | }); | ||
}, | |||
'♥': | |||
function(){ | |||
if (!diffId){ | |||
return;//nothing to do | |||
} | |||
var api = new mw.Api(); | |||
api.postWithToken('csrf', { | |||
action:'thank', | |||
source: 'diff', | |||
rev: diffId | |||
}).done(function(data){ | |||
mw.notify('תודה נשלחה לעורך'); | |||
}); | |||
} | } | ||
}; | }; | ||
| שורה 49: | שורה 61: | ||
top: 'auto' | top: 'auto' | ||
}); | }); | ||
patrolBtn = $(":button:contains('!')"); | patrolBtn = $(":button:contains('!')").prop('title', 'סימון כבדוק'), | ||
thanksBtn = $(":button:contains('♥')").prop('title', 'תודה'); | |||
} | } | ||
var self = this, | var self = this, | ||
diffHref = $(this).find('a[href*=oldid]') | |||
.filter(function(){ | |||
return !$(this) | |||
.hasClass('WLM-icon'); // WLM collision fix | |||
}) | |||
.prop('href'), | |||
unpatrolled = $(this).find('.unpatrolled').length; | unpatrolled = $(this).find('.unpatrolled').length; | ||
diffTitle = $(this).find('.mw-changeslist-title').text(); | |||
patrolBtn.hide(); | patrolBtn.hide(); | ||
if(self == lastRequset) { | if(self == lastRequset) { | ||
return; | return; | ||
| שורה 64: | שורה 81: | ||
action: 'query', | action: 'query', | ||
prop: 'revisions', | prop: 'revisions', | ||
}; | }; | ||
var isWikidata = false; | |||
if(diffHref){ | if(diffHref){ | ||
diffId = diffHref.match(/&diff=(\d+)&oldid=/)[1]; | |||
isWikidata = diffHref.match(/www\.wikidata\.org/); | |||
param.rvprop = 'timestamp'; | param.rvprop = 'timestamp'; | ||
param.rvdiffto = 'prev'; | param.rvdiffto = 'prev'; | ||
param.revids = diffId; | param.revids = diffId; | ||
} else { | } else { | ||
diffId = 0; | |||
param.rvprop = 'content'; | param.rvprop = 'content'; | ||
param.titles = | param.titles = diffTitle; | ||
} | } | ||
var api = isWikidata? new mw.ForeignApi( 'https://www.wikidata.org/w/api.php' ) : new mw.Api(); | |||
api.get(param).done( function(res) | |||
{ | { | ||
if (unpatrolled) patrolBtn.show(); | if (unpatrolled) patrolBtn.show(); | ||
$(self).addClass('changeslist-entry-active'); | |||
$(self). | |||
if(lastRequset){ | if(lastRequset){ | ||
$(lastRequset).addClass('changeslist-entry-visited'); | |||
$(lastRequset).removeClass('changeslist-entry-active'); | |||
} | } | ||
lastRequset = self; | lastRequset = self; | ||
| שורה 113: | שורה 132: | ||
newTable.append(diffString); | newTable.append(diffString); | ||
} | } | ||
$diffDialog.dialog('option','title', | $diffDialog.dialog('option','title',diffTitle); | ||
$diffContent.html(newTable); | $diffContent.html(newTable); | ||
$diffDialog.dialog('isOpen') || $diffDialog.dialog('open').dialog('widget').css({'height': '300px', 'top':'auto'}); | $diffDialog.dialog('isOpen') || $diffDialog.dialog('open').dialog('widget').css({'height': '300px', 'top':'auto'}); | ||
}); | }); | ||
}); | }); | ||
}); | } | ||
mw.hook( 'wikipage.content' ).add(qRcDiffHandler); | |||
})(); | |||
גרסה אחרונה מ־13:06, 5 בדצמבר 2022
if ($.inArray(mw.config.get('wgCanonicalSpecialPageName'),['Watchlist','Recentchanges'])!=-1) (function(){
var lastRequset, $diffDialog, $diffContent, patrolBtn, thanksBtn, diffId, diffTitle;
function qRcDiffHandler(content){
mw.loader.load(['jquery.spinner', 'mediawiki.diff.styles']);
$('.mw-changeslist-edit', content).not('qRcDiff').addClass('qRcDiff').click(function(e) {
if (e.target !== this || ! $(this).find('a:contains(היסטוריה)').length) { return; }
//initalizations
if (!$diffContent) $diffContent = $('<div>');
if(!$diffDialog) {
var buttons = {
'בדיקת העתקה':
function() {
window.open('http://tools.wmflabs.org/copyvios/?lang=he&project=wikipedia&title='+diffTitle+'&oldid='+diffId+'&action=search&use_engine=1&use_links=1', '_blank')
},
'!':
function(){
if (!diffId){
return;//nothing to do
}
var api = new mw.Api();
api.postWithToken('patrol', {
action:'patrol',
revid: diffId
}).done(function(data){
if (data && data.patrol) {
patrolBtn.hide();
mw.notify('העריכה סומנה כבדוקה');
}
else {
var desc = (data && data.error && data.error.info) || '';
mw.notify('שגיאה:' + desc);
}
});
},
'♥':
function(){
if (!diffId){
return;//nothing to do
}
var api = new mw.Api();
api.postWithToken('csrf', {
action:'thank',
source: 'diff',
rev: diffId
}).done(function(data){
mw.notify('תודה נשלחה לעורך');
});
}
};
$diffDialog = $('<div>').append($diffContent).dialog({
width: '100%',
height: '300',
draggable: false,
resizable: false,
buttons: buttons
});
$diffDialog.dialog('widget').css({
position:'fixed',
bottom: '0',
top: 'auto'
});
patrolBtn = $(":button:contains('!')").prop('title', 'סימון כבדוק'),
thanksBtn = $(":button:contains('♥')").prop('title', 'תודה');
}
var self = this,
diffHref = $(this).find('a[href*=oldid]')
.filter(function(){
return !$(this)
.hasClass('WLM-icon'); // WLM collision fix
})
.prop('href'),
unpatrolled = $(this).find('.unpatrolled').length;
diffTitle = $(this).find('.mw-changeslist-title').text();
patrolBtn.hide();
if(self == lastRequset) {
return;
}
$diffContent.html($.createSpinner());
var param = {
action: 'query',
prop: 'revisions',
};
var isWikidata = false;
if(diffHref){
diffId = diffHref.match(/&diff=(\d+)&oldid=/)[1];
isWikidata = diffHref.match(/www\.wikidata\.org/);
param.rvprop = 'timestamp';
param.rvdiffto = 'prev';
param.revids = diffId;
} else {
diffId = 0;
param.rvprop = 'content';
param.titles = diffTitle;
}
var api = isWikidata? new mw.ForeignApi( 'https://www.wikidata.org/w/api.php' ) : new mw.Api();
api.get(param).done( function(res)
{
if (unpatrolled) patrolBtn.show();
$(self).addClass('changeslist-entry-active');
if(lastRequset){
$(lastRequset).addClass('changeslist-entry-visited');
$(lastRequset).removeClass('changeslist-entry-active');
}
lastRequset = self;
if(res === null)
{
$diffContent.html('Error');
return false;
}
var revision = res.query.pages[Object.keys(res.query.pages)[0]].revisions[0];
var diffString = diffHref ? revision.diff["*"] : revision['*'];
if(diffString === null)
{
$diffContent.html('Error');
return false;
}
var trTemp = $('<tr><td class="diff-marker"> </td><td class="diff-context"></td></tr>');
var newTable = $('<table class="diff"></table>')
.html('<colgroup><col class="diff-marker"><col class="diff-content"><col class="diff-marker"><col class="diff-content"></colgroup>');
if(! diffHref){
newTable.append($('<tr><td colspan="4" class="diff-lineno">דף חדש</td></tr>'));
var rows = diffString.split('\n');
for(var tr in rows){
var curTr = trTemp.clone();
curTr.find('.diff-context').first().text(rows[tr]);
newTable.append(curTr);
}
} else {
newTable.append(diffString);
}
$diffDialog.dialog('option','title',diffTitle);
$diffContent.html(newTable);
$diffDialog.dialog('isOpen') || $diffDialog.dialog('open').dialog('widget').css({'height': '300px', 'top':'auto'});
});
});
}
mw.hook( 'wikipage.content' ).add(qRcDiffHandler);
})();