Index: trunk/extensions/UploadWizard/resources/mw.Api.category.js |
— | — | @@ -42,18 +42,20 @@ |
43 | 43 | */ |
44 | 44 | getCategoriesByPrefix: function( prefix, callback, err ) { |
45 | 45 | |
| 46 | + // fetch with allpages to only get categories that have a corresponding description page. |
46 | 47 | var params = { |
47 | | - 'list': 'allcategories', |
48 | | - 'acprefix': prefix |
| 48 | + 'list': 'allpages', |
| 49 | + 'apprefix': prefix, |
| 50 | + 'apnamespace': mw.config.get('wgNamespaceIds').category |
49 | 51 | }; |
50 | 52 | |
51 | 53 | var ok = function( data ) { |
52 | 54 | var texts = []; |
53 | | - if ( data.query && data.query.allcategories ) { |
| 55 | + if ( data.query && data.query.allpages ) { |
54 | 56 | // API returns an array of objects like |
55 | | - // allcategories: [ {'*':'foo'}, {'*':'bar'} ] |
56 | | - $.each( data.query.allcategories, function( i, category ) { |
57 | | - texts.push( category['*'] ); |
| 57 | + // allpages: [ {'*':'foo'}, {'*':'bar'} ] |
| 58 | + $.each( data.query.allpages, function( i, category ) { |
| 59 | + texts.push( category.title.substr(9) ); // the substr removes Category: from the title. |
58 | 60 | } ); |
59 | 61 | } |
60 | 62 | callback( texts ); |