2 * @class mw.Api.plugin.watch
12 * @param {string|mw.Title|string[]|mw.Title[]} pages Full page name or instance of mw.Title, or an
13 * array thereof. If an array is passed, the return value passed to the promise will also be an
14 * array of appropriate objects.
15 * @return {jQuery.Promise}
16 * @return {Function} return.done
17 * @return {Object|Object[]} return.done.watch Object or list of objects (depends on the `pages`
19 * @return {string} return.done.watch.title Full pagename
20 * @return {boolean} return.done.watch.watched Whether the page is now watched or unwatched
21 * @return {string} return.done.watch.message Parsed HTML of the confirmational interface message
23 function doWatchInternal( pages, addParams ) {
24 // XXX: Parameter addParams is undocumented because we inherit this
25 // documentation in the public method...
26 var apiPromise = this.postWithToken( 'watch',
30 titles: $.isArray( pages ) ? pages.join( '|' ) : String( pages ),
31 uselang: mw.config.get( 'wgUserLanguage' )
38 .then( function ( data ) {
39 // If a single page was given (not an array) respond with a single item as well.
40 return $.isArray( pages ) ? data.watch : data.watch[0];
42 .promise( { abort: apiPromise.abort } );
45 $.extend( mw.Api.prototype, {
47 * Convenience method for `action=watch`.
49 * @inheritdoc #doWatchInternal
51 watch: function ( pages ) {
52 return doWatchInternal.call( this, pages );
56 * Convenience method for `action=watch&unwatch=1`.
58 * @inheritdoc #doWatchInternal
60 unwatch: function ( pages ) {
61 return doWatchInternal.call( this, pages, { unwatch: 1 } );
67 * @mixins mw.Api.plugin.watch
70 }( mediaWiki, jQuery ) );