[JobQueue] Added missing delete query.
[mediawiki.git] / resources / mediawiki.api / mediawiki.api.watch.js
blobd32344212e35bcafa9ddfa832acdd309139029da
1 /**
2 * Additional mw.Api methods to assist with (un)watching wiki pages.
3 * @since 1.19
4 */
5 ( function ( mw, $ ) {
7 /**
8 * @context {mw.Api}
9 */
10 function doWatchInternal( page, success, err, addParams ) {
11 var params = {
12 action: 'watch',
13 title: String( page ),
14 token: mw.user.tokens.get( 'watchToken' ),
15 uselang: mw.config.get( 'wgUserLanguage' )
17 function ok( data ) {
18 success( data.watch );
20 if ( addParams ) {
21 $.extend( params, addParams );
23 return this.post( params, { ok: ok, err: err } );
26 $.extend( mw.Api.prototype, {
27 /**
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)
35 * @return {jqXHR}
37 watch: function ( page, success, err ) {
38 return doWatchInternal.call( this, page, success, err );
40 /**
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)
48 * @return {jqXHR}
50 unwatch: function ( page, success, err ) {
51 return doWatchInternal.call( this, page, success, err, { unwatch: 1 } );
54 } );
56 }( mediaWiki, jQuery ) );