ab8a5127ded9a4d1f74ab0696825d44e54560b1e
2 * @class mw.Api.plugin.watch
11 * @param {string|mw.Title|string[]|mw.Title[]} page Full page name or instance of mw.Title or array of pages
12 * @param {Function} [ok] Success callback (deprecated)
13 * @param {Function} [err] Error callback (deprecated)
14 * @return {jQuery.Promise}
15 * @return {Function} return.done
16 * @return {Object} return.done.watch
17 * @return {string} return.done.watch.title Full pagename
18 * @return {boolean} return.done.watch.watched
19 * @return {string} return.done.watch.message Parsed HTML of the confirmational interface message
21 function doWatchInternal( page
, ok
, err
, addParams
) {
26 // Backwards compatibility (< MW 1.20)
27 d
.done( ok
).fail( err
);
31 titles
: $.isArray( page
) ? page
.join( '|' ) : String( page
),
32 token
: mw
.user
.tokens
.get( 'watchToken' ),
33 uselang
: mw
.config
.get( 'wgUserLanguage' )
37 $.extend( params
, addParams
);
40 apiPromise
= this.post( params
)
41 .done( function ( data
) {
42 d
.resolve( data
.watch
);
46 return d
.promise( { abort
: apiPromise
.abort
} );
49 $.extend( mw
.Api
.prototype, {
51 * Convenience method for `action=watch`.
53 * @inheritdoc #doWatchInternal
55 watch: function ( page
, ok
, err
) {
56 return doWatchInternal
.call( this, page
, ok
, err
);
59 * Convenience method for `action=watch&unwatch=1`.
61 * @inheritdoc #doWatchInternal
63 unwatch: function ( page
, ok
, err
) {
64 return doWatchInternal
.call( this, page
, ok
, err
, { unwatch
: 1 } );
71 * @mixins mw.Api.plugin.watch
74 }( mediaWiki
, jQuery
) );