Index: trunk/extensions/CentralNotice/newCentralNotice.js |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | for( var i = 0; i < bannerList.length; i++ ) { |
62 | 62 | w += bannerList[i].weight; |
63 | 63 | // when the weight tally exceeds the random integer, return the banner and stop the loop |
64 | | - if( w < pointer ) { |
| 64 | + if( w > pointer ) { |
65 | 65 | selectedBanner = bannerList[i]; |
66 | 66 | break; |
67 | 67 | } |
Index: trunk/extensions/CentralNotice/SpecialBannerListLoader.php |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | $this->project = $wgRequest->getText( 'project', 'wikipedia' ); |
36 | 36 | |
37 | 37 | // Get location from the query string |
38 | | - $this->location = $wgRequest->getText( 'location' ); |
| 38 | + $this->location = $wgRequest->getText( 'country' ); |
39 | 39 | |
40 | 40 | if ( $this->project && $this->language ) { |
41 | 41 | $content = $this->getJsonList(); |
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -1004,11 +1004,6 @@ |
1005 | 1005 | * @return A 2D array of running banners with associated weights and settings |
1006 | 1006 | */ |
1007 | 1007 | static function selectNoticeTemplates( $project, $language, $location = null ) { |
1008 | | - |
1009 | | - // Normalize location parameter (should be an uppercase 2-letter country code) |
1010 | | - preg_match( '/[a-zA-Z][a-zA-Z]/', $location, $matches ); |
1011 | | - $location = strtoupper( $matches[0] ); |
1012 | | - |
1013 | 1008 | $campaigns = array(); |
1014 | 1009 | $dbr = wfGetDB( DB_SLAVE ); |
1015 | 1010 | $encTimestamp = $dbr->addQuotes( $dbr->timestamp() ); |
— | — | @@ -1037,6 +1032,11 @@ |
1038 | 1033 | $campaigns[] = $row->not_id; |
1039 | 1034 | } |
1040 | 1035 | if ( $location ) { |
| 1036 | + |
| 1037 | + // Normalize location parameter (should be an uppercase 2-letter country code) |
| 1038 | + preg_match( '/[a-zA-Z][a-zA-Z]/', $location, $matches ); |
| 1039 | + $location = strtoupper( $matches[0] ); |
| 1040 | + |
1041 | 1041 | // Pull geotargeted campaigns |
1042 | 1042 | $campaignResults2 = $dbr->select( |
1043 | 1043 | array( |
Index: trunk/extensions/CentralNotice/SpecialBannerController.php |
— | — | @@ -64,10 +64,14 @@ |
65 | 65 | } |
66 | 66 | }); |
67 | 67 | }, |
68 | | - 'loadBannerList': function( timestamp ) { |
| 68 | + 'loadBannerList': function( geoOverride ) { |
69 | 69 | var bannerListURL; |
70 | | - var geoLocation = Geo.country; // pull the geo info |
71 | | - var bannerListPage = 'Special:BannerListLoader?language='+wgContentLanguage+'&project='+wgNoticeProject+'&location='+geoLocation; |
| 70 | + if ( geoOverride ) { |
| 71 | + var geoLocation = geoOverride; // override the geo info |
| 72 | + } else { |
| 73 | + var geoLocation = Geo.country; // pull the geo info |
| 74 | + } |
| 75 | + var bannerListPage = 'Special:BannerListLoader?language='+wgContentLanguage+'&project='+wgNoticeProject+'&country='+geoLocation; |
72 | 76 | bannerListURL = wgArticlePath.replace( '$1', bannerListPage ); |
73 | 77 | var request = $.ajax( { |
74 | 78 | url: bannerListURL, |
— | — | @@ -96,7 +100,7 @@ |
97 | 101 | for( var i = 0; i < bannerList.length; i++ ) { |
98 | 102 | w += bannerList[i].weight; |
99 | 103 | // when the weight tally exceeds the random integer, return the banner and stop the loop |
100 | | - if( w < pointer ) { |
| 104 | + if( w > pointer ) { |
101 | 105 | selectedBanner = bannerList[i]; |
102 | 106 | break; |
103 | 107 | } |
— | — | @@ -129,7 +133,7 @@ |
130 | 134 | $.centralNotice.fn.loadBanner( $.centralNotice.data.getVars['cnbanner'] ); |
131 | 135 | } else { |
132 | 136 | // Look for banners ready to go NOW |
133 | | - $.centralNotice.fn.loadBannerList( ); |
| 137 | + $.centralNotice.fn.loadBannerList( $.centralNotice.data.getVars['country'] ); |
134 | 138 | } |
135 | 139 | } ); //document ready |
136 | 140 | } )( jQuery ); |