"apisandbox-results-fixtoken-fail": "Failed to fetch \"$1\" token.",
"apisandbox-alert-page": "Fields on this page are not valid.",
"apisandbox-alert-field": "The value of this field is not valid.",
+ "apisandbox-continue": "Continue",
+ "apisandbox-continue-clear": "Clear",
+ "apisandbox-continue-help": "{{int:apisandbox-continue}} will [https://www.mediawiki.org/wiki/API:Query#Continuing_queries continue] the last request; {{int:apisandbox-continue-clear}} will clear continuation-related parameters.",
"booksources": "Book sources",
"booksources-summary": "",
"booksources-search-legend": "Search for book sources",
"apisandbox-results-fixtoken-fail": "Displayed as an error message from JavaScript when a CSRF token could not be fetched.\n\nParameters:\n* $1 - Token type",
"apisandbox-alert-page": "Tooltip for the alert icon on a module's page tab when the page contains fields with issues.",
"apisandbox-alert-field": "Tooltip for the alert icon on a field when the field has issues.",
+ "apisandbox-continue": "Button text for sending another request using query continuation.",
+ "apisandbox-continue-clear": "Button text for clearing query continuation parameters.",
+ "apisandbox-continue-help": "Help text for the continue and clear buttons.",
"booksources": "{{doc-special|BookSources}}\n\n'''This message shouldn't be changed unless it has serious mistakes.'''\n\nIt's used as the page name of the configuration page of [[Special:BookSources]]. Changing it breaks existing sites using the default version of this message.\n\nSee also:\n* {{msg-mw|Booksources|title}}\n* {{msg-mw|Booksources-text|text}}",
"booksources-summary": "{{doc-specialpagesummary|booksources}}",
"booksources-search-legend": "Box heading on [[Special:BookSources|book sources]] special page. The box is for searching for places where a particular book can be bought or viewed.",
suppressErrors = true,
updatingBooklet = false,
pages = {},
- moduleInfoCache = {};
+ moduleInfoCache = {},
+ baseRequestParams;
WidgetMethods = {
textInputWidget: {
/**
* Submit button handler
+ *
+ * @param {Object} [params] Use this set of params instead of those in the form fields.
+ * The form fields will be updated to match.
*/
- sendRequest: function () {
+ sendRequest: function ( params ) {
var page, subpages, i, query, $result, $focus,
progress, $progressText, progressLoading,
deferreds = [],
- params = {},
+ paramsAreForced = !!params,
displayParams = {},
checkPages = [ pages.main ];
suppressErrors = false;
+ // save widget state in params (or load from it if we are forced)
+ if ( paramsAreForced ) {
+ ApiSandbox.updateUI( params );
+ }
+ params = {};
while ( checkPages.length ) {
page = checkPages.shift();
deferreds.push( page.apiCheckValid() );
}
}
+ if ( !paramsAreForced ) {
+ // forced params means we are continuing a query; the base query should be preserved
+ baseRequestParams = $.extend( {}, params );
+ }
+
$.when.apply( $, deferreds ).done( function () {
if ( $.inArray( false, arguments ) !== -1 ) {
windowManager.openWindow( 'errorAlert', {
);
} )
.done( function ( data, jqXHR ) {
- var m, loadTime, button,
+ var m, loadTime, button, clear,
ct = jqXHR.getResponseHeader( 'Content-Type' );
$result.empty();
.text( data )
.appendTo( $result );
}
+ if ( paramsAreForced || data[ 'continue' ] ) {
+ $result.append(
+ $( '<div>' ).append(
+ new OO.ui.ButtonWidget( {
+ label: mw.message( 'apisandbox-continue' ).text()
+ } ).on( 'click', function () {
+ ApiSandbox.sendRequest( $.extend( {}, baseRequestParams, data[ 'continue' ] ) );
+ } ).setDisabled( !data[ 'continue' ] ).$element,
+ ( clear = new OO.ui.ButtonWidget( {
+ label: mw.message( 'apisandbox-continue-clear' ).text()
+ } ).on( 'click', function () {
+ ApiSandbox.updateUI( baseRequestParams );
+ clear.setDisabled( true );
+ booklet.setPage( '|results|' );
+ } ).setDisabled( !paramsAreForced ) ).$element,
+ new OO.ui.PopupButtonWidget( {
+ framed: false,
+ icon: 'info',
+ popup: {
+ $content: $( '<div>' ).append( mw.message( 'apisandbox-continue-help' ).parse() ),
+ padded: true
+ }
+ } ).$element
+ )
+ );
+ }
if ( typeof loadTime === 'number' ) {
$result.append(
$( '<div>' ).append(