mediawiki-extensions-Revisi.../modules/ext.RevisionSlider.fetchRevisions.js
addshore f9471bcfbc If the slider fails to load then fail nicely!
If something goes wrong with the initial api rquest the
slider would either load in a broken state or say that
it is loading forever.

Now a message will be displayed to the user as well
as the error logged to the console.

Change-Id: Id763f31432feb7bd0e9ecbbeb2dd40f7ca6acaaf
2016-05-12 09:46:39 +01:00

28 lines
699 B
JavaScript

( function ( mw, $ ) {
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
/**
* Fetches up to 500 revisions at a time
*
* @param {{}} options - Options containing success /error callback, pageName and startId
*/
mw.libs.revisionSlider.fetchRevisions = function ( options ) {
$.ajax( {
url: mw.util.wikiScript( 'api' ),
data: {
action: 'query',
prop: 'revisions',
format: 'json',
rvprop: 'ids|timestamp|user|comment|parsedcomment|size|flags',
titles: options.pageName,
formatversion: 2,
rvstartid: options.startId,
'continue': '',
rvlimit: 500
},
success: options.success,
error: options.error
} );
};
}( mediaWiki, jQuery ) );