diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-12-27 15:41:37 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-12-31 11:43:28 +0100 |
commit | c1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch) | |
tree | 2b38796e738dd74cb42ecd9bfd151803108386bc /resources/src/mediawiki.api | |
parent | b88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff) |
Update to MediaWiki 1.24.1
Diffstat (limited to 'resources/src/mediawiki.api')
-rw-r--r-- | resources/src/mediawiki.api/mediawiki.api.category.js | 146 | ||||
-rw-r--r-- | resources/src/mediawiki.api/mediawiki.api.edit.js | 87 | ||||
-rw-r--r-- | resources/src/mediawiki.api/mediawiki.api.js | 397 | ||||
-rw-r--r-- | resources/src/mediawiki.api/mediawiki.api.login.js | 54 | ||||
-rw-r--r-- | resources/src/mediawiki.api/mediawiki.api.parse.js | 45 | ||||
-rw-r--r-- | resources/src/mediawiki.api/mediawiki.api.watch.js | 79 |
6 files changed, 808 insertions, 0 deletions
diff --git a/resources/src/mediawiki.api/mediawiki.api.category.js b/resources/src/mediawiki.api/mediawiki.api.category.js new file mode 100644 index 00000000..7dd9730f --- /dev/null +++ b/resources/src/mediawiki.api/mediawiki.api.category.js @@ -0,0 +1,146 @@ +/** + * @class mw.Api.plugin.category + */ +( function ( mw, $ ) { + + var msg = 'Use of mediawiki.api callback params is deprecated. Use the Promise instead.'; + $.extend( mw.Api.prototype, { + /** + * Determine if a category exists. + * + * @param {mw.Title|string} title + * @param {Function} [ok] Success callback (deprecated) + * @param {Function} [err] Error callback (deprecated) + * @return {jQuery.Promise} + * @return {Function} return.done + * @return {boolean} return.done.isCategory Whether the category exists. + */ + isCategory: function ( title, ok, err ) { + var apiPromise = this.get( { + prop: 'categoryinfo', + titles: String( title ) + } ); + + if ( ok || err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); + } + + return apiPromise + .then( function ( data ) { + var exists = false; + if ( data.query && data.query.pages ) { + $.each( data.query.pages, function ( id, page ) { + if ( page.categoryinfo ) { + exists = true; + } + } ); + } + return exists; + } ) + .done( ok ) + .fail( err ) + .promise( { abort: apiPromise.abort } ); + }, + + /** + * Get a list of categories that match a certain prefix. + * + * E.g. given "Foo", return "Food", "Foolish people", "Foosball tables"... + * + * @param {string} prefix Prefix to match. + * @param {Function} [ok] Success callback (deprecated) + * @param {Function} [err] Error callback (deprecated) + * @return {jQuery.Promise} + * @return {Function} return.done + * @return {string[]} return.done.categories Matched categories + */ + getCategoriesByPrefix: function ( prefix, ok, err ) { + // Fetch with allpages to only get categories that have a corresponding description page. + var apiPromise = this.get( { + list: 'allpages', + apprefix: prefix, + apnamespace: mw.config.get( 'wgNamespaceIds' ).category + } ); + + if ( ok || err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); + } + + return apiPromise + .then( function ( data ) { + var texts = []; + if ( data.query && data.query.allpages ) { + $.each( data.query.allpages, function ( i, category ) { + texts.push( new mw.Title( category.title ).getMainText() ); + } ); + } + return texts; + } ) + .done( ok ) + .fail( err ) + .promise( { abort: apiPromise.abort } ); + }, + + /** + * Get the categories that a particular page on the wiki belongs to. + * + * @param {mw.Title|string} title + * @param {Function} [ok] Success callback (deprecated) + * @param {Function} [err] Error callback (deprecated) + * @param {boolean} [async=true] Asynchronousness (deprecated) + * @return {jQuery.Promise} + * @return {Function} return.done + * @return {boolean|mw.Title[]} return.done.categories List of category titles or false + * if title was not found. + */ + getCategories: function ( title, ok, err, async ) { + var apiPromise = this.get( { + prop: 'categories', + titles: String( title ) + }, { + async: async === undefined ? true : async + } ); + + if ( ok || err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); + } + if ( async !== undefined ) { + mw.track( 'mw.deprecate', 'api.async' ); + mw.log.warn( + 'Use of mediawiki.api async=false param is deprecated. ' + + 'The sychronous mode will be removed in the future.' + ); + } + + return apiPromise + .then( function ( data ) { + var titles = false; + if ( data.query && data.query.pages ) { + $.each( data.query.pages, function ( id, page ) { + if ( page.categories ) { + if ( titles === false ) { + titles = []; + } + $.each( page.categories, function ( i, cat ) { + titles.push( new mw.Title( cat.title ) ); + } ); + } + } ); + } + return titles; + } ) + .done( ok ) + .fail( err ) + .promise( { abort: apiPromise.abort } ); + } + } ); + + /** + * @class mw.Api + * @mixins mw.Api.plugin.category + */ + +}( mediaWiki, jQuery ) ); diff --git a/resources/src/mediawiki.api/mediawiki.api.edit.js b/resources/src/mediawiki.api/mediawiki.api.edit.js new file mode 100644 index 00000000..e88ae5e2 --- /dev/null +++ b/resources/src/mediawiki.api/mediawiki.api.edit.js @@ -0,0 +1,87 @@ +/** + * @class mw.Api.plugin.edit + */ +( function ( mw, $ ) { + + var msg = 'Use of mediawiki.api callback params is deprecated. Use the Promise instead.'; + $.extend( mw.Api.prototype, { + + /** + * Post to API with edit token. If we have no token, get one and try to post. + * If we have a cached token try using that, and if it fails, blank out the + * cached token and start over. + * + * @param {Object} params API parameters + * @param {Function} [ok] Success callback (deprecated) + * @param {Function} [err] Error callback (deprecated) + * @return {jQuery.Promise} See #post + */ + postWithEditToken: function ( params, ok, err ) { + if ( ok || err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); + } + + return this.postWithToken( 'edit', params ).done( ok ).fail( err ); + }, + + /** + * API helper to grab an edit token. + * + * @param {Function} [ok] Success callback (deprecated) + * @param {Function} [err] Error callback (deprecated) + * @return {jQuery.Promise} + * @return {Function} return.done + * @return {string} return.done.token Received token. + */ + getEditToken: function ( ok, err ) { + if ( ok || err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); + } + + return this.getToken( 'edit' ).done( ok ).fail( err ); + }, + + /** + * Post a new section to the page. + * @see #postWithEditToken + * @param {mw.Title|String} title Target page + * @param {string} header + * @param {string} message wikitext message + * @param {Object} [additionalParams] Additional API parameters, e.g. `{ redirect: true }` + * @param {Function} [ok] Success handler (deprecated) + * @param {Function} [err] Error handler (deprecated) + * @return {jQuery.Promise} + */ + newSection: function ( title, header, message, additionalParams, ok, err ) { + // Until we remove 'ok' and 'err' parameters, we have to support code that passes them, + // but not additionalParams... + if ( $.isFunction( additionalParams ) ) { + err = ok; + ok = additionalParams; + additionalParams = undefined; + } + + if ( ok || err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); + } + + return this.postWithEditToken( $.extend( { + action: 'edit', + section: 'new', + format: 'json', + title: String( title ), + summary: header, + text: message + }, additionalParams ) ).done( ok ).fail( err ); + } + } ); + + /** + * @class mw.Api + * @mixins mw.Api.plugin.edit + */ + +}( mediaWiki, jQuery ) ); diff --git a/resources/src/mediawiki.api/mediawiki.api.js b/resources/src/mediawiki.api/mediawiki.api.js new file mode 100644 index 00000000..51b3238c --- /dev/null +++ b/resources/src/mediawiki.api/mediawiki.api.js @@ -0,0 +1,397 @@ +( function ( mw, $ ) { + + // We allow people to omit these default parameters from API requests + // there is very customizable error handling here, on a per-call basis + // wondering, would it be simpler to make it easy to clone the api object, + // change error handling, and use that instead? + var defaultOptions = { + + // Query parameters for API requests + parameters: { + action: 'query', + format: 'json' + }, + + // Ajax options for jQuery.ajax() + ajax: { + url: mw.util.wikiScript( 'api' ), + + timeout: 30 * 1000, // 30 seconds + + dataType: 'json' + } + }, + // Keyed by ajax url and symbolic name for the individual request + promises = {}; + + // Pre-populate with fake ajax promises to save http requests for tokens + // we already have on the page via the user.tokens module (bug 34733). + promises[ defaultOptions.ajax.url ] = {}; + $.each( mw.user.tokens.get(), function ( key, value ) { + // This requires #getToken to use the same key as user.tokens. + // Format: token-type + "Token" (eg. editToken, patrolToken, watchToken). + promises[ defaultOptions.ajax.url ][ key ] = $.Deferred() + .resolve( value ) + .promise( { abort: function () {} } ); + } ); + + /** + * Constructor to create an object to interact with the API of a particular MediaWiki server. + * mw.Api objects represent the API of a particular MediaWiki server. + * + * TODO: Share API objects with exact same config. + * + * var api = new mw.Api(); + * api.get( { + * action: 'query', + * meta: 'userinfo' + * } ).done ( function ( data ) { + * console.log( data ); + * } ); + * + * @class + * + * @constructor + * @param {Object} options See defaultOptions documentation above. Ajax options can also be + * overridden for each individual request to {@link jQuery#ajax} later on. + */ + mw.Api = function ( options ) { + + if ( options === undefined ) { + options = {}; + } + + // Force a string if we got a mw.Uri object + if ( options.ajax && options.ajax.url !== undefined ) { + options.ajax.url = String( options.ajax.url ); + } + + options.parameters = $.extend( {}, defaultOptions.parameters, options.parameters ); + options.ajax = $.extend( {}, defaultOptions.ajax, options.ajax ); + + this.defaults = options; + }; + + mw.Api.prototype = { + + /** + * Normalize the ajax options for compatibility and/or convenience methods. + * + * @param {Object} [arg] An object contaning one or more of options.ajax. + * @return {Object} Normalized ajax options. + */ + normalizeAjaxOptions: function ( arg ) { + // Arg argument is usually empty + // (before MW 1.20 it was used to pass ok callbacks) + var opts = arg || {}; + // Options can also be a success callback handler + if ( typeof arg === 'function' ) { + opts = { ok: arg }; + } + return opts; + }, + + /** + * Perform API get request + * + * @param {Object} parameters + * @param {Object|Function} [ajaxOptions] + * @return {jQuery.Promise} + */ + get: function ( parameters, ajaxOptions ) { + ajaxOptions = this.normalizeAjaxOptions( ajaxOptions ); + ajaxOptions.type = 'GET'; + return this.ajax( parameters, ajaxOptions ); + }, + + /** + * Perform API post request + * + * TODO: Post actions for non-local hostnames will need proxy. + * + * @param {Object} parameters + * @param {Object|Function} [ajaxOptions] + * @return {jQuery.Promise} + */ + post: function ( parameters, ajaxOptions ) { + ajaxOptions = this.normalizeAjaxOptions( ajaxOptions ); + ajaxOptions.type = 'POST'; + return this.ajax( parameters, ajaxOptions ); + }, + + /** + * Perform the API call. + * + * @param {Object} parameters + * @param {Object} [ajaxOptions] + * @return {jQuery.Promise} Done: API response data and the jqXHR object. + * Fail: Error code + */ + ajax: function ( parameters, ajaxOptions ) { + var token, + apiDeferred = $.Deferred(), + msg = 'Use of mediawiki.api callback params is deprecated. Use the Promise instead.', + xhr, key, formData; + + parameters = $.extend( {}, this.defaults.parameters, parameters ); + ajaxOptions = $.extend( {}, this.defaults.ajax, ajaxOptions ); + + // Ensure that token parameter is last (per [[mw:API:Edit#Token]]). + if ( parameters.token ) { + token = parameters.token; + delete parameters.token; + } + + // If multipart/form-data has been requested and emulation is possible, emulate it + if ( + ajaxOptions.type === 'POST' && + window.FormData && + ajaxOptions.contentType === 'multipart/form-data' + ) { + + formData = new FormData(); + + for ( key in parameters ) { + formData.append( key, parameters[key] ); + } + // If we extracted a token parameter, add it back in. + if ( token ) { + formData.append( 'token', token ); + } + + ajaxOptions.data = formData; + + // Prevent jQuery from mangling our FormData object + ajaxOptions.processData = false; + // Prevent jQuery from overriding the Content-Type header + ajaxOptions.contentType = false; + } else { + // Some deployed MediaWiki >= 1.17 forbid periods in URLs, due to an IE XSS bug + // So let's escape them here. See bug #28235 + // This works because jQuery accepts data as a query string or as an Object + ajaxOptions.data = $.param( parameters ).replace( /\./g, '%2E' ); + + // If we extracted a token parameter, add it back in. + if ( token ) { + ajaxOptions.data += '&token=' + encodeURIComponent( token ); + } + + if ( ajaxOptions.contentType === 'multipart/form-data' ) { + // We were asked to emulate but can't, so drop the Content-Type header, otherwise + // it'll be wrong and the server will fail to decode the POST body + delete ajaxOptions.contentType; + } + } + + // Backwards compatibility: Before MediaWiki 1.20, + // callbacks were done with the 'ok' and 'err' property in ajaxOptions. + if ( ajaxOptions.ok ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); + apiDeferred.done( ajaxOptions.ok ); + delete ajaxOptions.ok; + } + if ( ajaxOptions.err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); + apiDeferred.fail( ajaxOptions.err ); + delete ajaxOptions.err; + } + + // Make the AJAX request + xhr = $.ajax( ajaxOptions ) + // If AJAX fails, reject API call with error code 'http' + // and details in second argument. + .fail( function ( xhr, textStatus, exception ) { + apiDeferred.reject( 'http', { + xhr: xhr, + textStatus: textStatus, + exception: exception + } ); + } ) + // AJAX success just means "200 OK" response, also check API error codes + .done( function ( result, textStatus, jqXHR ) { + if ( result === undefined || result === null || result === '' ) { + apiDeferred.reject( 'ok-but-empty', + 'OK response but empty result (check HTTP headers?)' + ); + } else if ( result.error ) { + var code = result.error.code === undefined ? 'unknown' : result.error.code; + apiDeferred.reject( code, result ); + } else { + apiDeferred.resolve( result, jqXHR ); + } + } ); + + // Return the Promise + return apiDeferred.promise( { abort: xhr.abort } ).fail( function ( code, details ) { + if ( !( code === 'http' && details && details.textStatus === 'abort' ) ) { + mw.log( 'mw.Api error: ', code, details ); + } + } ); + }, + + /** + * Post to API with specified type of token. If we have no token, get one and try to post. + * If we have a cached token try using that, and if it fails, blank out the + * cached token and start over. For example to change an user option you could do: + * + * new mw.Api().postWithToken( 'options', { + * action: 'options', + * optionname: 'gender', + * optionvalue: 'female' + * } ); + * + * @param {string} tokenType The name of the token, like options or edit. + * @param {Object} params API parameters + * @param {Object} [ajaxOptions] + * @return {jQuery.Promise} See #post + * @since 1.22 + */ + postWithToken: function ( tokenType, params, ajaxOptions ) { + var api = this; + + // Do not allow deprecated ok-callback + // FIXME: Remove this check when the deprecated ok-callback is removed in #post + if ( $.isFunction( ajaxOptions ) ) { + ajaxOptions = undefined; + } + + return api.getToken( tokenType ).then( function ( token ) { + params.token = token; + return api.post( params, ajaxOptions ).then( + // If no error, return to caller as-is + null, + // Error handler + function ( code ) { + if ( code === 'badtoken' ) { + // Clear from cache + promises[ api.defaults.ajax.url ][ tokenType + 'Token' ] = + params.token = undefined; + + // Try again, once + return api.getToken( tokenType ).then( function ( token ) { + params.token = token; + return api.post( params, ajaxOptions ); + } ); + } + + // Different error, pass on to let caller handle the error code + return this; + } + ); + } ); + }, + + /** + * Get a token for a certain action from the API. + * + * @param {string} type Token type + * @return {jQuery.Promise} + * @return {Function} return.done + * @return {string} return.done.token Received token. + * @since 1.22 + */ + getToken: function ( type ) { + var apiPromise, + promiseGroup = promises[ this.defaults.ajax.url ], + d = promiseGroup && promiseGroup[ type + 'Token' ]; + + if ( !d ) { + apiPromise = this.get( { action: 'tokens', type: type } ); + + d = apiPromise + .then( function ( data ) { + // If token type is not available for this user, + // key '...token' is either missing or set to boolean false + if ( data.tokens && data.tokens[type + 'token'] ) { + return data.tokens[type + 'token']; + } + + return $.Deferred().reject( 'token-missing', data ); + }, function () { + // Clear promise. Do not cache errors. + delete promiseGroup[ type + 'Token' ]; + + // Pass on to allow the caller to handle the error + return this; + } ) + // Attach abort handler + .promise( { abort: apiPromise.abort } ); + + // Store deferred now so that we can use it again even if it isn't ready yet + if ( !promiseGroup ) { + promiseGroup = promises[ this.defaults.ajax.url ] = {}; + } + promiseGroup[ type + 'Token' ] = d; + } + + return d; + } + }; + + /** + * @static + * @property {Array} + * List of errors we might receive from the API. + * For now, this just documents our expectation that there should be similar messages + * available. + */ + mw.Api.errors = [ + // occurs when POST aborted + // jQuery 1.4 can't distinguish abort or lost connection from 200 OK + empty result + 'ok-but-empty', + + // timeout + 'timeout', + + // really a warning, but we treat it like an error + 'duplicate', + 'duplicate-archive', + + // upload succeeded, but no image info. + // this is probably impossible, but might as well check for it + 'noimageinfo', + // remote errors, defined in API + 'uploaddisabled', + 'nomodule', + 'mustbeposted', + 'badaccess-groups', + 'stashfailed', + 'missingresult', + 'missingparam', + 'invalid-file-key', + 'copyuploaddisabled', + 'mustbeloggedin', + 'empty-file', + 'file-too-large', + 'filetype-missing', + 'filetype-banned', + 'filetype-banned-type', + 'filename-tooshort', + 'illegal-filename', + 'verification-error', + 'hookaborted', + 'unknown-error', + 'internal-error', + 'overwrite', + 'badtoken', + 'fetchfileerror', + 'fileexists-shared-forbidden', + 'invalidtitle', + 'notloggedin' + ]; + + /** + * @static + * @property {Array} + * List of warnings we might receive from the API. + * For now, this just documents our expectation that there should be similar messages + * available. + */ + mw.Api.warnings = [ + 'duplicate', + 'exists' + ]; + +}( mediaWiki, jQuery ) ); diff --git a/resources/src/mediawiki.api/mediawiki.api.login.js b/resources/src/mediawiki.api/mediawiki.api.login.js new file mode 100644 index 00000000..ccbae06c --- /dev/null +++ b/resources/src/mediawiki.api/mediawiki.api.login.js @@ -0,0 +1,54 @@ +/** + * Make the two-step login easier. + * @author Niklas Laxström + * @class mw.Api.plugin.login + * @since 1.22 + */ +( function ( mw, $ ) { + 'use strict'; + + $.extend( mw.Api.prototype, { + /** + * @param {string} username + * @param {string} password + * @return {jQuery.Promise} See mw.Api#post + */ + login: function ( username, password ) { + var params, request, + deferred = $.Deferred(), + api = this; + + params = { + action: 'login', + lgname: username, + lgpassword: password + }; + + request = api.post( params ); + request.fail( deferred.reject ); + request.done( function ( data ) { + params.lgtoken = data.login.token; + api.post( params ) + .fail( deferred.reject ) + .done( function ( data ) { + var code; + if ( data.login && data.login.result === 'Success' ) { + deferred.resolve( data ); + } else { + // Set proper error code whenever possible + code = data.error && data.error.code || 'unknown'; + deferred.reject( code, data ); + } + } ); + } ); + + return deferred.promise( { abort: request.abort } ); + } + } ); + + /** + * @class mw.Api + * @mixins mw.Api.plugin.login + */ + +}( mediaWiki, jQuery ) ); diff --git a/resources/src/mediawiki.api/mediawiki.api.parse.js b/resources/src/mediawiki.api/mediawiki.api.parse.js new file mode 100644 index 00000000..b1f1d2b0 --- /dev/null +++ b/resources/src/mediawiki.api/mediawiki.api.parse.js @@ -0,0 +1,45 @@ +/** + * @class mw.Api.plugin.parse + */ +( function ( mw, $ ) { + + $.extend( mw.Api.prototype, { + /** + * Convenience method for 'action=parse'. + * + * @param {string} wikitext + * @param {Function} [ok] Success callback (deprecated) + * @param {Function} [err] Error callback (deprecated) + * @return {jQuery.Promise} + * @return {Function} return.done + * @return {string} return.done.data Parsed HTML of `wikitext`. + */ + parse: function ( wikitext, ok, err ) { + var apiPromise = this.get( { + action: 'parse', + contentmodel: 'wikitext', + text: wikitext + } ); + + // Backwards compatibility (< MW 1.20) + if ( ok || err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( 'Use of mediawiki.api callback params is deprecated. Use the Promise instead.' ); + } + + return apiPromise + .then( function ( data ) { + return data.parse.text['*']; + } ) + .done( ok ) + .fail( err ) + .promise( { abort: apiPromise.abort } ); + } + } ); + + /** + * @class mw.Api + * @mixins mw.Api.plugin.parse + */ + +}( mediaWiki, jQuery ) ); diff --git a/resources/src/mediawiki.api/mediawiki.api.watch.js b/resources/src/mediawiki.api/mediawiki.api.watch.js new file mode 100644 index 00000000..af2dee10 --- /dev/null +++ b/resources/src/mediawiki.api/mediawiki.api.watch.js @@ -0,0 +1,79 @@ +/** + * @class mw.Api.plugin.watch + * @since 1.19 + */ +( function ( mw, $ ) { + + /** + * @private + * @static + * @context mw.Api + * + * @param {string|mw.Title|string[]|mw.Title[]} pages Full page name or instance of mw.Title, or an + * array thereof. If an array is passed, the return value passed to the promise will also be an + * array of appropriate objects. + * @param {Function} [ok] Success callback (deprecated) + * @param {Function} [err] Error callback (deprecated) + * @return {jQuery.Promise} + * @return {Function} return.done + * @return {Object|Object[]} return.done.watch Object or list of objects (depends on the `pages` + * parameter) + * @return {string} return.done.watch.title Full pagename + * @return {boolean} return.done.watch.watched Whether the page is now watched or unwatched + * @return {string} return.done.watch.message Parsed HTML of the confirmational interface message + */ + function doWatchInternal( pages, ok, err, addParams ) { + // XXX: Parameter addParams is undocumented because we inherit this + // documentation in the public method... + var apiPromise = this.postWithToken( 'watch', + $.extend( + { + action: 'watch', + titles: $.isArray( pages ) ? pages.join( '|' ) : String( pages ), + uselang: mw.config.get( 'wgUserLanguage' ) + }, + addParams + ) + ); + + // Backwards compatibility (< MW 1.20) + if ( ok || err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( 'Use of mediawiki.api callback params is deprecated. Use the Promise instead.' ); + } + + return apiPromise + .then( function ( data ) { + // If a single page was given (not an array) respond with a single item as well. + return $.isArray( pages ) ? data.watch : data.watch[0]; + } ) + .done( ok ) + .fail( err ) + .promise( { abort: apiPromise.abort } ); + } + + $.extend( mw.Api.prototype, { + /** + * Convenience method for `action=watch`. + * + * @inheritdoc #doWatchInternal + */ + watch: function ( pages, ok, err ) { + return doWatchInternal.call( this, pages, ok, err ); + }, + /** + * Convenience method for `action=watch&unwatch=1`. + * + * @inheritdoc #doWatchInternal + */ + unwatch: function ( pages, ok, err ) { + return doWatchInternal.call( this, pages, ok, err, { unwatch: 1 } ); + } + } ); + + /** + * @class mw.Api + * @mixins mw.Api.plugin.watch + */ + +}( mediaWiki, jQuery ) ); |