מדיה ויקי:Gadget-rcPatrol.js: הבדלים בין גרסאות בדף
מראה
מ גרסה חדשה של משתמש:קיפודנחש שעובדת גם בשינויים אחרונים משופר |
מאין תקציר עריכה |
||
| שורה 22: | שורה 22: | ||
if (matches) { | if (matches) { | ||
var rcid = matches[1]; | var rcid = matches[1]; | ||
abbr.before($('<input>', {'type': 'checkbox'}).change(function() {patrol(rcid); $(this).remove(); abbr.remove( | abbr.before($('<input>', {'type': 'checkbox'}).change(function() {patrol(rcid); $(this).remove();})); | ||
abbr.remove(); | |||
} | } | ||
} | } | ||
גרסה מ־13:51, 7 באוקטובר 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(td.siblings(), abbr);
});
// collect lis in "normal" rc list
var lis = $('li.mw-line-odd').get().concat($('li.mw-line-even').get());
$.each(lis, function(index, hli) {
var li = $(hli);
var abbr = li.find('abbr.unpatrolled');
addCheckbox(li, abbr);
});
}); // getJSON
}); // document.ready