diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
commit | d9022f63880ce039446fba8364f68e656b7bf4cb (patch) | |
tree | 16b40fbf17bf7c9ee6f4ead25b16dd192378050a /resources/mediawiki.api/mediawiki.api.watch.js | |
parent | 27cf83d177256813e2e802241085fce5dd0f3fb9 (diff) |
Update to MediaWiki 1.19.0
Diffstat (limited to 'resources/mediawiki.api/mediawiki.api.watch.js')
-rw-r--r-- | resources/mediawiki.api/mediawiki.api.watch.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/resources/mediawiki.api/mediawiki.api.watch.js b/resources/mediawiki.api/mediawiki.api.watch.js new file mode 100644 index 00000000..3f2525ad --- /dev/null +++ b/resources/mediawiki.api/mediawiki.api.watch.js @@ -0,0 +1,58 @@ +/** + * Additional mw.Api methods to assist with (un)watching wiki pages. + * @since 1.19 + */ +( function( $, mw ) { + + $.extend( mw.Api.prototype, { + /** + * Convinience method for 'action=watch'. + * + * @param page {String|mw.Title} Full page name or instance of mw.Title + * @param success {Function} callback to which the watch object will be passed + * watch object contains 'title' (full page name), 'watched' (boolean) and + * 'message' (parsed HTML of the 'addedwatchtext' message). + * @param err {Function} callback if error (optional) + * @return {jqXHR} + */ + watch: function( page, success, err ) { + var params, ok; + params = { + action: 'watch', + title: String( page ), + token: mw.user.tokens.get( 'watchToken' ), + uselang: mw.config.get( 'wgUserLanguage' ) + }; + ok = function( data ) { + success( data.watch ); + }; + return this.post( params, { ok: ok, err: err } ); + }, + /** + * Convinience method for 'action=watch&unwatch='. + * + * @param page {String|mw.Title} Full page name or instance of mw.Title + * @param success {Function} callback to which the watch object will be passed + * watch object contains 'title' (full page name), 'unwatched' (boolean) and + * 'message' (parsed HTML of the 'removedwatchtext' message). + * @param err {Function} callback if error (optional) + * @return {jqXHR} + */ + unwatch: function( page, success, err ) { + var params, ok; + params = { + action: 'watch', + unwatch: 1, + title: String( page ), + token: mw.user.tokens.get( 'watchToken' ), + uselang: mw.config.get( 'wgUserLanguage' ) + }; + ok = function( data ) { + success( data.watch ); + }; + return this.post( params, { ok: ok, err: err } ); + } + + } ); + +} )( jQuery, mediaWiki ); |