r86976 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86975‎ | r86976 | r86977 >
Date:19:35, 26 April 2011
Author:krinkle
Status:ok
Tags:
Comment:
* Replace MW (inexistant) with mw (global alias to the mediaWiki object)
* Other minor fixes
(Follow-up r85049)
Modified paths:
  • /trunk/extensions/ClickTracking/modules/ext.UserBuckets.js (modified) (history)
  • /trunk/extensions/ClickTracking/modules/jquery.clickTracking.js (modified) (history)
  • /trunk/extensions/ClickTracking/modules/sampleCampaign.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ClickTracking/modules/jquery.clickTracking.js
@@ -26,9 +26,9 @@
2727 */
2828 $.trackAction = function( id ) {
2929 $.post(
30 - mediaWiki.config.get( 'wgScriptPath' ) + '/api.php', {
 30+ mw.config.get( 'wgScriptPath' ) + '/api.php', {
3131 'action': 'clicktracking',
32 - 'namespacenumber': mediaWiki.config.get( 'wgNamespaceNumber' ),
 32+ 'namespacenumber': mw.config.get( 'wgNamespaceNumber' ),
3333 'eventid': id,
3434 'token': $.cookie( 'clicktracking-session' )
3535 }
@@ -42,10 +42,10 @@
4343 */
4444 $.trackActionWithInfo = function( id, info ) {
4545 $.post(
46 - mediaWiki.config.get( 'wgScriptPath' ) + '/api.php', {
 46+ mw.config.get( 'wgScriptPath' ) + '/api.php', {
4747 'action': 'clicktracking',
4848 'eventid': id,
49 - 'namespacenumber': mediaWiki.config.get( 'wgNamespaceNumber' ),
 49+ 'namespacenumber': mw.config.get( 'wgNamespaceNumber' ),
5050 'token': $.cookie( 'clicktracking-session' ),
5151 'additional': info
5252 }
@@ -59,12 +59,13 @@
6060 * @param {string} id Event identifier
6161 */
6262 $.trackActionURL = function( url, id ) {
63 - return mediaWiki.config.get( 'wgScriptPath' ) + '/api.php?' + $.param( {
 63+ return mw.config.get( 'wgScriptPath' ) + '/api.php?' + $.param( {
6464 'action': 'clicktracking',
6565 'eventid': id,
66 - 'namespacenumber': mediaWiki.config.get( 'wgNamespaceNumber' ),
 66+ 'namespacenumber': mw.config.get( 'wgNamespaceNumber' ),
6767 'token': $.cookie( 'clicktracking-session' ),
6868 'redirectto': url
6969 } );
7070 }
 71+
7172 } )( jQuery );
Index: trunk/extensions/ClickTracking/modules/ext.UserBuckets.js
@@ -1,4 +1,4 @@
2 -
 2+// FIXME: Use jquery.json.js instead
33 var JSON;
44 if (!JSON) {
55 JSON = {};
@@ -48,8 +48,8 @@
4949
5050 $.setupActiveBuckets = function(){
5151 var buckets = $.getBuckets();
52 - for(iter in MW.activeCampaigns){
53 - var campaign = MW.activeCampaigns[iter];
 52+ for(iter in mw.activeCampaigns){
 53+ var campaign = mw.activeCampaigns[iter];
5454 // if bucket has been set, or bucket version is out of date,
5555 // set up a user bucket
5656 if(campaign.all){
Index: trunk/extensions/ClickTracking/modules/sampleCampaign.js
@@ -1,53 +1,54 @@
 2+/**
 3+ * Sample campaign for ClickTracking
 4+ */
25
3 -//checks
4 -if(typeof(MW) == "undefined"){ MW={};}
5 -if(!MW.activeCampaigns){ MW.activeCampaigns ={}; }
 6+// Check
 7+if ( !mw.activeCampaigns ) {
 8+ mw.activeCampaigns = {};
 9+}
610
7 -//define new active campaign
8 -MW.activeCampaigns.ArticleSave =
 11+// Define new active campaign
 12+mw.activeCampaigns.ArticleSave = {
 13+ // Treatment name
 14+ name: "ArticleSave",
915
10 -{
11 - //Treatment name
12 - "name": "ArticleSave",
13 -
14 - //Treatment version. Increment this when altering rates
15 - "version": 2,
16 -
17 - // Rates are calculated out of the total sum, so
18 - // rates of x:10000, y:3, and z:1 mean users have a
19 - // chance of being in bucket x at 10000/10004,
20 - // y at 3/10004 and z at 1/10004
21 - // The algorithm is faster if these are ordered in descending order,
22 - // particularly if there are orders of magnitude differences in the
23 - // bucket sizes
24 - // "none" is reserved for control
25 - "rates": {"none": 10000, "Bold": 3, "Italics": 1 },
26 -
27 - // individual changes, function names corresponding
28 - // to what is in "rates" object
29 - // (note: "none" function not needed or used)
30 -
31 - "Bold": function(){
32 - //change edit button to bold
33 - $j("#wpSave").css("font-weight", "bolder");
34 -
35 - },
36 - "Italics": function(){
37 - //change edit button to italics
38 - $j("#wpSave").css("font-weight", "normal")
39 - .css("font-style", "italic");
40 -
41 - },
42 -
43 - // "allActive" is reserved.
44 - // If this function exists, it will be apply to every user not in the "none" bucket
45 - "allActive": function(){
46 - //add click tracking to save
47 - $j("#wpSave").click(function(){ $j.trackAction('save'); });
48 - //add click tracking to preview
49 - $j("#wpPreview").click(function(){ $j.trackAction('preview'); });
50 - $j("#editpage-copywarn").click(function(){ $j.trackAction('copywarn'); });
51 -
52 - }
53 -
54 -};
\ No newline at end of file
 16+ // Treatment version. Increment this when altering rates
 17+ version: 2,
 18+
 19+ // Rates are calculated out of the total sum, so
 20+ // rates of x:10000, y:3, and z:1 mean users have a
 21+ // chance of being in bucket x at 10000/10004,
 22+ // y at 3/10004 and z at 1/10004
 23+ // The algorithm is faster if these are ordered in descending order,
 24+ // particularly if there are orders of magnitude differences in the
 25+ // bucket sizes
 26+ // "none" is reserved for control
 27+ rates: {
 28+ none: 10000,
 29+ Bold: 3,
 30+ Italics: 1
 31+ },
 32+
 33+ // Individual changes, function names corresponding
 34+ // to what is in "rates" object
 35+ // (note: "none" function not needed or used)
 36+ Bold: function(){
 37+ // Change edit button to bold
 38+ jQuery( '#wpSave' ).css( 'font-weight', 'bolder' );
 39+ },
 40+ Italics: function(){
 41+ // Change edit button to italics
 42+ jQuery( '#wpSave' ).css( { 'font-weight': 'normal', 'font-style': 'italic' });
 43+ },
 44+
 45+ // "allActive" is reserved.
 46+ // If this function exists, it will be apply to every user not in the "none" bucket
 47+ allActive: function(){
 48+ // Add click tracking to save
 49+ jQuery( '#wpSave' ).click(function(){ jQuery.trackAction( 'save' ); });
 50+ // Add click tracking to preview
 51+ jQuery( '#wpPreview' ).click(function(){ jQuery.trackAction( 'preview' ); });
 52+ jQuery( '#editpage-copywarn' ).click(function(){ jQuery.trackAction( 'copywarn' ); });
 53+ }
 54+
 55+};

Follow-up revisions

RevisionCommit summaryAuthorDate
r87054changing MW to mw as per r86976nimishg22:54, 27 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85049Simplified buckets, created a possible framework for user bucket campaignsnimishg21:40, 30 March 2011
r86961cross-browser funnimishg18:10, 26 April 2011

Status & tagging log