Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.watch.ajax.js |
— | — | @@ -85,15 +85,12 @@ |
86 | 86 | |
87 | 87 | var reqData = { |
88 | 88 | 'action': 'watch', |
89 | | - 'format': 'json', |
90 | 89 | 'title': $link.data( 'target' ) |
91 | 90 | }; |
92 | 91 | if ( $link.data( 'action' ) == 'unwatch' ) { |
93 | 92 | reqData['unwatch'] = ''; |
94 | 93 | } |
95 | | - $.getJSON( mw.config.get( 'wgScriptPath' ) |
96 | | - + '/api' + mw.config.get( 'wgScriptExtension' ), |
97 | | - reqData, |
| 94 | + mw.api(reqData, |
98 | 95 | function( data, textStatus, xhr ) { |
99 | 96 | wgAjaxWatch.processResult( data, $link ); |
100 | 97 | } |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -473,6 +473,17 @@ |
474 | 474 | }; |
475 | 475 | |
476 | 476 | /** |
| 477 | + * Performs an API call |
| 478 | + * |
| 479 | + * @param data object Call parameters |
| 480 | + * @param callback function Function to be called on success, see jQuery.getJSON() for details |
| 481 | + */ |
| 482 | + this.api = function( data, callback ) { |
| 483 | + var url = this.config.get( 'wgScriptPath' ) + '/api' + this.config.get( 'wgScriptExtension' ); |
| 484 | + data.format = 'json'; |
| 485 | + return jQuery.getJSON( url, data, callback ); |
| 486 | + } |
| 487 | + /** |
477 | 488 | * Client-side module loader which integrates with the MediaWiki ResourceLoader |
478 | 489 | */ |
479 | 490 | this.loader = new ( function() { |