r83919 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83918‎ | r83919 | r83920 >
Date:16:41, 14 March 2011
Author:catrope
Status:ok
Tags:
Comment:
ClickTracking: Factor api.php?action=clicktracking&redirectto=... URL generation out into $.trackActionURL()
Modified paths:
  • /trunk/extensions/ClickTracking/modules/ext.clickTracking.js (modified) (history)
  • /trunk/extensions/ClickTracking/modules/jquery.clickTracking.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ClickTracking/modules/jquery.clickTracking.js
@@ -49,4 +49,19 @@
5050 }
5151 );
5252 };
 53+
 54+ /**
 55+ * Rewrites a URL to one that runs through the ClickTracking API module
 56+ * which registers the event and redirects to the real URL
 57+ * @param {string} url URL to redirect to
 58+ * @param {string} id Event identifier
 59+ */
 60+ $.trackActionURL = function( url, id ) {
 61+ return mediaWiki.config.get( 'wgScriptPath' ) + '/api.php?' + $.param( {
 62+ 'action': 'clicktracking',
 63+ 'eventid': id,
 64+ 'token': $.cookie( 'clicktracking-session' ),
 65+ 'redirectto': url
 66+ } );
 67+ }
5368 } )( jQuery );
Index: trunk/extensions/ClickTracking/modules/ext.clickTracking.js
@@ -7,13 +7,10 @@
88 $( document ).ready( function() {
99 $( '#p-logo a, #p-navigation a, #p-interaction a, #p-tb a' ).each( function() {
1010 var href = $( this ).attr( 'href' );
11 - var token = $.cookie( 'clicktracking-session' );
1211 // Only modify local URLs
1312 if ( href.length > 0 && href[0] == '/' && ( href.length == 1 || href[1] != '/' ) ) {
1413 var id = 'leftnav-' + skin + '-' + ( $( this ).attr( 'id' ) || $( this ).parent().attr( 'id' ) );
15 - href = mediaWiki.config.get( 'wgScriptPath' ) + '/api.php?action=clicktracking' +
16 - '&eventid=' + id + '&token=' + token + '&redirectto=' + escape( href );
17 - $( this ).attr( 'href', href );
 14+ $( this ).attr( 'href', $.trackActionURL( href, id ) );
1815 }
1916 } );
2017 } );

Follow-up revisions

RevisionCommit summaryAuthorDate
r83920Vector/SectionEditLinks: Use $.trackActionURL() from r83919catrope16:42, 14 March 2011
r839521.17wmf1: MFT r83919catrope19:32, 14 March 2011
r85033MFT more extension revs: r82601, r82654, r82698, r82755, r82756, r82759, r829...demon18:49, 30 March 2011

Status & tagging log