r78391 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78390‎ | r78391 | r78392 >
Date:16:56, 14 December 2010
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Use $.getJSON()'s middle parameter rather than DIY URL building in AJAX watch JS
Modified paths:
  • /trunk/phase3/resources/mediawiki.action/mediawiki.action.watch.ajax.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.watch.ajax.js
@@ -82,10 +82,18 @@
8383 }
8484
8585 wgAjaxWatch.setLinkText( $link, $link.data( 'action' ) + 'ing' );
 86+
 87+ var reqData = {
 88+ 'action': 'watch',
 89+ 'format': 'json',
 90+ 'title': $link.data( 'target' )
 91+ };
 92+ if ( $link.data( 'action' ) == 'unwatch' ) {
 93+ reqData['unwatch'] = '';
 94+ }
8695 $.getJSON( mw.config.get( 'wgScriptPath' )
87 - + '/api' + mw.config.get( 'wgScriptExtension' ) + '?action=watch&format=json&title='
88 - + encodeURIComponent( $link.data( 'target' ) )
89 - + ( $link.data( 'action' ) == 'unwatch' ? '&unwatch' : '' ),
 96+ + '/api' + mw.config.get( 'wgScriptExtension' ),
 97+ reqData,
9098 function( data, textStatus, xhr ) {
9199 wgAjaxWatch.processResult( data, $link );
92100 }

Comments

#Comment by Krinkle (talk | contribs)   17:07, 14 December 2010

Ah, ofcourse. Much better :-)

#Comment by Catrope (talk | contribs)   17:08, 14 December 2010

Even if this param hadn't been there, $.param() should've been used.

Status & tagging log