r86054 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86053‎ | r86054 | r86055 >
Date:15:56, 14 April 2011
Author:maxsem
Status:reverted (Comments)
Tags:
Comment:
Added wrapper mw.api() for API calls
Modified paths:
  • /trunk/phase3/resources/mediawiki.action/mediawiki.action.watch.ajax.js (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.watch.ajax.js
@@ -85,15 +85,12 @@
8686
8787 var reqData = {
8888 'action': 'watch',
89 - 'format': 'json',
9089 'title': $link.data( 'target' )
9190 };
9291 if ( $link.data( 'action' ) == 'unwatch' ) {
9392 reqData['unwatch'] = '';
9493 }
95 - $.getJSON( mw.config.get( 'wgScriptPath' )
96 - + '/api' + mw.config.get( 'wgScriptExtension' ),
97 - reqData,
 94+ mw.api(reqData,
9895 function( data, textStatus, xhr ) {
9996 wgAjaxWatch.processResult( data, $link );
10097 }
Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -473,6 +473,17 @@
474474 };
475475
476476 /**
 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+ /**
477488 * Client-side module loader which integrates with the MediaWiki ResourceLoader
478489 */
479490 this.loader = new ( function() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r86059CodeReview.tooltips: use built-in functionsmaxsem16:41, 14 April 2011
r86250Back out r86054 and part of r86059 for now, I'd like to evaluate the possibil...maxsem05:46, 17 April 2011

Comments

#Comment by Catrope (talk | contribs)   14:58, 15 April 2011

It would be nice if the wrapper also allow POST requests.

You should also talk to Neil, who has written (or inherited, or rewritten, I'm not sure) a larger mw.api library.

Status & tagging log