מדיה ויקי:Gadget-rcPatrol.js: הבדלים בין גרסאות בדף
מראה
מאין תקציר עריכה |
|||
| שורה 34: | שורה 34: | ||
if (sib.find('.mw-collapsible-toggle').length) | if (sib.find('.mw-collapsible-toggle').length) | ||
return; | return; | ||
addCheckbox( | addCheckbox(sib, abbr); | ||
}); | }); | ||
// collect lis in "normal" rc list | // collect lis in "normal" rc list | ||
var lis = $('li.mw-line-odd | var lis = $('li.mw-line-odd, li.mw-line-even').each(function() { | ||
addCheckbox($(this), $(this).find('abbr.unpatrolled')); | |||
}); | }); | ||
}); // getJSON | }); // getJSON | ||
}); // document.ready | }); // document.ready | ||
גרסה מ־21:09, 13 בדצמבר 2011
/* Allows to mark pages as patrolled from the Recentchanges or Watchlist page.
*
* Written by [[User:Yonidebest]]
*/
if ($.inArray(wgCanonicalSpecialPageName, ["Recentchanges", "Watchlist", "Recentchangeslinked"]) + 1)
$(document).ready(function() {
var params = {action: 'query', list: 'recentchanges', rctoken: 'patrol', rclimit: 1, format: 'json'};
$.getJSON(mw.util.wikiScript('api'), params, function(data) {
var token = data.query.recentchanges[0].patroltoken;
function patrol(rcid) {
$.post(mw.util.wikiScript('api'), {action:'patrol', rcid:rcid, token: token});
}
function addCheckbox(elem, abbr) {
var a = elem.find('a[href*="rcid="]');
if (!a.length)
return;
var matches = a.attr('href').match(/rcid=(\d+)/);
if (matches) {
var rcid = matches[1];
abbr.before($('<input>', {'type': 'checkbox'}).change(function() {patrol(rcid); $(this).remove();}));
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);
});
// collect lis in "normal" rc list
var lis = $('li.mw-line-odd, li.mw-line-even').each(function() {
addCheckbox($(this), $(this).find('abbr.unpatrolled'));
});
}); // getJSON
}); // document.ready