מדיה ויקי:Gadget-rcPatrol.js: הבדלים בין גרסאות בדף
מראה
סידור היישור. נבדק ב-IE8 |
מ 65 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-rcPatrol.js יובאו |
||
| (30 גרסאות ביניים של 6 משתמשים אינן מוצגות) | |||
| שורה 1: | שורה 1: | ||
/* Allows to mark pages as patrolled from the Recentchanges or Watchlist page. | |||
* | |||
* Written by [[User:Yonidebest]] | |||
*/ | |||
if ($.inArray(mw.config.get('wgCanonicalSpecialPageName'), ["Recentchanges", "Watchlist", "Recentchangeslinked", "Newpages"]) + 1) { | |||
mw.loader.load('mediawiki.api'); | |||
mw.hook( 'wikipage.content' ).add(function() { | |||
function patrol(revid, checkbox) { | |||
var api = new mw.Api(); | |||
api.postWithToken('patrol', {action: 'patrol', revid: revid }).done( function(data, textStatus, jqXHR) { | |||
if (data && data.patrol) { | |||
mw.notify('העריכה בדף ' + data.patrol.title + ' סומנה כבדוקה'); | |||
$(checkbox).remove(); | |||
} | |||
else { | |||
var desc = (data && data.error && data.error.info) || ''; | |||
mw.notify(desc, {title: "אירעה שגיאה", type: "error"}); | |||
} | |||
}) | |||
.fail( function(jqXHR, textStatus, errorThrown) { | |||
mw.notify(jqXHR + '<br/>' + textStatus + '<br/>' + errorThrown); | |||
}); | |||
} | |||
} | function addCheckbox(elem, abbr) { | ||
var a = elem.find('a:Contains(קודמת), a:Contains(הבדל)').filter(function() { return /diff=\d+/.test($(this).attr('href')); } ); | |||
function | if (!a.length) | ||
{ | return; | ||
var m = a.attr('href').match(/diff=(\d+)/); | |||
if ( ! m ) | |||
return; | |||
var revid = m[1]; | |||
abbr.before($('<input>', {'type': 'checkbox'}).change(function() {patrol(revid, this);})); | |||
abbr.remove(); | |||
} | |||
// collect tds in "enhanced" rc list | |||
$('td.mw-enhanced-rc').each(function() { | |||
var td = $(this); | |||
var abbr = td.find('abbr.unpatrolled'); | |||
var sib = td.siblings(); | |||
if (sib.find('.mw-collapsible-toggle').length) | |||
return; | |||
addCheckbox(sib, abbr); | |||
}); | |||
$('li.mw-line-odd, li.mw-line-even').each(function() { | |||
addCheckbox($(this), $(this).find('abbr.unpatrolled')); | |||
}); | |||
$('li.not-patrolled').each(function(){ | |||
var a = $(this).find('a[href*="oldid"]') | |||
if (!a.length) | |||
return; | |||
var m = a.attr('href').match(/oldid=(\d+)/); | |||
if ( ! m ) | |||
return; | |||
var revid = m[1]; | |||
function | a.before($('<input>', {'type': 'checkbox'}).change(function() {patrol(revid, this);})); | ||
}); | |||
}); // document.ready | |||
} // in recentchanges page. | |||
} | |||
גרסה אחרונה מ־13:04, 5 בדצמבר 2022
/* Allows to mark pages as patrolled from the Recentchanges or Watchlist page.
*
* Written by [[User:Yonidebest]]
*/
if ($.inArray(mw.config.get('wgCanonicalSpecialPageName'), ["Recentchanges", "Watchlist", "Recentchangeslinked", "Newpages"]) + 1) {
mw.loader.load('mediawiki.api');
mw.hook( 'wikipage.content' ).add(function() {
function patrol(revid, checkbox) {
var api = new mw.Api();
api.postWithToken('patrol', {action: 'patrol', revid: revid }).done( function(data, textStatus, jqXHR) {
if (data && data.patrol) {
mw.notify('העריכה בדף ' + data.patrol.title + ' סומנה כבדוקה');
$(checkbox).remove();
}
else {
var desc = (data && data.error && data.error.info) || '';
mw.notify(desc, {title: "אירעה שגיאה", type: "error"});
}
})
.fail( function(jqXHR, textStatus, errorThrown) {
mw.notify(jqXHR + '<br/>' + textStatus + '<br/>' + errorThrown);
});
}
function addCheckbox(elem, abbr) {
var a = elem.find('a:Contains(קודמת), a:Contains(הבדל)').filter(function() { return /diff=\d+/.test($(this).attr('href')); } );
if (!a.length)
return;
var m = a.attr('href').match(/diff=(\d+)/);
if ( ! m )
return;
var revid = m[1];
abbr.before($('<input>', {'type': 'checkbox'}).change(function() {patrol(revid, this);}));
abbr.remove();
}
// collect tds in "enhanced" rc list
$('td.mw-enhanced-rc').each(function() {
var td = $(this);
var abbr = td.find('abbr.unpatrolled');
var sib = td.siblings();
if (sib.find('.mw-collapsible-toggle').length)
return;
addCheckbox(sib, abbr);
});
$('li.mw-line-odd, li.mw-line-even').each(function() {
addCheckbox($(this), $(this).find('abbr.unpatrolled'));
});
$('li.not-patrolled').each(function(){
var a = $(this).find('a[href*="oldid"]')
if (!a.length)
return;
var m = a.attr('href').match(/oldid=(\d+)/);
if ( ! m )
return;
var revid = m[1];
a.before($('<input>', {'type': 'checkbox'}).change(function() {patrol(revid, this);}));
});
}); // document.ready
} // in recentchanges page.