2 * Additional mw.Api methods to assist with (un)watching wiki pages.
10 function doWatchInternal( page
, success
, err
, addParams
) {
13 title
: String( page
),
14 token
: mw
.user
.tokens
.get( 'watchToken' ),
15 uselang
: mw
.config
.get( 'wgUserLanguage' )
18 success( data
.watch
);
21 $.extend( params
, addParams
);
23 return this.post( params
, { ok
: ok
, err
: err
} );
26 $.extend( mw
.Api
.prototype, {
28 * Convinience method for 'action=watch'.
30 * @param page {String|mw.Title} Full page name or instance of mw.Title
31 * @param success {Function} Callback to which the watch object will be passed.
32 * Watch object contains properties 'title' (full pagename), 'watched' (boolean) and
33 * 'message' (parsed HTML of the 'addedwatchtext' message).
34 * @param err {Function} Error callback (optional)
37 watch: function ( page
, success
, err
) {
38 return doWatchInternal
.call( this, page
, success
, err
);
41 * Convinience method for 'action=watch&unwatch=1'.
43 * @param page {String|mw.Title} Full page name or instance of mw.Title
44 * @param success {Function} Callback to which the watch object will be passed.
45 * Watch object contains properties 'title' (full pagename), 'watched' (boolean) and
46 * 'message' (parsed HTML of the 'removedwatchtext' message).
47 * @param err {Function} Error callback (optional)
50 unwatch: function ( page
, success
, err
) {
51 return doWatchInternal
.call( this, page
, success
, err
, { unwatch
: 1 } );
56 }( mediaWiki
, jQuery
) );