מדיה ויקי:Gadget-QuickRCDiff.js: הבדלים בין גרסאות בדף

הוספת האפשרות לצפיה בתוכנו של דף חדש ישירות מדף השינויים האחרונים
מ 25 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-QuickRCDiff.js יובאו
 
(22 גרסאות ביניים של 5 משתמשים אינן מוצגות)
שורה 1: שורה 1:
/*
if ($.inArray(mw.config.get('wgCanonicalSpecialPageName'),['Watchlist','Recentchanges'])!=-1) (function(){
check recentchanges/watchlist diffs directly without navigation to other pages.
var lastRequset, $diffDialog, $diffContent, patrolBtn, thanksBtn, diffId, diffTitle;
Written by: [[User:ערן]]
 
*/
function qRcDiffHandler(content){
$(function(){
mw.loader.load(['jquery.spinner', 'mediawiki.diff.styles']);
if($.inArray(mw.config.get('wgCanonicalSpecialPageName'),['Watchlist','Recentchanges'])==-1) return;
$('.mw-changeslist-edit', content).not('qRcDiff').addClass('qRcDiff').click(function(e) {
mw.loader.load(['mediawiki.action.history.diff','jquery.spinner']);
if (e.target !== this || ! $(this).find('a:contains(היסטוריה)').length) { return; }
var lastRequset, $diffDialog, $diffContent, rcid, patrolBtn;
$('.mw-line-even,.mw-line-odd').click(function(e) {
if (e.target !== this || ! $(this).children('a:contains(היסטוריה)').length) { return; }
//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 (!rcid){
if (!diffId){
return;//nothing to do
return;//nothing to do
}
}
var api=new mw.Api();
var api = new mw.Api();
api.post({
api.postWithToken('patrol', {
action:'patrol',
action:'patrol',
rcid: rcid,
revid: diffId
token: mw.user.tokens.get('patrolToken')
}).done(function(data){
}, function(data){
if (data && data.patrol) {
if (data && data.patrol) {
patrolBtn.hide();
patrolBtn.hide();
שורה 34: שורה 33:
}
}
});
});
rcid=0;//dont repost
},
'♥':
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('תודה נשלחה לעורך');
});
}
}
};
};
שורה 47: שורה 59:
position:'fixed',
position:'fixed',
bottom: '0',
bottom: '0',
top: ''
top: 'auto'
});
});
patrolBtn = $(":button:contains('!')");
patrolBtn = $(":button:contains('!')").prop('title', 'סימון כבדוק'),
thanksBtn =  $(":button:contains('♥')").prop('title', 'תודה');
}
}
var self = this,
var self = this,
    title = $(this).find('.mw-changeslist-title').text(),
    diffHref = $(this).find('a[href*=oldid]')
    diffHref = $(this).find('a[tabindex]').prop('href'),
    .filter(function(){
    unpatrolled = $(this).find('.unpatrolled').length
    return !$(this)
.hasClass('WLM-icon'); // WLM collision fix
    })
    .prop('href'),
    unpatrolled = $(this).find('.unpatrolled').length;
diffTitle = $(this).find('.mw-changeslist-title').text();
patrolBtn.hide();
patrolBtn.hide();
if(diffHref) var diffId = diffHref.match(/&diff=(\d+)&oldid=/)[1];
if(self == lastRequset) {
if(self == lastRequset) {
return;
return;
שורה 64: שורה 81:
action: 'query',
action: 'query',
prop: 'revisions',
prop: 'revisions',
format: 'json'
};
}
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 = title;
param.titles = diffTitle;
}
}
$.getJSON('/w/api.php', param, function(res)
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();
rcid = unpatrolled && /rcid=([0-9]+)/.exec(diffHref);
 
if (rcid) {
$(self).addClass('changeslist-entry-active');
rcid = rcid[1];
}
$(self).css('background','#fc6');
if(lastRequset){
if(lastRequset){
$(lastRequset).css('background','#eee');
$(lastRequset).addClass('changeslist-entry-visited');
$(lastRequset).removeClass('changeslist-entry-active');
}
}
lastRequset = self;
lastRequset = self;
if(res == null)
if(res === null)
{
{
$diffContent.html('Error');
$diffContent.html('Error');
שורה 94: שורה 113:
var revision = res.query.pages[Object.keys(res.query.pages)[0]].revisions[0];
var revision = res.query.pages[Object.keys(res.query.pages)[0]].revisions[0];
var diffString = diffHref ? revision.diff["*"] : revision['*'];
var diffString = diffHref ? revision.diff["*"] : revision['*'];
if(diffString == null)
if(diffString === null)
{
{
$diffContent.html('Error');
$diffContent.html('Error');
שורה 113: שורה 132:
newTable.append(diffString);
newTable.append(diffString);
}
}
$diffDialog.dialog('option','title',title);
$diffDialog.dialog('option','title',diffTitle);
$diffContent.html(newTable);
$diffContent.html(newTable);
$diffDialog.dialog('isOpen') || $diffDialog.dialog('widget').show();
$diffDialog.dialog('isOpen') || $diffDialog.dialog('open').dialog('widget').css({'height': '300px', 'top':'auto'});
});
});
});
});
});
}
 
mw.hook( 'wikipage.content' ).add(qRcDiffHandler);
})();