With formatversion=2 the JSON response uses UTF-8 instead of escape sequences
with hex for encoding of non-ASCII characters (e.g. "\u00e4" for "รค").
The processing of the response is adapted to the new format.
Change-Id: I2fc0a696a8aa4486c497ac25763f8e4ece671a26
return;
}
this.currentRequest = this.api.get( {
return;
}
this.currentRequest = this.api.get( {
action: 'query',
prop: [ 'info' ],
titles: titles
} ).done( function ( response ) {
action: 'query',
prop: [ 'info' ],
titles: titles
} ).done( function ( response ) {
- var index, curr, title;
- for ( index in response.query.pages ) {
- curr = response.query.pages[ index ];
- title = new ForeignTitle( curr.title ).getPrefixedText();
- this.existenceCache[ title ] = curr.missing === undefined;
+ $.each( response.query.pages, function ( index, page ) {
+ var title = new ForeignTitle( page.title ).getPrefixedText();
+ this.existenceCache[ title ] = !page.missing;
queue[ title ].resolve( this.existenceCache[ title ] );
queue[ title ].resolve( this.existenceCache[ title ] );
switch ( searchType ) {
case CategorySelector.SearchType.OpenSearch:
this.api.get( {
switch ( searchType ) {
case CategorySelector.SearchType.OpenSearch:
this.api.get( {
action: 'opensearch',
namespace: NS_CATEGORY,
limit: this.limit,
action: 'opensearch',
namespace: NS_CATEGORY,
limit: this.limit,
case CategorySelector.SearchType.InternalSearch:
this.api.get( {
case CategorySelector.SearchType.InternalSearch:
this.api.get( {
action: 'query',
list: 'allpages',
apnamespace: NS_CATEGORY,
action: 'query',
list: 'allpages',
apnamespace: NS_CATEGORY,
action: 'query',
prop: 'info',
titles: 'Category:' + input
} ).done( function ( res ) {
action: 'query',
prop: 'info',
titles: 'Category:' + input
} ).done( function ( res ) {
- var page,
- categories = [];
- for ( page in res.query.pages ) {
- if ( parseInt( page, 10 ) > -1 ) {
- categories.push( res.query.pages[ page ].title );
+ $.each( res.query.pages, function ( index, page ) {
+ if ( !page.missing ) {
+ categories.push( page.title );
deferred.resolve( categories );
} ).fail( deferred.reject.bind( deferred ) );
deferred.resolve( categories );
} ).fail( deferred.reject.bind( deferred ) );
action: 'query',
list: 'categorymembers',
cmtype: 'subcat',
action: 'query',
list: 'categorymembers',
cmtype: 'subcat',
action: 'query',
prop: 'categories',
cllimit: this.limit,
titles: 'Category:' + input
} ).done( function ( res ) {
action: 'query',
prop: 'categories',
cllimit: this.limit,
titles: 'Category:' + input
} ).done( function ( res ) {
- var page,
- categories = [];
- for ( page in res.query.pages ) {
- if ( parseInt( page, 10 ) > -1 ) {
- if ( $.isArray( res.query.pages[ page ].categories ) ) {
- categories.push.apply( categories, res.query.pages[ page ].categories.map( function ( category ) {
+ $.each( res.query.pages, function ( index, page ) {
+ if ( !page.missing ) {
+ if ( $.isArray( page.categories ) ) {
+ categories.push.apply( categories, page.categories.map( function ( category ) {
return category.title;
} ) );
}
}
return category.title;
} ) );
}
}
deferred.resolve( categories );
} ).fail( deferred.reject.bind( deferred ) );
deferred.resolve( categories );
} ).fail( deferred.reject.bind( deferred ) );