Index: trunk/extensions/ClickTracking/modules/ext.UserBuckets.js |
— | — | @@ -7,17 +7,17 @@ |
8 | 8 | ( function( $ ) { |
9 | 9 | //lazy-load |
10 | 10 | $.getBuckets = function (force){ |
11 | | - if (typeof(this.userBuckets) == 'undefined' || force ){ |
12 | | - this.userBuckets = $.parseJSON( $.cookie('userbuckets') ); |
| 11 | + if (typeof($.userBuckets) == 'undefined' || force ){ |
| 12 | + $.userBuckets = $.parseJSON( $.cookie('userbuckets') ); |
13 | 13 | } |
14 | | - return this.userBuckets; |
| 14 | + return $.userBuckets; |
15 | 15 | }; |
16 | 16 | |
17 | 17 | $.setBucket = function ( bucketName, bucketValue, bucketVersion ){ |
18 | 18 | var bucketCookies = $.getBuckets(); |
19 | 19 | if(!bucketCookies) { bucketCookies ={};} |
20 | 20 | bucketCookies[ bucketName ] = [ bucketValue, bucketVersion ]; |
21 | | - $.cookie('userbuckets', JSON.stringify( bucketCookies ) , { expires: 365 }); //expires in 1 year |
| 21 | + $j.cookie('userbuckets', JSON.stringify( bucketCookies ) , { expires: 365 }); //expires in 1 year |
22 | 22 | bucketCookies = $.getBuckets(true); //force it to rerun and update |
23 | 23 | }; |
24 | 24 | |
— | — | @@ -25,7 +25,6 @@ |
26 | 26 | var buckets = $.getBuckets(); |
27 | 27 | for(iter in MW.activeCampaigns){ |
28 | 28 | var campaign = MW.activeCampaigns[iter]; |
29 | | - |
30 | 29 | // if bucket has been set, or bucket version is out of date, |
31 | 30 | // set up a user bucket |
32 | 31 | if(!buckets || !buckets[campaign.name] || buckets[campaign.name][1] < campaign.version){ |
— | — | @@ -53,7 +52,7 @@ |
54 | 53 | } |
55 | 54 | |
56 | 55 | // do the actual code in the campaign based on the bucket |
57 | | - if($.getBuckets()[campaign.name][0] != "none"){ |
| 56 | + if($.getBuckets()[campaign.name] && $.getBuckets()[campaign.name][0] != "none"){ |
58 | 57 | campaign[$.getBuckets()[campaign.name][0]](); //function to execute |
59 | 58 | if(campaign.allActive){ |
60 | 59 | campaign.allActive(); |