r114717 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114716‎ | r114717 | r114718 >
Date:21:58, 4 April 2012
Author:catrope
Status:deferred
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
@@ -135,6 +135,33 @@
136136 '
137137 },
138138 'fn': {
 139+ 'trackClick': function( id ) {
 140+ if ( track && typeof $.trackActionWithInfo == 'function' ) {
 141+ $.trackActionWithInfo( prefix( id ), mw.config.get( 'wgTitle' ) + '|' + mw.config.get( 'wgCurRevisionId' ) );
 142+ }
 143+ },
 144+ /**
 145+ * Rewrites a URL to one that runs through the ClickTracking API module
 146+ * which registers the event and redirects to the real URL
 147+ *
 148+ * This is a copy of the one out of the clicktracking javascript API
 149+ * we have to do our OWN because there is no "additional" option in that
 150+ * API which we MUST use for the article title
 151+ *
 152+ * @param {string} url URL to redirect to
 153+ * @param {string} id Event identifier
 154+ */
 155+ 'trackActionURL': function( url, id ) {
 156+ return mw.config.get( 'wgScriptPath' ) + '/api.php?' + $.param( {
 157+ 'action': 'clicktracking',
 158+ 'format' : 'json',
 159+ 'eventid': prefix( id ),
 160+ 'namespacenumber': mw.config.get( 'wgNamespaceNumber' ),
 161+ 'token': $.cookie( 'clicktracking-session' ),
 162+ 'additional': mw.config.get( 'wgTitle' ) + '|' + mw.config.get( 'wgCurRevisionId' ),
 163+ 'redirectto': url
 164+ } );
 165+ },
139166 'enableSubmission': function( state ) {
140167 var context = this;
141168 if ( state ) {
@@ -547,9 +574,7 @@
548575 { 'expires': 3, 'path': '/' }
549576 );
550577 // Track that a pitch was dismissed
551 - if ( tracked && typeof $.trackAction == 'function' ) {
552 - $.trackAction( prefix( 'pitch-' + key + '-reject' ) );
553 - }
 578+ $.articleFeedback.fn.trackClick( 'pitch-' + key + '-reject' );
554579 $pitch.fadeOut( 'fast', function() {
555580 context.$ui.find( '.articleFeedback-ui' ).show();
556581 } );
@@ -686,14 +711,10 @@
687712 .fadeIn( 'fast' );
688713 context.$ui.find( '.articleFeedback-ui' ).hide();
689714 // Track that a pitch was presented
690 - if ( tracked && typeof $.trackAction == 'function' ) {
691 - $.trackAction( prefix( 'pitch-' + key + '-show' ) );
692 - }
 715+ $.articleFeedback.fn.trackClick( 'pitch-' + key + '-show' );
693716 } else {
694717 // Track that a pitch was not presented
695 - if ( tracked && typeof $.trackAction == 'function' ) {
696 - $.trackAction( prefix( 'pitch-bypass' ) );
697 - }
 718+ $.articleFeedback.fn.trackClick( 'pitch-' + key + '-bypass' );
698719 // Give user some feedback that a save occured
699720 context.$ui.find( '.articleFeedback-success span' ).fadeIn( 'fast' );
700721 context.successTimeout = setTimeout( function() {
Index: branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js
@@ -26,7 +26,9 @@
2727 * @return Boolean: Whether the pitch is muted
2828 */
2929 function isPitchVisible( pitch ) {
30 - return $.cookie( prefix( 'pitches-' + pitch ) ) != 'hide';
 30+ return true;
 31+ // Disabled per Dario
 32+ //return $.cookie( prefix( 'pitches-' + pitch ) ) != 'hide';
3133 }
3234
3335 /**
@@ -36,24 +38,10 @@
3739 * @param durration Integer: Number of days to mute the pitch for
3840 */
3941 function mutePitch( pitch, duration ) {
40 - $.cookie( prefix( 'pitches-' + pitch ), 'hide', { 'expires': duration, 'path': '/' } );
 42+ // Disabled per Dario
 43+ //$.cookie( prefix( 'pitches-' + pitch ), 'hide', { 'expires': duration, 'path': '/' } );
4144 }
4245
43 -function trackClick( id ) {
44 - // Track the click so we can figure out how useful this is
45 - if ( tracked && $.isFunction( $.trackActionWithInfo ) ) {
46 - $.trackActionWithInfo( prefix( id ), mw.config.get( 'wgTitle' ) );
47 - }
48 -}
49 -
50 -function trackClickURL( url, id ) {
51 - if ( tracked && $.isFunction( $.trackActionURL ) ) {
52 - return $.trackActionURL( url, prefix( id ) );
53 - } else {
54 - return url;
55 - }
56 -}
57 -
5846 /**
5947 * Survey object
6048 *
@@ -94,7 +82,7 @@
9583 'title': mw.msg( 'articlefeedback-survey-title' ),
9684 'close': function() {
9785 // Click tracking
98 - trackClick( 'survey-cancel' );
 86+ $.articleFeedback.fn.trackClick( 'survey-cancel' );
9987 // Return the survey to default state
10088 $dialog.dialog( 'option', 'height', 400 );
10189 $form.show();
@@ -173,7 +161,7 @@
174162 }
175163 } );
176164 // Click tracking
177 - trackClick( 'survey-submit-attempt' );
 165+ $.articleFeedback.fn.trackClick( 'survey-submit-attempt' );
178166 // XXX: Not only are we submitting to a special page instead of an API request, but we are
179167 // screen-scraping the result - this is evil and needs to be addressed later
180168 $.ajax( {
@@ -191,7 +179,7 @@
192180 // Mute for 30 days
193181 mutePitch( 'survey', 30 );
194182 // Click tracking
195 - trackClick( 'survey-submit-complete' );
 183+ $.articleFeedback.fn.trackClick( 'survey-submit-complete' );
196184 },
197185 'error': function( XMLHttpRequest, textStatus, errorThrown ) {
198186 // Take the dialog out of "loading" state
@@ -223,7 +211,7 @@
224212 'action': function() {
225213 survey.load();
226214 // Click tracking
227 - trackClick( 'pitch-survey-accept' );
 215+ $.articleFeedback.fn.trackClick( 'pitch-survey-accept' );
228216 // Hide the pitch immediately
229217 return true;
230218 },
@@ -243,7 +231,7 @@
244232 mutePitch( 'join', 1 );
245233 // Go to account creation page
246234 // Track the click through an API redirect
247 - window.location = trackClickURL(
 235+ window.location = $.articleFeedback.fn.trackActionURL(
248236 mw.config.get( 'wgScript' ) + '?' + $.param( {
249237 'title': 'Special:UserLogin',
250238 'type': 'signup',
@@ -263,7 +251,7 @@
264252 mutePitch( 'join', 1 );
265253 // Go to login page
266254 // Track the click through an API redirect
267 - window.location = trackClickURL(
 255+ window.location = $.articleFeedback.fn.trackActionURL(
268256 mw.config.get( 'wgScript' ) + '?' + $.param( {
269257 'title': 'Special:UserLogin',
270258 'returnto': mw.config.get( 'wgPageName' )
@@ -299,7 +287,7 @@
300288 params.clicktrackingevent = prefix( 'pitch-edit-save' );
301289 }
302290 // Track the click through an API redirect (automatically bypasses if !tracked)
303 - window.location = trackClickURL(
 291+ window.location = $.articleFeedback.fn.trackActionURL(
304292 mw.config.get( 'wgScript' ) + '?' + $.param( params ), 'pitch-edit-accept'
305293 );
306294 return false;
@@ -333,7 +321,7 @@
334322 .click( function() {
335323 // Click tracking
336324 // Temporarily disabled per Dario's request --Roan
337 - //trackClick( 'toolbox-link' );
 325+ //$.articleFeedback.fn.trackClick( 'toolbox-link' );
338326 // Get the image, set the count and an interval.
339327 var $box = $( '#mw-articlefeedback' );
340328 var count = 0;

Status & tagging log