Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | "fogg-installed" : "Firefogg is Installed", |
12 | 12 | "fogg-for_improved_uplods" : "For Improved uploads: ", |
13 | 13 | "fogg-please_install" : "<a href=\"$1\">Install Firefogg</a>. More <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">about firefogg</a>", |
14 | | - "fogg-use_latest_fox" : "Please first install <a href=\"http://www.mozilla.com/en-US/firefox/upgrade.html?from=mv_embed\">Firefox 3.5</a>. <i>then revisit this page to install the <b>firefogg</b> extention</i>", |
| 14 | + "fogg-use_latest_fox" : "Please first install <a href=\"http://www.mozilla.com/en-US/firefox/upgrade.html?from=firefogg\">Firefox 3.5</a>. <i>then revisit this page to install the <b>firefogg</b> extention</i>", |
15 | 15 | "fogg-passthrough_mode" : "Your selected file is already ogg or not a video file", |
16 | 16 | "fogg-transcoding" : "Encoding Video to Ogg", |
17 | 17 | "fogg-encoding-done" : "Encoding Done" |
— | — | @@ -495,8 +495,7 @@ |
496 | 496 | _this.formData[ 'wpSourceType' ] = 'upload'; |
497 | 497 | _this.formData[ 'action' ] = 'submit'; |
498 | 498 | //wpUploadFile is set by firefogg |
499 | | - delete _this.formData[ 'wpUploadFile' ]; |
500 | | - |
| 499 | + delete _this.formData[ 'wpUploadFile' ]; |
501 | 500 | |
502 | 501 | _this.fogg.post( _this.editForm.action, 'wpUploadFile', JSON.stringify( _this.formData ) ); |
503 | 502 | //update upload status: |
— | — | @@ -515,7 +514,7 @@ |
516 | 515 | var uploadStatus = function(){ |
517 | 516 | //get the response text: |
518 | 517 | var response_text = _this.fogg.responseText; |
519 | | - if( !response_text){ |
| 518 | + if(!response_text){ |
520 | 519 | try{ |
521 | 520 | var pstatus = JSON.parse( _this.fogg.uploadstatus() ); |
522 | 521 | response_text = pstatus["responseText"]; |
— | — | @@ -527,16 +526,31 @@ |
528 | 527 | if( _this.oldResponseText != response_text){ |
529 | 528 | js_log('new result text:' + response_text + ' state:' + _this.fogg.state); |
530 | 529 | _this.oldResponseText = response_text; |
531 | | - //try and pare the response see if we need to take action: |
532 | | - } |
| 530 | + //try and parse the response text and check for errors |
| 531 | + try{ |
| 532 | + var apiResult = JSON.parse( response_text ); |
| 533 | + }catch(e){ |
| 534 | + js_log("could not parse response_text::" + response_text + ' ...for now try with eval...'); |
| 535 | + try{ |
| 536 | + var apiResult = eval( response_text ); |
| 537 | + }catch(e){ |
| 538 | + var apiResult = null; |
| 539 | + } |
| 540 | + } |
| 541 | + if(apiResult && _this.apiUpdateErrorCheck( apiResult ) === false){ |
| 542 | + //stop status update we have an error |
| 543 | + _this.fogg.cancel(); |
| 544 | + return false; |
| 545 | + } |
| 546 | + } |
533 | 547 | //update progress bar |
534 | 548 | _this.updateProgress( _this.fogg.progress() ); |
535 | 549 | |
536 | 550 | //loop to get new status if still uploading (could also be encoding if we are in chunk upload mode) |
537 | 551 | if( _this.fogg.state == 'encoding' || _this.fogg.state == 'uploading') { |
538 | 552 | setTimeout(uploadStatus, 100); |
539 | | - } |
540 | | - //check upload state |
| 553 | + |
| 554 | + }//check upload state |
541 | 555 | else if( _this.fogg.state == 'upload done' || |
542 | 556 | _this.fogg.state == 'done' || |
543 | 557 | _this.fogg.state == 'encoding done' ) { |
Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js |
— | — | @@ -31,6 +31,8 @@ |
32 | 32 | "ignorewarning" : "Ignore warning and save file anyway", |
33 | 33 | "file-thumbnail-no" : "The filename begins with <b><tt>$1</tt></b>", |
34 | 34 | "go-to-resource" : "Go to Resource Page", |
| 35 | + |
| 36 | + "wgfogg_waring_bad_extension" : "You have selected a file with an unsuported extension (<a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types\">more information</a>).", |
35 | 37 | |
36 | 38 | "cancel-button" : "Cancel", |
37 | 39 | "ok-button" : "OK" |
— | — | @@ -320,15 +322,16 @@ |
321 | 323 | } |
322 | 324 | uploadStatus(); |
323 | 325 | }, |
324 | | - processApiResult: function( apiRes ){ |
325 | | - var _this = this; |
326 | | - js_log('processApiResult::'); |
327 | | - //check for upload api error: |
328 | | - // {"upload":{"result":"Failure","error":"unknown-error","code":{"status":5,"filtered":"NGC2207%2BIC2163.jpg"}}} |
| 326 | + apiUpdateErrorCheck:function( apiRes ){ |
| 327 | + var _this = this; |
329 | 328 | if( apiRes.error || ( apiRes.upload && apiRes.upload.result == "Failure" ) ){ |
330 | | - |
| 329 | + //gennerate the error button: |
| 330 | + var bObj = {}; |
| 331 | + bObj[ gM('return-to-form') ] = function(){ |
| 332 | + $j(this).dialog('close'); |
| 333 | + }; |
331 | 334 | //check a few places for the error code: |
332 | | - var error_code=0; |
| 335 | + var error_code=0; |
333 | 336 | if( apiRes.error && apiRes.error.code ){ |
334 | 337 | error_code = apiRes.error.code; |
335 | 338 | }else if( apiRes.upload.code ){ |
— | — | @@ -337,7 +340,7 @@ |
338 | 341 | error_code = apiRes.upload.code[0]; |
339 | 342 | } |
340 | 343 | if(apiRes.upload.code['status']){ |
341 | | - error_code = apiRes.upload['status']; |
| 344 | + error_code = apiRes.upload.code['status']; |
342 | 345 | } |
343 | 346 | }else{ |
344 | 347 | apiRes.upload.code; |
— | — | @@ -352,68 +355,44 @@ |
353 | 356 | if(!error_code || error_code == 'unknown-error'){ |
354 | 357 | if(typeof JSON != 'undefined'){ |
355 | 358 | js_log('Error: apiRes: ' + JSON.stringify( apiRes) ); |
356 | | - } |
357 | | - var bObj = {}; |
358 | | - bObj[ gM('return-to-form') ] = function(){ |
359 | | - $j(this).dialog('close'); |
360 | | - }; |
| 359 | + } |
| 360 | + js_log('should update win::'); |
361 | 361 | _this.updateProgressWin( gM('uploaderror'), gM('unknown-error') + '<br>' + error_msg, bObj); |
362 | | - return ; |
| 362 | + return false; |
363 | 363 | }else{ |
364 | | - if( apiRes.error.info ){ |
| 364 | + if(apiRes.error && apiRes.error.info ){ |
365 | 365 | _this.updateProgressWin( gM('uploaderror'), apiRes.error.info ,bObj); |
366 | | - return ; |
| 366 | + return false; |
367 | 367 | }else{ |
368 | | - gMsgLoadRemote(error_code, function(){ |
369 | | - js_log('send msg: ' + gM( error_code )); |
370 | | - var bObj = {}; |
371 | | - bObj[gM('return-to-form')] = function(){ |
372 | | - $(this).dialog('close'); |
373 | | - }; |
374 | | - _this.updateProgressWin( gM('uploaderror'), gM( error_code ),bObj); |
375 | | - }); |
376 | | - js_log("api.erorr"); |
377 | | - return ; |
| 368 | + if(typeof error_code == 'number'){ |
| 369 | + if(apiRes.upload.code.finalExt){ |
| 370 | + _this.updateProgressWin( gM('uploaderror'), gM('wgfogg_waring_bad_extension',apiRes.upload.code.finalExt) , bObj); |
| 371 | + }else{ |
| 372 | + _this.updateProgressWin( gM('uploaderror'), gM('unknown-error') + ' : ' + error_code, bObj); |
| 373 | + } |
| 374 | + }else{ |
| 375 | + gMsgLoadRemote(error_code, function(){ |
| 376 | + js_log('send msg: ' + gM( error_code )); |
| 377 | + var bObj = {}; |
| 378 | + bObj[gM('return-to-form')] = function(){ |
| 379 | + $(this).dialog('close'); |
| 380 | + }; |
| 381 | + _this.updateProgressWin( gM('uploaderror'), gM( error_code ),bObj); |
| 382 | + }); |
| 383 | + js_log("api.erorr"); |
| 384 | + } |
| 385 | + return false; |
378 | 386 | } |
379 | 387 | } |
380 | | - } |
381 | | - //check for upload_session key for async upload: |
382 | | - if( apiRes.upload && apiRes.upload.upload_session_key ){ |
383 | | - //set the session key |
384 | | - _this.upload_session_key = apiRes.upload.upload_session_key; |
385 | | - |
386 | | - //do ajax upload status: |
387 | | - _this.doAjaxUploadStatus(); |
388 | | - js_log("set upload_session_key: " + _this.upload_session_key); |
389 | | - return ; |
390 | | - } |
391 | | - |
392 | | - if( apiRes.upload.imageinfo && apiRes.upload.imageinfo.descriptionurl ){ |
393 | | - var url = apiRes.upload.imageinfo.descriptionurl; |
394 | | - //check done action: |
395 | | - if(_this.done_upload_cb){ |
396 | | - //close up shop: |
397 | | - $j('#upProgressDialog').dialog('close'); |
398 | | - //call the callback: |
399 | | - _this.done_upload_cb( url ); |
400 | | - }else{ |
401 | | - var bObj = {}; |
402 | | - bObj[ gM('go-to-resource') ] = function(){ |
403 | | - window.location = url; |
404 | | - }; |
405 | | - _this.updateProgressWin( gM('successfulupload'), gM( 'mv_upload_done', url), bObj); |
406 | | - js_log('apiRes.upload.imageinfo::'+url); |
407 | | - } |
408 | | - return ; |
409 | | - } |
410 | | - |
411 | | - //check for upload error: |
| 388 | + } |
| 389 | + //check for upload.error type erros. |
412 | 390 | if( apiRes.upload && apiRes.upload.error){ |
413 | 391 | js_log(' apiRes.upload.error: ' + apiRes.upload.error ); |
414 | | - return ; |
| 392 | + _this.updateProgressWin( gM('uploaderror'), gM('unknown-error') + '<br>', bObj); |
| 393 | + return false; |
415 | 394 | } |
416 | 395 | //check for known warnings: |
417 | | - if( apiRes.upload.warnings ){ |
| 396 | + if(apiRes.upload && apiRes.upload.warnings ){ |
418 | 397 | //debugger; |
419 | 398 | var wmsg = '<ul>'; |
420 | 399 | for(var wtype in apiRes.upload.warnings){ |
— | — | @@ -449,17 +428,49 @@ |
450 | 429 | _this.updateProgressWin( gM('uploadwarning'), '<h3>' + gM('uploadwarning') + '</h3>' +msg + '<p>',bObj); |
451 | 430 | return false; |
452 | 431 | } |
453 | | - |
454 | | - //nothing fits assume unkown error: |
455 | | - js_log('could not parse upload api request result'); |
456 | | - var return_to_form_msg = gM('return-to-form'); |
457 | | - var bObj = {}; |
458 | | - bObj[ gM('return-to-form')] = function(){ |
459 | | - $(this).dialog('close'); |
460 | | - }; |
461 | | - _this.updateProgressWin( gM('uploaderror'), gM('unknown-error'),bObj); |
462 | | - return false; |
| 432 | + //should be "OK" |
| 433 | + return true; |
463 | 434 | }, |
| 435 | + processApiResult: function( apiRes ){ |
| 436 | + var _this = this; |
| 437 | + js_log('processApiResult::'); |
| 438 | + //check for upload api error: |
| 439 | + // {"upload":{"result":"Failure","error":"unknown-error","code":{"status":5,"filtered":"NGC2207%2BIC2163.jpg"}}} |
| 440 | + if( _this.apiUpdateErrorCheck(apiRes) === false){ |
| 441 | + //error returned false (updated and |
| 442 | + return false; |
| 443 | + }else{ |
| 444 | + //check for upload_session key for async upload: |
| 445 | + if( apiRes.upload && apiRes.upload.upload_session_key ){ |
| 446 | + //set the session key |
| 447 | + _this.upload_session_key = apiRes.upload.upload_session_key; |
| 448 | + |
| 449 | + //do ajax upload status: |
| 450 | + _this.doAjaxUploadStatus(); |
| 451 | + js_log("set upload_session_key: " + _this.upload_session_key); |
| 452 | + return ; |
| 453 | + } |
| 454 | + |
| 455 | + if( apiRes.upload.imageinfo && apiRes.upload.imageinfo.descriptionurl ){ |
| 456 | + var url = apiRes.upload.imageinfo.descriptionurl; |
| 457 | + //check done action: |
| 458 | + if(_this.done_upload_cb){ |
| 459 | + //close up shop: |
| 460 | + $j('#upProgressDialog').dialog('close'); |
| 461 | + //call the callback: |
| 462 | + _this.done_upload_cb( url ); |
| 463 | + }else{ |
| 464 | + var bObj = {}; |
| 465 | + bObj[ gM('go-to-resource') ] = function(){ |
| 466 | + window.location = url; |
| 467 | + }; |
| 468 | + _this.updateProgressWin( gM('successfulupload'), gM( 'mv_upload_done', url), bObj); |
| 469 | + js_log('apiRes.upload.imageinfo::'+url); |
| 470 | + } |
| 471 | + return ; |
| 472 | + } |
| 473 | + } |
| 474 | + }, |
464 | 475 | updateProgressWin:function(title_txt, msg, buttons){ |
465 | 476 | var _this = this; |
466 | 477 | if(!title_txt) |
— | — | @@ -473,10 +484,10 @@ |
474 | 485 | }else{ |
475 | 486 | //@@todo should convice the jquery ui people to not use object keys as user msg's |
476 | 487 | var bObj = {}; |
477 | | - bObj[ gM('ok-button') ] = function(){ |
| 488 | + bObj[ gM('ok-button') ] = function(){ |
478 | 489 | $j(this).dialog('close'); |
479 | | - }; |
480 | | - $j('#upProgressDialog').dialog('option','buttons', bObj); |
| 490 | + }; |
| 491 | + $j('#upProgressDialog').dialog('option','buttons', bObj); |
481 | 492 | } |
482 | 493 | }, |
483 | 494 | getProgressTitle:function(){ |
Index: branches/new-upload/phase3/js2/mwEmbed/libSequencer/mvPlayList.js |
— | — | @@ -1208,11 +1208,12 @@ |
1209 | 1209 | }else{ |
1210 | 1210 | this[method]=videoInterface[method]; |
1211 | 1211 | } |
1212 | | - } |
| 1212 | + } |
1213 | 1213 | //string -> boolean: |
1214 | 1214 | if(this[method]=="false")this[method]=false; |
1215 | 1215 | if(this[method]=="true")this[method]=true; |
1216 | | - } |
| 1216 | + } |
| 1217 | + debugger; |
1217 | 1218 | }, |
1218 | 1219 | onClipDone:function(){ |
1219 | 1220 | js_log('pl onClipDone (should go to next)'); |
Index: branches/new-upload/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -275,8 +275,10 @@ |
276 | 276 | }else if(typeof msgSet == 'string'){ |
277 | 277 | ammessages += msgSet; |
278 | 278 | } |
279 | | - if(ammessages=='') |
280 | | - return js_log('gMsgLoadRemote::no msg set requested'); |
| 279 | + if(ammessages=''){ |
| 280 | + js_log('gMsgLoadRemote::no msg set requested'); |
| 281 | + return false; |
| 282 | + } |
281 | 283 | |
282 | 284 | do_api_req({ |
283 | 285 | 'data':{'meta':'allmessages', 'ammessages':ammessages} |
— | — | @@ -762,10 +764,10 @@ |
763 | 765 | loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
764 | 766 | loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css' ); |
765 | 767 | //load all the req libs: |
766 | | - mvJsLoader.jQueryCheck(function(){ |
| 768 | + mvJsLoader.jQueryCheck(function(){ |
767 | 769 | //load with staged dependeinces (for ie and safari that don't execute in order) |
768 | 770 | mvJsLoader.doLoadDepMode([ |
769 | | - ['remoteSearchDriver', |
| 771 | + [ 'remoteSearchDriver', |
770 | 772 | '$j.cookie', |
771 | 773 | '$j.ui' |
772 | 774 | ],[ |
Index: branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js |
— | — | @@ -325,11 +325,11 @@ |
326 | 326 | $j('#' + embedObj.id).get(0).play(); |
327 | 327 | }); |
328 | 328 | |
329 | | - //add recomend firefox if non-native playback: |
| 329 | + //add recomend firefox if non-native playback: |
330 | 330 | if( embedObj.doNativeWarningCheck() ){ |
331 | 331 | $j('#dc_'+ embedObj.id).hover( |
332 | 332 | function(){ |
333 | | - if($j('gnp_' + embedObj.id).length==0){ |
| 333 | + if($j('#gnp_' + embedObj.id).length==0){ |
334 | 334 | $j(this).append('<div id="gnp_' + embedObj.id + '" class="ui-state-highlight ui-corner-all" ' + |
335 | 335 | 'style="position:absolute;display:none;background:#FFF;top:10px;left:10px;right:10px;height:60px;">' + |
336 | 336 | gM('mv_for_best_experience') + |