r65494 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65493‎ | r65494 | r65495 >
Date:21:00, 23 April 2010
Author:dale
Status:deferred
Tags:
Comment:
* fixed commons shared repository check
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -2692,23 +2692,21 @@
26932693 // First check the api for imagerepository
26942694 mw.getJSON( mw.getLocalApiUrl(), request, function( data ) {
26952695 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+ }
27082706 }
 2707+ // else page is found:
 2708+ mw.log( fileName + " found" );
 2709+ callback( data.query.pages[i] );
27092710 }
2710 - // else page is found:
2711 - mw.log( fileName + " found" );
2712 - callback( data.query.pages[i] );
27132711 }
27142712 }
27152713 } );

Status & tagging log