17,230
edits
(get params from location.href) |
(add patrol calls) |
||
Line 9: | Line 9: | ||
$patrolAllLink.click(function(e) { | $patrolAllLink.click(function(e) { | ||
var $this = $(this); | var $this = $(this); | ||
var $spinner; | |||
// replace text with spinner | // replace text with spinner | ||
mw.loader.using('jquery.spinner').then(function() { | mw.loader.using('jquery.spinner').then(function() { | ||
$spinner = $.createSpinner({ size :'small', type: 'inline' }); | |||
$this.hide().after($spinner); | $this.hide().after($spinner); | ||
}); | }); | ||
Line 30: | Line 31: | ||
rvlimit: 'max', | rvlimit: 'max', | ||
pageids: pageid | pageids: pageid | ||
} ).done( function ( data ) { | }).done(function (data) { | ||
console.log( data ); | console.log(data); | ||
var revisions = data.query.pages[pageid].revisions; | |||
var promises = []; | |||
for (int i = 0; i < revisions.length; i++) { | |||
promises.push(api.postWithToken('patrol', { | |||
formatversion: 2, // no clue what this is or if it's needed | |||
action: 'patrol', | |||
revid: revisions[i].revid | |||
})); | |||
} | } | ||
$.when.apply($, promises).then( | |||
function(result) { | |||
$spinner.remove(); | |||
$this.after($('<span style="color:green">Marked as patrolled</span>')); | |||
}, function(error) { | |||
$spinner.remove(); | |||
$this.after($('<span style="color:red">Cannot mark as patrolled</span>')) | |||
}); | |||
}); | |||
e.preventDefault(); | |||
} ); | |||
}); | }); | ||
} | } | ||
} | } |