Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php |
— | — | @@ -232,12 +232,14 @@ |
233 | 233 | public static function resourceLoaderGetConfigVars( &$vars ) { |
234 | 234 | global $wgArticleFeedbackSMaxage, |
235 | 235 | $wgArticleFeedbackCategories, |
| 236 | + $wgArticleFeedbackBlacklistCategories, |
236 | 237 | $wgArticleFeedbackLotteryOdds, |
237 | 238 | $wgArticleFeedbackTracking, |
238 | 239 | $wgArticleFeedbackOptions, |
239 | 240 | $wgArticleFeedbackNamespaces; |
240 | 241 | $vars['wgArticleFeedbackSMaxage'] = $wgArticleFeedbackSMaxage; |
241 | 242 | $vars['wgArticleFeedbackCategories'] = $wgArticleFeedbackCategories; |
| 243 | + $vars['wgArticleFeedbackBlacklistCategories'] = $wgArticleFeedbackBlacklistCategories; |
242 | 244 | $vars['wgArticleFeedbackLotteryOdds'] = $wgArticleFeedbackLotteryOdds; |
243 | 245 | $vars['wgArticleFeedbackTracking'] = $wgArticleFeedbackTracking; |
244 | 246 | $vars['wgArticleFeedbackOptions'] = $wgArticleFeedbackOptions; |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.startup.js |
— | — | @@ -16,29 +16,42 @@ |
17 | 17 | // Not viewing a redirect |
18 | 18 | && mw.util.getParamValue( 'redirect' ) != 'no' |
19 | 19 | ) { |
20 | | - var trackingBucket = mw.user.bucket( |
| 20 | + // Assign a tracking bucket using options from wgArticleFeedbackTracking |
| 21 | + mw.user.bucket( |
21 | 22 | 'ext.articleFeedback-tracking', mw.config.get( 'wgArticleFeedbackTracking' ) |
22 | 23 | ); |
23 | | - // Category activation |
24 | | - var articleFeedbackCategories = mw.config.get( 'wgArticleFeedbackCategories', [] ); |
25 | | - var articleCategories = mw.config.get( 'wgCategories', [] ); |
26 | | - var inCategory = false; |
27 | | - for ( var i = 0; i < articleCategories.length; i++ ) { |
28 | | - for ( var j = 0; j < articleFeedbackCategories.length; j++ ) { |
29 | | - if ( articleCategories[i] == articleFeedbackCategories[j] ) { |
30 | | - inCategory = true; |
31 | | - // Break 2 levels - could do this with a label, but eww. |
32 | | - i = articleCategories.length; |
33 | | - j = articleFeedbackCategories.length; |
34 | | - } |
| 24 | + |
| 25 | + // Collect categories for intersection tests |
| 26 | + var categories = { |
| 27 | + 'include': mw.config.get( 'wgArticleFeedbackCategories', [] ), |
| 28 | + 'exclude': mw.config.get( 'wgArticleFeedbackBlacklistCategories', [] ), |
| 29 | + 'current': mw.config.get( 'wgCategories', [] ) |
| 30 | + }; |
| 31 | + |
| 32 | + // Category exclusion |
| 33 | + var disable = false; |
| 34 | + for ( var i = 0; i < categories.current.length; i++ ) { |
| 35 | + if ( $.inArray( categories.current[i], categories.exclude ) > -1 ) { |
| 36 | + disable = true; |
| 37 | + break; |
35 | 38 | } |
36 | 39 | } |
37 | | - // Lottery activation |
| 40 | + |
| 41 | + // Category inclusion |
| 42 | + var enable = false; |
| 43 | + for ( var i = 0; i < categories.current.length; i++ ) { |
| 44 | + if ( $.inArray( categories.current[i], categories.include ) > -1 ) { |
| 45 | + enable = true; |
| 46 | + break; |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + // Lottery inclusion |
38 | 51 | var wonLottery = ( Number( mw.config.get( 'wgArticleId', 0 ) ) % 1000 ) |
39 | 52 | < Number( mw.config.get( 'wgArticleFeedbackLotteryOdds', 0 ) ) * 10; |
40 | | - |
| 53 | + |
41 | 54 | // Lazy loading |
42 | | - if ( wonLottery || inCategory ) { |
| 55 | + if ( !disable && ( wonLottery || enable ) ) { |
43 | 56 | mw.loader.load( 'ext.articleFeedback' ); |
44 | 57 | } |
45 | 58 | } |
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.php |
— | — | @@ -31,6 +31,9 @@ |
32 | 32 | // Extension is "disabled" if this field is an empty array (as per default configuration) |
33 | 33 | $wgArticleFeedbackCategories = array(); |
34 | 34 | |
| 35 | +// Which categories the pages must not belong to have the rating widget added (with _ in text) |
| 36 | +$wgArticleFeedbackBlacklistCategories = array(); |
| 37 | + |
35 | 38 | // Only load the module / enable the tool in these namespaces |
36 | 39 | // Default to $wgContentNamespaces (defaults to array( NS_MAIN ) ). |
37 | 40 | $wgArticleFeedbackNamespaces = $wgContentNamespaces; |