2 * Additional mw.Api methods to assist with (un)watching wiki pages.
6 $.extend( mw
.Api
.prototype, {
8 * Convinience method for 'action=watch'.
10 * @param page {String|mw.Title} Full page name or instance of mw.Title
11 * @param success {Function} callback to which the watch object will be passed
12 * watch object contains 'title' (full page name), 'watched' (boolean) and
13 * 'message' (parsed HTML of the 'addedwatchtext' message).
14 * @param err {Function} callback if error (optional)
15 * @param unwatch {Boolean} Internal variable, do not use. Used by unwatch() to
16 * reuse this function.
19 watch: function( page
, success
, err
, unwatch
) {
23 title
: String( page
),
24 token
: mw
.user
.tokens
.get( 'watchToken' ),
25 uselang
: mw
.config
.get( 'wgUserLanguage' )
27 ok = function( data
) {
28 success( data
.watch
);
30 return this.post( params
, { ok
: ok
, err
: err
} );
33 * Convinience method for 'action=watch&unwatch='.
35 * @param page {String|mw.Title} Full page name or instance of mw.Title
36 * @param success {Function} callback to which the watch object will be passed
37 * watch object contains 'title' (full page name), 'unwatched' (boolean) and
38 * 'message' (parsed HTML of the 'removedwatchtext' message).
39 * @param err {Function} callback if error (optional)
42 unwatch: function( page
, success
, err
, unwatch
) {
47 title
: String( page
),
48 token
: mw
.user
.tokens
.get( 'watchToken' ),
49 uselang
: mw
.config
.get( 'wgUserLanguage' )
51 ok = function( data
) {
52 success( data
.watch
);
54 return this.post( params
, { ok
: ok
, err
: err
} );
59 } )( jQuery
, mediaWiki
);