מדיה ויקי:Gadget-QuickRCDiff.js: הבדלים בין גרסאות בדף
הוספת האפשרות לצפיה בתוכנו של דף חדש ישירות מדף השינויים האחרונים |
מ 25 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-QuickRCDiff.js יובאו |
||
| (22 גרסאות ביניים של 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){ | |||
if (data && data.patrol) { | if (data && data.patrol) { | ||
patrolBtn.hide(); | patrolBtn.hide(); | ||
| שורה 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('תודה נשלחה לעורך'); | |||
}); | |||
} | } | ||
}; | }; | ||
| שורה 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, | ||
diffHref = $(this).find('a[href*=oldid]') | |||
.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(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; | ||
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', | $diffDialog.dialog('option','title',diffTitle); | ||
$diffContent.html(newTable); | $diffContent.html(newTable); | ||
$diffDialog.dialog('isOpen') || $diffDialog.dialog('widget'). | $diffDialog.dialog('isOpen') || $diffDialog.dialog('open').dialog('widget').css({'height': '300px', 'top':'auto'}); | ||
}); | }); | ||
}); | }); | ||
}); | } | ||
mw.hook( 'wikipage.content' ).add(qRcDiffHandler); | |||
})(); | |||