Merge branch 'next-submission-link'

This commit is contained in:
theopolisme 2014-11-05 21:13:17 -06:00
parent 0e139d9a73
commit d31c75652d

View File

@ -460,6 +460,37 @@
return deferred; return deferred;
}; };
/**
* Gets the next submission in the queue (i.e. the oldest one).
* @param {bool} older Whether to get the oldest pending submission instead of the newest one.
* @return {$.Deferred} resolves with API call
*/
AFCH.Submission.prototype.getNextSubmission = function ( older ) {
var deferred = $.Deferred(),
request = {
action: 'query',
list: 'categorymembers',
cmtitle: 'Category:Pending AfC submissions',
cmnamespace: 5,
cmtype: 'page',
cmlimit: 1,
cmsort: 'sortkey',
cmdir: older ? 'desc' : 'asc',
cmstartsortkey: 'P' + ( ( afchSubmission.templates.length && afchSubmission.templates[0].timestamp ) / 100 ) + ( older ? 0 : 1 )
};
AFCH.api.get( request )
.done( function ( data ) {
if ( data.query.categorymembers && data.query.categorymembers[0].title ) {
deferred.resolve( data.query.categorymembers[0].title );
} else {
deferred.reject( data );
}
} );
return deferred;
};
/** /**
* Represents text of an AfC submission * Represents text of an AfC submission
* @param {[type]} text [description] * @param {[type]} text [description]
@ -1162,7 +1193,8 @@
/** /**
* Sets up the `ajaxStop` handler which runs after all ajax * Sets up the `ajaxStop` handler which runs after all ajax
* requests are complete and changes the text of the button * requests are complete and changes the text of the button
* to "Done" and auto-reloads the page. * to "Done", shows a link to the next submission and
* auto-reloads the page.
*/ */
function setupAjaxStopHandler () { function setupAjaxStopHandler () {
$( document ).ajaxStop( function () { $( document ).ajaxStop( function () {
@ -1177,6 +1209,10 @@
.text( '(reloading...)' ) .text( '(reloading...)' )
); );
afchSubmission.getNextSubmission().done( function ( title ) {
new AFCH.status.Element( 'Continue to next submission, $1 »', { '$1': AFCH.makeLinkElementToPage( title ) } );
} );
// Also, automagically reload the page in place // Also, automagically reload the page in place
$( '#mw-content-text' ).load( AFCH.consts.pagelink + ' #mw-content-text', function () { $( '#mw-content-text' ).load( AFCH.consts.pagelink + ' #mw-content-text', function () {
$afch.find( '#reloadLink' ).text( '(reloaded automatically)' ); $afch.find( '#reloadLink' ).text( '(reloaded automatically)' );