Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -2692,23 +2692,21 @@ |
2693 | 2693 | // First check the api for imagerepository |
2694 | 2694 | mw.getJSON( mw.getLocalApiUrl(), request, function( data ) { |
2695 | 2695 | if ( data.query.pages ) { |
2696 | | - for ( var i in data.query.pages ) { |
2697 | | - if( i == '-1' ) { |
2698 | | - callback( false ); |
2699 | | - return ; |
2700 | | - } |
2701 | | - for ( var j in data.query.pages[i] ) { |
2702 | | - if ( j == 'missing' |
2703 | | - && data.query.pages[i].imagerepository != 'shared' |
2704 | | - && data.query.pages[i].imagerepository != 'commons' ) |
2705 | | - { |
2706 | | - callback( false ); |
2707 | | - return; |
| 2696 | + for ( var i in data.query.pages ) { |
| 2697 | + if( i != 'undefined' ){ |
| 2698 | + //If assset is missing check if is shared or on commons |
| 2699 | + if( data.query.pages[i]['missing'] || i == -1 ) { |
| 2700 | + if( data.query.pages[i].imagerepository != 'shared' |
| 2701 | + && data.query.pages[i].imagerepository != 'commons' ) |
| 2702 | + { |
| 2703 | + callback( false ); |
| 2704 | + return; |
| 2705 | + } |
2708 | 2706 | } |
| 2707 | + // else page is found: |
| 2708 | + mw.log( fileName + " found" ); |
| 2709 | + callback( data.query.pages[i] ); |
2709 | 2710 | } |
2710 | | - // else page is found: |
2711 | | - mw.log( fileName + " found" ); |
2712 | | - callback( data.query.pages[i] ); |
2713 | 2711 | } |
2714 | 2712 | } |
2715 | 2713 | } ); |