Remove unused $wgDebugDBTransactions
[lhc/web/wiklou.git] / resources / mediawiki.api / mediawiki.api.watch.js
1 /**
2 * Additional mw.Api methods to assist with (un)watching wiki pages.
3 * @since 1.19
4 */
5 ( function( $, mw ) {
6
7 $.extend( mw.Api.prototype, {
8 /**
9 * Convinience method for 'action=watch'.
10 *
11 * @param page {String|mw.Title} Full page name or instance of mw.Title
12 * @param success {Function} callback to which the watch object will be passed
13 * watch object contains 'title' (full page name), 'watched' (boolean) and
14 * 'message' (parsed HTML of the 'addedwatchtext' message).
15 * @param _unwatch {Boolean} Internally used to re-use this logic for unwatch(),
16 * do not use outside this module.
17 * @param err {Function} callback if error (optional)
18 * @return {jqXHR}
19 */
20 watch: function( page, success, err, _unwatch ) {
21 var params, ok;
22 params = {
23 action: 'watch',
24 title: String( page ),
25 token: mw.user.tokens.get( 'watchToken' ),
26 uselang: mw.config.get( 'wgUserLanguage' )
27 };
28 if ( _unwatch ) {
29 params.unwatch = 1;
30 }
31 ok = function( data ) {
32 success( data.watch );
33 };
34 return this.post( params, { ok: ok, err: err } );
35 },
36 /**
37 * Convinience method for 'action=watch&unwatch=1'.
38 *
39 * @param page {String|mw.Title} Full page name or instance of mw.Title
40 * @param success {Function} callback to which the watch object will be passed
41 * watch object contains 'title' (full page name), 'unwatched' (boolean) and
42 * 'message' (parsed HTML of the 'removedwatchtext' message).
43 * @param err {Function} callback if error (optional)
44 * @return {jqXHR}
45 */
46 unwatch: function( page, success, err ) {
47 return this.watch( page, success, err, true );
48 }
49
50 } );
51
52 } )( jQuery, mediaWiki );