Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -228,10 +228,12 @@ |
229 | 229 | 'siiprop': 'url' |
230 | 230 | }; |
231 | 231 | |
232 | | - this.api.get( params, function( data ) { |
| 232 | + |
| 233 | + var ok = function( data ) { |
233 | 234 | if ( !data || !data.query || !data.query.stashimageinfo ) { |
234 | 235 | mw.log("mw.UploadWizardUpload::getThumbnail> No data? "); |
235 | 236 | callback( null ); |
| 237 | + return; |
236 | 238 | } |
237 | 239 | var thumbnails = data.query.stashimageinfo; |
238 | 240 | for ( var i = 0; i < thumbnails.length; i++ ) { |
— | — | @@ -239,6 +241,7 @@ |
240 | 242 | if ( ! ( thumb.thumburl && thumb.thumbwidth && thumb.thumbheight ) ) { |
241 | 243 | mw.log( "mw.UploadWizardUpload::getThumbnail> thumbnail missing information" ); |
242 | 244 | callback( null ); |
| 245 | + return; |
243 | 246 | } |
244 | 247 | var image = document.createElement( 'img' ); |
245 | 248 | $j( image ).load( function() { |
— | — | @@ -249,7 +252,14 @@ |
250 | 253 | image.src = thumb.thumburl; |
251 | 254 | _this.thumbnails[key] = image; |
252 | 255 | } |
253 | | - } ); |
| 256 | + }; |
| 257 | + |
| 258 | + var err = function( code, result ) { |
| 259 | + mw.log( 'mw.UploadWizardUpload::getThumbnail> error: ' + code, 'debug' ); |
| 260 | + callback( null ); |
| 261 | + }; |
| 262 | + |
| 263 | + this.api.get( params, { ok: ok, err: err } ); |
254 | 264 | } |
255 | 265 | }, |
256 | 266 | |
— | — | @@ -272,7 +282,7 @@ |
273 | 283 | } |
274 | 284 | |
275 | 285 | var callback = function( image ) { |
276 | | - if ( image == null ) { |
| 286 | + if ( image === null ) { |
277 | 287 | $j( selector ).addClass( 'mwe-upwiz-file-preview-broken' ); |
278 | 288 | _this.ui.setStatus( 'mwe-upwiz-thumbnail-failed' ); |
279 | 289 | } else { |