Index: branches/wmf/1.17wmf1/extensions/ClickTracking/modules/jquery.clickTracking.js |
— | — | @@ -49,4 +49,19 @@ |
50 | 50 | } |
51 | 51 | ); |
52 | 52 | }; |
| 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 | + } |
53 | 68 | } )( jQuery ); |
Index: branches/wmf/1.17wmf1/extensions/ClickTracking/modules/ext.clickTracking.js |
— | — | @@ -7,13 +7,10 @@ |
8 | 8 | $( document ).ready( function() { |
9 | 9 | $( '#p-logo a, #p-navigation a, #p-interaction a, #p-tb a' ).each( function() { |
10 | 10 | var href = $( this ).attr( 'href' ); |
11 | | - var token = $.cookie( 'clicktracking-session' ); |
12 | 11 | // Only modify local URLs |
13 | 12 | if ( href.length > 0 && href[0] == '/' && ( href.length == 1 || href[1] != '/' ) ) { |
14 | 13 | 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 ) ); |
18 | 15 | } |
19 | 16 | } ); |
20 | 17 | } ); |