Index: branches/new-upload/phase3/js2/mwEmbed/libClipEdit/mvClipEdit.js |
— | — | @@ -574,10 +574,11 @@ |
575 | 575 | js_log('add_adjust_hooks: ' + mvd_id ); |
576 | 576 | //if options are unset populate functions: |
577 | 577 | //add mouse over end time frame highlight |
578 | | - $j('#mv_end_hr_'+mvd_id).hoverIntent({interval:200,over:function(){ |
579 | | - //js_log('pre style: ' + $j(this).css('border')); |
580 | | - $j(this).css('border','solid red'); |
581 | | - do_video_time_update( $j('#mv_end_hr_'+mvd_id).val(), $j('#mv_end_hr_'+mvd_id).val() ); |
| 578 | + $j('#mv_end_hr_'+mvd_id).hoverIntent( { interval : 200, |
| 579 | + over:function(){ |
| 580 | + //js_log('pre style: ' + $j(this).css('border')); |
| 581 | + $j(this).css('border','solid red'); |
| 582 | + do_video_time_update( $j('#mv_end_hr_'+mvd_id).val(), $j('#mv_end_hr_'+mvd_id).val() ); |
582 | 583 | },out:function(){ |
583 | 584 | $j(this).css('border','solid black thin'); |
584 | 585 | do_video_time_update($j('#mv_start_hr_'+mvd_id).val(), $j('#mv_end_hr_'+mvd_id).val() ); |
Index: branches/new-upload/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php |
— | — | @@ -51,8 +51,8 @@ |
52 | 52 | |
53 | 53 | //libAddMedia: |
54 | 54 | $wgJSAutoloadLocalClasses['mvFirefogg'] = $wgMwEmbedDirectory . 'libAddMedia/mvFirefogg.js'; |
55 | | - $wgJSAutoloadLocalClasses['mvAdvFirefogg'] = $wgMwEmbedDirectory . 'libAddMedia/mvAdvFirefogg.js'; |
56 | | - $wgJSAutoloadLocalClasses['mvUploader'] = $wgMwEmbedDirectory . 'libAddMedia/mvUploader.js'; |
| 55 | + $wgJSAutoloadLocalClasses['mvAdvFirefogg'] = $wgMwEmbedDirectory . 'libAddMedia/mvAdvFirefogg.js'; |
| 56 | + |
57 | 57 | $wgJSAutoloadLocalClasses['remoteSearchDriver'] = $wgMwEmbedDirectory . 'libAddMedia/remoteSearchDriver.js'; |
58 | 58 | $wgJSAutoloadLocalClasses['seqRemoteSearchDriver'] = $wgMwEmbedDirectory . 'libAddMedia/seqRemoteSearchDriver.js'; |
59 | 59 | $wgJSAutoloadLocalClasses['baseRemoteSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/baseRemoteSearch.js'; |
Index: branches/new-upload/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -248,7 +248,9 @@ |
249 | 249 | ctime:0, |
250 | 250 | load_error:false,//load error flag (false by default) |
251 | 251 | load_time:0, |
252 | | - callbacks:new Array(), |
| 252 | + callbacks:new Array(), |
| 253 | + cur_path: null, |
| 254 | + missing_path : null, |
253 | 255 | doLoad:function(libs, callback){ |
254 | 256 | this.ctime++; |
255 | 257 | if(libs){ //setup this.libs: |
— | — | @@ -295,11 +297,11 @@ |
296 | 298 | this.callbacks.push(callback); |
297 | 299 | } |
298 | 300 | if( this.checkLoading() ){ |
299 | | - if( this.load_time++ > 3000){ //time out after ~30seconds |
300 | | - js_error( gM('error_load_lib') + this.cur_path ); |
301 | | - this.load_error=true; |
| 301 | + if( this.load_time++ > 4000){ //time out after ~80seconds |
| 302 | + js_error( gM('error_load_lib') + this.missing_path ); |
| 303 | + this.load_error=true; |
302 | 304 | }else{ |
303 | | - setTimeout( 'mvJsLoader.doLoad()', 10 ); |
| 305 | + setTimeout( 'mvJsLoader.doLoad()', 20 ); |
304 | 306 | } |
305 | 307 | }else{ |
306 | 308 | //js_log('checkLoading passed run callbacks'); |
— | — | @@ -346,6 +348,7 @@ |
347 | 349 | cur_path = (cur_path=='')?cur_path+objPath[p]:cur_path+'.'+objPath[p]; |
348 | 350 | eval( 'var ptest = typeof ( '+ cur_path + ' ); '); |
349 | 351 | if( ptest == 'undefined'){ |
| 352 | + this.missing_path = cur_path; |
350 | 353 | return false; |
351 | 354 | } |
352 | 355 | } |
— | — | @@ -366,6 +369,8 @@ |
367 | 370 | cache: true |
368 | 371 | }); |
369 | 372 | js_log('jquery loaded'); |
| 373 | + //setup mvEmbed jquery bindigns: |
| 374 | + mv_jqueryBindings(); |
370 | 375 | //run the callback |
371 | 376 | if(callback){ |
372 | 377 | callback(); |
— | — | @@ -541,7 +546,7 @@ |
542 | 547 | } |
543 | 548 | |
544 | 549 | /* init remote search */ |
545 | | -function mv_do_remote_search(initObj){ |
| 550 | +function mv_do_remote_search( initObj ){ |
546 | 551 | js_log(':::::mv_do_remote_search::::'); |
547 | 552 | |
548 | 553 | //issue a load skin request: |
— | — | @@ -559,7 +564,64 @@ |
560 | 565 | }); |
561 | 566 | }); |
562 | 567 | } |
563 | | - |
| 568 | + |
| 569 | +/* |
| 570 | + * stores all the mwEmbed jQuery specific bindings |
| 571 | + * (setup after jQuery is avaliable) |
| 572 | + * lets you call rewrites in a jquery "way" |
| 573 | + * |
| 574 | + * @@todo eventually we should refactor mwCode over to jQuery style plugins |
| 575 | + * ( but for now mv_embed.js will bridge this gap ) |
| 576 | + */ |
| 577 | +function mv_jqueryBindings(){ |
| 578 | + js_log('mv_jqueryBindings'); |
| 579 | + (function($) { |
| 580 | + |
| 581 | + $.fn.firefogg = function( initObj, callback ) { |
| 582 | + //set "selector" in the initObj |
| 583 | + |
| 584 | + // @@todo should refactor mvAdvFirefogg as jQuery plugin |
| 585 | + initObj['selector'] = this.selector; |
| 586 | + |
| 587 | + loadSet = { |
| 588 | + 'mvBaseUploadInterface' : 'libAddMedia/mvBaseUploadInterface.js', |
| 589 | + 'mvFirefogg' : 'libAddMedia/mvFirefogg.js' |
| 590 | + }; |
| 591 | + |
| 592 | + //see if we need to load the advanced firefog controls and associated ui components: |
| 593 | + $j(this.selector).each(function(){ |
| 594 | + if( this.tagName.toLowerCase() != 'input' ){ |
| 595 | + initObj.form_rewrite = false; |
| 596 | + //if not an input tag (we probably want to load the full encoder interface) |
| 597 | + if( typeof initObj.encoder_interface == 'undefined' ) |
| 598 | + initObj.encoder_interface = true; |
| 599 | + } |
| 600 | + }); |
| 601 | + if( initObj.encoder_interface ){ |
| 602 | + //@@todo would be nice to have a "dependency" map we could use/ |
| 603 | + loadSet['mvAdvFirefogg'] = 'libAddMedia/mvAdvFirefogg.js'; |
| 604 | + loadSet['$j.cookie'] = 'jquery/jquery.ui-1.7.1/external/cookie/jquery.cookie.js'; |
| 605 | + loadSet['$j.ui'] = 'jquery/jquery.ui-1.7.1/ui/ui.core.js'; |
| 606 | + loadSet['$j.ui.accordion'] = 'jquery/jquery.ui-1.7.1/ui/ui.accordion.js'; |
| 607 | + loadSet['$j.ui.slider'] = 'jquery/jquery.ui-1.7.1/ui/ui.slider.js'; |
| 608 | + } |
| 609 | + //make sure we have everything loaded that we need: |
| 610 | + mvJsLoader.doLoad( loadSet, function(){ |
| 611 | + js_log('firefogg libs loaded. target select:' + initObj.selector); |
| 612 | + //select interface provicer based on if we want to include the encoder interface or not: |
| 613 | + if(initObj.encoder_interface){ |
| 614 | + var myFogg = new mvAdvFirefogg( initObj ); |
| 615 | + }else{ |
| 616 | + var myFogg = new mvFirefogg( initObj ); |
| 617 | + } |
| 618 | + if(myFogg) |
| 619 | + myFogg.doRewrite( callback ); |
| 620 | + }); |
| 621 | + } |
| 622 | + |
| 623 | + })(jQuery); |
| 624 | +} |
| 625 | + |
564 | 626 | /* init the sequencer */ |
565 | 627 | function mv_do_sequence(initObj){ |
566 | 628 | //debugger; |
Index: branches/new-upload/phase3/js2/mwEmbed/jsScriptLoader.php |
— | — | @@ -125,9 +125,10 @@ |
126 | 126 | global $wgRequest, $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgStyleVersion; |
127 | 127 | |
128 | 128 | //set debug flag: |
129 | | - if( (isset($_GET['debug']) && $_GET['debug']=='true') && (isset($wgEnableScriptDebug) && $wgEnableScriptDebug==true )){ |
| 129 | + if( (isset($_GET['debug']) && $_GET['debug']=='true') || (isset($wgEnableScriptDebug) && $wgEnableScriptDebug==true )){ |
130 | 130 | $this->debug = true; |
131 | 131 | } |
| 132 | + |
132 | 133 | //set the urid: |
133 | 134 | if( isset( $_GET['urid'] ) && $_GET['urid'] !=''){ |
134 | 135 | $this->urid = htmlspecialchars( $_GET['urid'] ); |
Index: branches/new-upload/phase3/js2/mwEmbed/example_usage/Make_Ogg.html |
— | — | @@ -2,133 +2,38 @@ |
3 | 3 | <html><head> |
4 | 4 | <meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
5 | 5 | <title>Firefogg - Make Ogg Video in your Browser</title> |
6 | | - <script type="text/javascript" src="../jsScriptLoader.php?class=mv_embed"></script> |
| 6 | + <!-- <script type="text/javascript" src="../jsScriptLoader.php?class=mv_embed&urid=da&debug=true"></script> --> |
| 7 | + <script type="text/javascript" src="../mv_embed.js"></script> |
7 | 8 | <style type="text/css" media="all">@import "http://www.firefogg.org/css/style.css";</style> |
8 | 9 | <style type="text/css" media="all"> |
9 | 10 | .install{ |
10 | 11 | display:none; |
11 | 12 | } |
| 13 | +input{ |
| 14 | +font-size:150%; |
| 15 | +} |
12 | 16 | </style> |
13 | 17 | <script type="text/javascript"> |
14 | 18 | mwAddOnloadHook(function(){ |
15 | | - $j('#check_install').hide(); |
16 | | - $j('.install').hide(); |
17 | | - if(!($j.browser.mozilla && $j.browser.version >= '1.9.1')) { |
18 | | - $j('#use_firefox').show(); |
19 | | - }else { |
20 | | - if(typeof(Firefogg) != 'undefined' && Firefogg().version >= '0.9.5') { |
21 | | - $j('#installed').show(); |
22 | | - setupFirefogg(); |
23 | | - } else { |
24 | | - if(navigator.oscpu && navigator.oscpu.search('Linux') >= 0) |
25 | | - $j('#install_linux').show(); |
26 | | - else if(navigator.oscpu && navigator.oscpu.search('Mac') >= 0) |
27 | | - $j('#install_macosx').show(); |
28 | | - else if(navigator.oscpu && navigator.oscpu.search('Win') >= 0) |
29 | | - $j('#install_win32').show(); |
30 | | - } |
31 | | - } |
32 | | -}); |
33 | | - |
34 | | -//sets up the local settings for the encode (restored from a cookie if you have them) |
35 | | -function setupSettings( force ){ |
36 | | - if(!force){ |
37 | | - if($.cookie('firefogg_settings')){ |
38 | | - firefogg_settings = JSON.parse( $.cookie('firefogg_settings') ); |
39 | | - } |
40 | | - } |
41 | | - for(var i in firefogg_defaults){ |
42 | | - if( firefogg_defaults[i]['d'] ){ |
43 | | - firefogg_settings[i] = firefogg_defaults[i]['d']; |
44 | | - } |
45 | | - } |
46 | | - setValuesInHtml(); |
47 | | -} |
48 | | -function setValuesInHtml(){ |
49 | | - //set the actual HTML: |
50 | | - $.each(firefogg_settings, function(inx, val){ |
51 | | - if($j('#_'+inx).length !=0){ |
52 | | - $j('#_'+inx).val( val ); |
53 | | - } |
54 | | - }) |
55 | | -} |
56 | | -function saveSettings(){ |
57 | | - $.cookie('firefogg_settings', JSON.stringify( firefogg_settings ) ); |
58 | | -} |
59 | | - |
60 | | -function setupFirefogg(){ |
61 | | - //get all the libraries we will need (should be single scriptLoader request |
62 | | - //(unless you loaded mv_embed.js without php in which case lots of js load requests:) |
63 | | - mvJsLoader.doLoad({ |
64 | | - 'mvUploader' : 'libAddMedia/mvUploader.js', |
65 | | - 'mvFirefogg' : 'libAddMedia/mvFirefogg.js', |
66 | | - 'mvAdvFirefogg' : 'libAddMedia/mvAdvFirefogg.js', |
67 | | - '$j.cookie' : 'jquery/jquery.ui-1.7.1/external/jquery.cookie.js', |
68 | | - '$j.ui' : 'jquery/jquery.ui-1.7.1/ui/ui.core.js', |
69 | | - '$j.ui.accordion' : 'jquery/jquery.ui-1.7.1/ui/ui.accordion.js', |
70 | | - '$j.ui.slider' : 'jquery/jquery.ui-1.7.1/ui/ui.slider.js' |
71 | | - },function(){ |
72 | | - //do setupSettings: |
73 | | - //for all options see /* iniObj in mvAdvFirefogg.js */ |
74 | | - mvAdvFirefogg = new mvAdvFirefogg({ |
75 | | - //set up the targets: |
76 | | - 'btn_select_file' : '#select_file', |
77 | | - 'btn_select_new_file' : '#select_new_file', |
78 | | - 'btn_save_local_file' : '#save_local_file', |
79 | | - //the control container (where we put all the controls) |
80 | | - 'control_container' : '#control_container' |
81 | | - }); |
| 19 | + $j('#control_container').firefogg({ |
| 20 | + 'encoder_interface' : false, |
| 21 | + 'encode_local' : true |
82 | 22 | }); |
83 | | -} |
| 23 | +}); |
84 | 24 | </script> |
85 | 25 | </head><body> |
86 | 26 | <div id="main"> |
87 | 27 | <h1><a href="http://www.firefogg.org/index.html"><img |
88 | 28 | src="http://www.firefogg.org/png/firefogg.png" alt="Firefogg"></a><br> |
89 | 29 | Make Ogg Video</h1> |
90 | | -<br> |
| 30 | +<br><br><br> |
91 | 31 | <center> |
92 | | -<table width="500" border="0"> |
93 | | -<tr> |
94 | | -<td colspan="2" > |
95 | | - <div id="check_install"><center>Checking for Firefogg<blink>...</blink></center></div> |
96 | | - <div id="install_linux" class="install"> |
97 | | - <a href="linux/Firefogg-0.9.5.xpi">Install Firefogg</a> |
98 | | -</div> |
99 | | -<div id="install_macosx" class="install"> |
100 | | - <a href="macosx/Firefogg-0.9.5.xpi">Install Firefogg</a> |
101 | | -</div> |
102 | | -<div id="install_win32" class="install"> |
103 | | - <a href="win32/Firefogg-0.9.5.xpi">Install Firefogg</a> |
104 | | -</div> |
105 | | -<div id="installed" class="install" style="background:#FFF"> |
106 | | - <a href="http://firefogg.org">Firefogg</a> installed. </a> |
107 | | -</div> |
108 | | -<div id="use_firefox" class="install"> |
109 | | - You need <a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 3.5</a><br>to use this extension. |
110 | | -</div> |
111 | | - |
112 | | -</td> |
113 | | -</tr> |
114 | | -<tr> |
115 | | -<td> |
116 | | - |
117 | | -<input style="font-size:150%" id="select_file" type="button" value="Select File" disabled="true"> |
118 | | -<input style="font-size:150%;display:none" id="save_local_file" type="button" value="Save Ogg File" > |
119 | | -<input style="font-size:150%;display:none" id="select_new_file" type="button" value="Select New File" > |
120 | | - |
121 | | -</td> |
122 | | -<td id="file_info"> |
123 | | -</td> |
124 | | -</tr> |
125 | | -<tr> |
126 | | -<td colspan="2" style="display:none" id="fogg_control_td" > |
127 | | - <div style="height:400px" id="control_container"></div> |
128 | | -<br><br> |
129 | | -<span style="font:size:80%">Built using <a href="http://firefogg.org">firefogg</a> & <a href="http://jqueryui.com/">jquery.ui</a> Supports |
130 | | -<a href="javascript:(function(){if%20(!/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){alert('Sorry,%20due%20to%20security%20restrictions,%20this%20tool%20only%20works%20in%20Firefox');%20return%20false;%20};%20if(window.jquitr){%20jquitr.addThemeRoller();%20}%20else{%20jquitr%20=%20{};%20jquitr.s%20=%20document.createElement('script');%20jquitr.s.src%20=%20'http://jqueryui.com/themeroller/developertool/developertool.js.php';%20document.getElementsByTagName('head')[0].appendChild(jquitr.s);}%20})();">custom themes</a>, <b>remix me</b> |
131 | | -</td> |
132 | | -</tr> |
133 | | -</table> |
134 | | - <h2></h2> |
| 32 | + <div style="width:500px"> |
| 33 | + <div style="float:left;height:400px" id="control_container"></div> |
| 34 | + <br><br> |
| 35 | + <!-- <span style="font:size:80%">Built using <a href="http://firefogg.org">firefogg</a> & <a href="http://jqueryui.com/">jquery.ui</a> Supports |
| 36 | + <a href="javascript:(function(){if%20(!/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){alert('Sorry,%20due%20to%20security%20restrictions,%20this%20tool%20only%20works%20in%20Firefox');%20return%20false;%20};%20if(window.jquitr){%20jquitr.addThemeRoller();%20}%20else{%20jquitr%20=%20{};%20jquitr.s%20=%20document.createElement('script');%20jquitr.s.src%20=%20'http://jqueryui.com/themeroller/developertool/developertool.js.php';%20document.getElementsByTagName('head')[0].appendChild(jquitr.s);}%20})();">custom themes</a>, <b>remix me</b> |
| 37 | + </span> --> |
| 38 | + </div> |
| 39 | +</center> |
135 | 40 | </body></html> |
Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/mvUploader.js |
— | — | @@ -1,684 +0,0 @@ |
2 | | -/* the upload javascript |
3 | | -presently does hackery to work with Special:Upload page... |
4 | | -will be replaced with upload API once that is ready |
5 | | -*/ |
6 | | - |
7 | | -loadGM({ |
8 | | - "upload-enable-converter" : "Enable video converter (to upload source video not yet converted to theora format) <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>", |
9 | | - "upload-fogg_not_installed": "If you want to upload video consider installing <a href=\"http://firefogg.org\">firefogg.org</a>, <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>", |
10 | | - "upload-transcode-in-progress":"Doing Transcode & Upload (do not close this window)", |
11 | | - "upload-in-progress": "Upload in Progress (do not close this window)", |
12 | | - "upload-transcoded-status": "Transcoded", |
13 | | - "uploaded-status": "Uploaded", |
14 | | - "upload-select-file": "Select File...", |
15 | | - "wgfogg_wrong_version": "You have firefogg installed but its outdated, <a href=\"http://firefogg.org\">please upgrade</a> ", |
16 | | - "wgfogg_waring_ogg_upload": "You have selected an ogg file for conversion to ogg (this is probably unnessesary). Maybe disable the video converter?", |
17 | | - "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 help</a>", |
18 | | - "upload-stats-fileprogres": "$1 of $2", |
19 | | - |
20 | | - "mv_upload_done" : "Your upload <i>should be</i> accessible <a href=\"$1\">here</a>", |
21 | | - "upload-unknown-size": "Unknown size", |
22 | | - |
23 | | - "successfulupload" : "Successful upload", |
24 | | - "uploaderror" : "Upload error", |
25 | | - "uploadwarning": "Upload warning", |
26 | | - "unknown-error": "Unknown Error", |
27 | | - "return-to-form": "Return to form", |
28 | | - |
29 | | - "file-exists-duplicate" : "This file is a duplicate of the following file", |
30 | | - "fileexists" : "A file with this name exists already, please check <b><tt>$1</tt></b> if you are not sure if you want to change it.", |
31 | | - "fileexists-thumb": "<center><b>Existing file</b></center>", |
32 | | - "ignorewarning" : "Ignore warning and save file anyway", |
33 | | - "file-thumbnail-no" : "The filename begins with <b><tt>$1</tt></b>" |
34 | | -}); |
35 | | - |
36 | | -var default_upload_options = { |
37 | | - 'target_div':'', |
38 | | - 'upload_done_action':'redirect', |
39 | | - 'api_url':false |
40 | | -} |
41 | | - |
42 | | -var mvUploader = function(initObj){ |
43 | | - return this.init( initObj ); |
44 | | -} |
45 | | -mvUploader.prototype = { |
46 | | - init:function( iObj ){ |
47 | | - var _this = this; |
48 | | - js_log('init uploader'); |
49 | | - if(!iObj) |
50 | | - iObj = {}; |
51 | | - for(var i in default_upload_options){ |
52 | | - if(iObj[i]){ |
53 | | - this[i] = iObj[i]; |
54 | | - }else{ |
55 | | - this[i] = default_upload_options[i]; |
56 | | - } |
57 | | - } |
58 | | - //check if we are on the uplaod page: |
59 | | - this.on_upload_page = ( wgPageName== "Special:Upload")?true:false; |
60 | | - js_log('f:mvUploader: onuppage:' + this.on_upload_page); |
61 | | - //grab firefogg.js: |
62 | | - mvJsLoader.doLoad({ |
63 | | - 'mvFirefogg' : 'libAddMedia/mvFirefogg.js' |
64 | | - },function(){ |
65 | | - //if we are not on the upload page grab the upload html via ajax: |
66 | | - //@@todo refactor with |
67 | | - if( !_this.on_upload_page){ |
68 | | - $j.get(wgArticlePath.replace(/\$1/, 'Special:Upload'), {}, function(data){ |
69 | | - //add upload.js: |
70 | | - $j.getScript( stylepath + '/common/upload.js', function(){ |
71 | | - //really _really_ need an "upload api"! |
72 | | - wgAjaxUploadDestCheck = true; |
73 | | - wgAjaxLicensePreview = false; |
74 | | - wgUploadAutoFill = true; |
75 | | - //strip out inline scripts: |
76 | | - sp = data.indexOf('<div id="content">'); |
77 | | - se = data.indexOf('<!-- end content -->'); |
78 | | - if(sp!=-1 && se !=-1){ |
79 | | - result_data = data.substr(sp, (se-sp) ).replace('/\<script\s.*?\<\/script\>/gi',' '); |
80 | | - js_log("trying to set: " + result_data ); |
81 | | - //$j('#'+_this.target_div).html( result_data ); |
82 | | - } |
83 | | - _this.setupFirefogg(); |
84 | | - }); |
85 | | - }); |
86 | | - }else{ |
87 | | - //@@could check if firefogg is enabled here: |
88 | | - _this.setupFirefogg(); |
89 | | - //if only want httpUploadFrom help enable it here: |
90 | | - } |
91 | | - } |
92 | | - ); |
93 | | - }, |
94 | | - /** |
95 | | - * setupBaseUpInterface supports intefaces for progress indication if the browser supports it |
96 | | - * also sets up ajax progress updates for http posts |
97 | | - * //pre |
98 | | - */ |
99 | | - setupBaseUpInterface:function(){ |
100 | | - //check if this feature is not false (we want it on by default (null) instances that don't have the upload api or any modifications) |
101 | | - this.upForm = new mvBaseUploadInterface( { |
102 | | - 'api_url' : this.api_url, |
103 | | - 'parent_uploader': this |
104 | | - } |
105 | | - ); |
106 | | - this.upForm.setupForm(); |
107 | | - }, |
108 | | - setupFirefogg:function(){ |
109 | | - var _this = this; |
110 | | - //add firefogg html if not already there: ( same as $wgEnableFirebug added in SpecialUpload.php ) |
111 | | - if( $j('#fogg-video-file').length==0 ){ |
112 | | - js_log('add addFirefoggHtml'); |
113 | | - _this.addFirefoggHtml(); |
114 | | - }else{ |
115 | | - js_log('firefogg already init:'); |
116 | | - } |
117 | | - //set up the upload_done action |
118 | | - //redirect if we are on the upload page |
119 | | - //do a callback if in called from gui) |
120 | | - var intFirefoggObj = ( this.on_upload_page )? |
121 | | - {'upload_done_action':'redirect'}: |
122 | | - {'upload_done_action':function( rTitle ){ |
123 | | - js_log( 'add_done_action callback for uploader' ); |
124 | | - //call the parent insert resource preview |
125 | | - _this.upload_done_action( rTitle ); |
126 | | - } |
127 | | - }; |
128 | | - |
129 | | - if( _this.api_url ) |
130 | | - intFirefoggObj['api_url'] = _this.api_url; |
131 | | - |
132 | | - js_log('new mvFirefogg extends mvUploader (this)'); |
133 | | - this.fogg = new mvFirefogg( intFirefoggObj ); |
134 | | - this.fogg.setupForm(); |
135 | | - }, |
136 | | - //same add code as specialUpload if($wgEnableFirefogg){ |
137 | | - addFirefoggHtml:function(){ |
138 | | - var itd_html = $j('#mw-upload-table .mw-input:first').html(); |
139 | | - $j('#mw-upload-table .mw-input').eq(0).html('<div id="wg-base-upload">' + itd_html + '</div>'); |
140 | | - //add in firefogg control |
141 | | - $j('#wg-base-upload').after('<p id="fogg-enable-item" >' + |
142 | | - '<input style="display:none" id="fogg-video-file" name="fogg-video-file" type="button" value="' + gM('upload-select-file') + '">' + |
143 | | - "<span id='wgfogg_not_installed'>" + |
144 | | - gM('upload-fogg_not_installed') + |
145 | | - "</span>" + |
146 | | - "<span class='error' id='wgfogg_wrong_version' style='display:none;'><br>" + |
147 | | - gM('wgfogg_wrong_version') + |
148 | | - "<br>" + |
149 | | - "</span>" + |
150 | | - "<span class='error' id='wgfogg_waring_ogg_upload' style='display:none;'><br>"+ |
151 | | - gM('wgfogg_waring_ogg_upload') + |
152 | | - "<br>" + |
153 | | - "</span>" + |
154 | | - "<span class='error' id='wgfogg_waring_bad_extension' style='display:none;'><br>"+ |
155 | | - gM('wgfogg_waring_bad_extension') + |
156 | | - "<br>" + |
157 | | - "</span>" + |
158 | | - "<span id='wgfogg_installed' style='display:none' >"+ |
159 | | - '<input id="wgEnableFirefogg" type="checkbox" name="wgEnableFirefogg" >' + |
160 | | - gM('upload-enable-converter') + |
161 | | - '</span><br></p>'); |
162 | | - }, |
163 | | - /** |
164 | | - * doDestCheck checks the destination |
165 | | - * @@todo we should be able to configure its "targets" via parent config |
166 | | - */ |
167 | | - doDestCheck:function(){ |
168 | | - var _this = this; |
169 | | - $j('#wpDestFile-warning').empty(); |
170 | | - //show loading |
171 | | - $j('#wpDestFile').after('<img id = "mw-spinner-wpDestFile" src ="'+ stylepath + '/common/images/spinner.gif" />'); |
172 | | - //try and get a thumb of the current file (check its destination) |
173 | | - do_api_req({ |
174 | | - 'data':{ |
175 | | - 'titles': 'File:' + $j('#wpDestFile').val(),//@@todo we may need a more clever way to get a the filename |
176 | | - 'prop': 'imageinfo', |
177 | | - 'iiprop':'url|mime|size', |
178 | | - 'iiurlwidth': 150 |
179 | | - }, |
180 | | - 'url': _this.api_url |
181 | | - },function(data){ |
182 | | - $j('#mw-spinner-wpDestFile').remove(); |
183 | | - if(data && data.query && data.query.pages){ |
184 | | - if( data.query.pages[-1] ){ |
185 | | - //all good no file there |
186 | | - }else{ |
187 | | - for(var page_id in data.query.pages){ |
188 | | - if( data.query.normalized){ |
189 | | - var ntitle = data.query.normalized[0].to; |
190 | | - }else{ |
191 | | - var ntitle = data.query.pages[ page_id ].title; |
192 | | - } |
193 | | - var img = data.query.pages[ page_id ].imageinfo[0]; |
194 | | - $j('#wpDestFile-warning').html( |
195 | | - '<ul>' + |
196 | | - '<li>'+ |
197 | | - gM('fileexists', ntitle) + |
198 | | - '</li>'+ |
199 | | - '<div class="thumb tright">' + |
200 | | - '<div style="width: ' + ( parseInt(img.thumbwidth)+2 ) + 'px;" class="thumbinner">' + |
201 | | - '<a title="' + ntitle + '" class="image" href="' + img.descriptionurl + '">' + |
202 | | - '<img width="' + img.thumbwidth + '" height="' + img.thumbheight + '" border="0" class="thumbimage" ' + |
203 | | - 'src="' + img.thumburl + '"' + |
204 | | - ' alt="' + ntitle + '"/>' + |
205 | | - '</a>' + |
206 | | - '<div class="thumbcaption">' + |
207 | | - '<div class="magnify">' + |
208 | | - '<a title="' + gM('thumbnail-more') + '" class="internal" ' + |
209 | | - 'href="' + img.descriptionurl +'"><img width="15" height="11" alt="" ' + |
210 | | - 'src="' + stylepath +"/>" + |
211 | | - '</a>'+ |
212 | | - '</div>'+ |
213 | | - gM('fileexists-thumb') + |
214 | | - '</div>' + |
215 | | - '</div>'+ |
216 | | - '</div>' + |
217 | | - '</ul>' |
218 | | - ); |
219 | | - } |
220 | | - } |
221 | | - } |
222 | | - }); |
223 | | - }, |
224 | | - /** |
225 | | - * doDestinationFill fills in a destination file-name based on a source asset name. |
226 | | - * @@todo we should be able to configure its "targets" via parent config |
227 | | - */ |
228 | | - doDestinationFill:function( targetElm ){ |
229 | | - js_log("doDestinationFill") |
230 | | - //remove any previously flagged errors |
231 | | - $j('#mw-upload-permitted,#mw-upload-prohibited').hide(); |
232 | | - |
233 | | - var path = $j(targetElm).val(); |
234 | | - // Find trailing part |
235 | | - var slash = path.lastIndexOf('/'); |
236 | | - var backslash = path.lastIndexOf('\\'); |
237 | | - var fname; |
238 | | - if (slash == -1 && backslash == -1) { |
239 | | - fname = path; |
240 | | - } else if (slash > backslash) { |
241 | | - fname = path.substring(slash+1, 10000); |
242 | | - } else { |
243 | | - fname = path.substring(backslash+1, 10000); |
244 | | - } |
245 | | - //urls are less likely to have a usefull extension don't include them in the extention check |
246 | | - if( wgFileExtensions && $j(targetElm).attr('id') != 'wpUploadFileURL' ){ |
247 | | - var found = false; |
248 | | - if( fname.lastIndexOf('.')!=-1 ){ |
249 | | - var ext = fname.substr( fname.lastIndexOf('.')+1 ); |
250 | | - for(var i=0; i < wgFileExtensions.length; i++){ |
251 | | - if( wgFileExtensions[i].toLowerCase() == ext.toLowerCase() ) |
252 | | - found = true; |
253 | | - } |
254 | | - } |
255 | | - if(!found){ |
256 | | - //clear the upload set mw-upload-permitted to error |
257 | | - $j(targetElm).val(''); |
258 | | - $j('#mw-upload-permitted,#mw-upload-prohibited').show().addClass('error'); |
259 | | - //clear the wpDestFile as well: |
260 | | - $j('#wpDestFile').val(''); |
261 | | - return false; |
262 | | - } |
263 | | - } |
264 | | - // Capitalise first letter and replace spaces by underscores |
265 | | - fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_'); |
266 | | - // Output result |
267 | | - $j('#wpDestFile').val( fname ); |
268 | | - |
269 | | - //do a destination check |
270 | | - this.doDestCheck(); |
271 | | - } |
272 | | -} |
273 | | -/** |
274 | | - * the base Upload Interface extended via firefogg |
275 | | - */ |
276 | | -var default_bui_options = { |
277 | | - 'api_url':null, |
278 | | - 'parent_uploader':null |
279 | | -} |
280 | | -var mvBaseUploadInterface = function( iObj ){ |
281 | | - return this.init( iObj ); |
282 | | -} |
283 | | -mvBaseUploadInterface.prototype = { |
284 | | - parent_uploader:false, |
285 | | - formData:{}, //the form to be submitted |
286 | | - upload_mode:'autodetect', //can be 'post', 'chunks' or autodetect. (autodetect issues an api call) |
287 | | - warnings_sessionkey:null, |
288 | | - chunks_supported:false, |
289 | | - form_post_override:false, |
290 | | - init: function( iObj ){ |
291 | | - if(!iObj) |
292 | | - iObj = {}; |
293 | | - //inherit iObj properties: |
294 | | - for(var i in default_bui_options){ |
295 | | - if(iObj[i]){ |
296 | | - this[i] = iObj[i]; |
297 | | - }else{ |
298 | | - this[i] = default_bui_options[i]; |
299 | | - } |
300 | | - } |
301 | | - }, |
302 | | - setupForm:function(){ |
303 | | - var _this = this; |
304 | | - //set up the local pointer to the edit form: |
305 | | - _this.getEditForm(); |
306 | | - |
307 | | - if(_this.editForm){ |
308 | | - //set up the org_onsubmit if not set: |
309 | | - if( typeof( _this.org_onsubmit ) == 'undefined' ) |
310 | | - _this.org_onsubmit = _this.editForm.onsubmit; |
311 | | - |
312 | | - //have to define the onsubmit function inline or its hard to pass the "_this" instance |
313 | | - _this.editForm.onsubmit = function(){ |
314 | | - //run the original onsubmit (if not run yet set flag to avoid excessive chaining ) |
315 | | - if( typeof( _this.org_onsubmit ) == 'function' ){ |
316 | | - if( ! _this.org_onsubmit() ){ |
317 | | - //error in org submit return false; |
318 | | - return false; |
319 | | - } |
320 | | - } |
321 | | - //check for post action override: |
322 | | - if( _this.form_post_override ){ |
323 | | - //alert('woudld submit here'); |
324 | | - return true; |
325 | | - } |
326 | | - //get the input form data in flat json: |
327 | | - var tmpAryData = $j( _this.editForm ).serializeArray(); |
328 | | - for(var i=0; i < tmpAryData.length; i++){ |
329 | | - if( tmpAryData[i]['name'] ) |
330 | | - _this.formData[ tmpAryData[i]['name'] ] = tmpAryData[i]['value']; |
331 | | - } |
332 | | - //put into a try catch so we are sure to return false: |
333 | | - try{ |
334 | | - //get a clean loader: |
335 | | - _this.dispProgressOverlay(); |
336 | | - |
337 | | - //for some unknown reason we have to drop down the #p-search z-index: |
338 | | - $j('#p-search').css('z-index', 1); |
339 | | - |
340 | | - //select upload mode: |
341 | | - _this.detectUploadMode(); |
342 | | - }catch(e){} |
343 | | - |
344 | | - //don't submit the form we will do the post in ajax |
345 | | - return false; |
346 | | - }; |
347 | | - } |
348 | | - |
349 | | - }, |
350 | | - detectUploadMode:function( callback ){ |
351 | | - var _this = this; |
352 | | - js_log('detectUploadMode::' + _this.upload_mode + ' api:' + _this.api_url); |
353 | | - //check the upload mode: |
354 | | - if( _this.upload_mode == 'autodetect' ){ |
355 | | - if( ! _this.api_url ) |
356 | | - return js_error( 'Error: can\'t autodetect mode without api url' ); |
357 | | - do_api_req( { |
358 | | - 'data':{ 'action':'paraminfo','modules':'upload' }, |
359 | | - 'url' :_this.api_url |
360 | | - }, function(data){ |
361 | | - if( typeof data.paraminfo == 'undefined' || typeof data.paraminfo.modules == 'undefined' ) |
362 | | - return js_error( 'Error: bad api results' ); |
363 | | - if( typeof data.paraminfo.modules[0].classname == 'undefined'){ |
364 | | - js_log( 'Autodetect Upload Mode: \'post\' '); |
365 | | - _this.upload_mode = 'post'; |
366 | | - }else{ |
367 | | - js_log( 'Autodetect Upload Mode: api ' ); |
368 | | - _this.upload_mode = 'api'; |
369 | | - //check to see if chunks are supported: |
370 | | - for( var i in data.paraminfo.modules[0].parameters ){ |
371 | | - var pname = data.paraminfo.modules[0].parameters[i].name; |
372 | | - if( pname == 'enablechunks' ){ |
373 | | - js_log( 'this.chunks_supported = true' ); |
374 | | - _this.chunks_supported = true; |
375 | | - break; |
376 | | - } |
377 | | - } |
378 | | - } |
379 | | - _this.doUploadSwitch(); |
380 | | - }); |
381 | | - }else{ |
382 | | - _this.doUploadSwitch(); |
383 | | - } |
384 | | - }, |
385 | | - doUploadSwitch:function(){ |
386 | | - |
387 | | - js_log('mvUPload:doUploadSwitch()'); |
388 | | - var _this = this; |
389 | | - //issue a normal post request |
390 | | - if( _this.upload_mode == 'post' || $j('#wpSourceTypeFile').get(0).checked ){ |
391 | | - js_log('do normal submit form'); |
392 | | - //update the status |
393 | | - _this.updateEmptyLoadingStatus(); |
394 | | - |
395 | | - //do normal post upload no status indicators (also since its a file I think we have to submit the form) |
396 | | - _this.form_post_override = true; |
397 | | - |
398 | | - //trick the browser into thinking the wpUpload button was pressed (there might be a cleaner way to do this) |
399 | | - $j(_this.editForm).append('<input type="hidden" name="wpUpload" value="' + $j('#wpUpload').val() + '"/>'); |
400 | | - |
401 | | - //@@todo support firefox 3.0 ajax file upload progress |
402 | | - //http://igstan.blogspot.com/2009/01/pure-javascript-file-upload.html |
403 | | - |
404 | | - //do the submit : |
405 | | - _this.editForm.submit(); |
406 | | - return true; |
407 | | - }else if( _this.upload_mode == 'api' && $j('#wpSourceTypeURL').get(0).checked){ |
408 | | - js_log('doHttpUpload (no form submit) '); |
409 | | - //if the api is supported.. && source type is http do upload with http status updates |
410 | | - _this.doHttpUpload(); |
411 | | - }else{ |
412 | | - js_error( 'Error: unrecongized upload mode: ' + _this.upload_mode ); |
413 | | - } |
414 | | - return false; |
415 | | - }, |
416 | | - doHttpUpload:function(){ |
417 | | - var _this = this; |
418 | | - //set the http box to loading (in case we don't get an update for some time) |
419 | | - $j('#dlbox-centered').html( '<h5>' + _this.getProgressTitle() + '</h5>' + |
420 | | - mv_get_loading_img( 'left:40%;top:20%') |
421 | | - ); |
422 | | - //build the api query: |
423 | | - do_api_req({ |
424 | | - 'data':{ |
425 | | - 'action' : 'upload', |
426 | | - 'url' : $j('#wpUploadFileURL').val(), |
427 | | - 'filename' : $j('#wpDestFile').val(), |
428 | | - 'comment' : $j('#wpUploadDescription').val(), |
429 | | - 'asyncdownload': true |
430 | | - }, |
431 | | - 'url' : _this.api_url |
432 | | - }, function( data ){ |
433 | | - _this.processApiResult( data ); |
434 | | - }); |
435 | | - }, |
436 | | - doAjaxWarningIgnore:function(){ |
437 | | - var _this = this; |
438 | | - if( !_this.upload_session_key ) |
439 | | - return js_error('missing upload_session_key (can\'t ignore warnigns'); |
440 | | - //do the ignore warnings submit to the api: |
441 | | - do_api_req({ |
442 | | - 'data':{ |
443 | | - 'ignorewarnings' : 'true', |
444 | | - 'sessionkey' :!_this.upload_session_key |
445 | | - }, |
446 | | - 'url': _this.api_url |
447 | | - },function(data){ |
448 | | - _this.processApiResult(data); |
449 | | - }); |
450 | | - }, |
451 | | - doAjaxUploadStatus:function() { |
452 | | - var _this = this; |
453 | | - |
454 | | - //set up the progress display for status updates: |
455 | | - _this.dispProgressOverlay(); |
456 | | - |
457 | | - var uploadStatus = function(){ |
458 | | - //do the api request: |
459 | | - do_api_req({ |
460 | | - 'data':{ |
461 | | - 'action' : 'upload', |
462 | | - 'httpstatus' : 'true', |
463 | | - 'sessionkey' : _this.upload_session_key |
464 | | - }, |
465 | | - 'url' : _this.api_url |
466 | | - }, function( data ){ |
467 | | - //@@check if we are done |
468 | | - if( data.upload['apiUploadResult'] ){ |
469 | | - //update status to 100% |
470 | | - _this.updateProgress( 1 ); |
471 | | - if(typeof JSON == 'undefined'){ |
472 | | - //we need to load the jQuery json parser: (older browsers don't have JSON.parse |
473 | | - mvJsLoader.doLoad({ |
474 | | - '$j.secureEvalJSON':'jquery/plugins/jquery.json-1.3.js' |
475 | | - },function(){ |
476 | | - var apiResult = $j.secureEvalJSON( data.upload['apiUploadResult'] ); |
477 | | - _this.processApiResult( apiResult ); |
478 | | - }); |
479 | | - }else{ |
480 | | - var apiResult = {}; |
481 | | - try{ |
482 | | - apiResult = JSON.parse ( data.upload['apiUploadResult'] ) ; |
483 | | - }catch (e){ |
484 | | - //could not parse api result |
485 | | - js_log('errro: could not parse apiUploadResult ') |
486 | | - } |
487 | | - _this.processApiResult( apiResult ); |
488 | | - } |
489 | | - return ; |
490 | | - } |
491 | | - |
492 | | - //@@ else update status: |
493 | | - if( data.upload['content_length'] && data.upload['loaded'] ){ |
494 | | - //we have content length we can show percentage done: |
495 | | - var perc = data.upload['loaded'] / data.upload['content_length']; |
496 | | - //update the status: |
497 | | - _this.updateProgress( perc ); |
498 | | - //special case update the file progress where we have data size: |
499 | | - $j('#upload-stats-fileprogres').html( |
500 | | - gM('upload-stats-fileprogres', [ |
501 | | - formatSize( data.upload['loaded'] ), |
502 | | - formatSize( data.upload['content_length'] ) |
503 | | - ] |
504 | | - ) |
505 | | - ); |
506 | | - }else if( data.upload['loaded'] ){ |
507 | | - //for lack of content-length requests: |
508 | | - $j('#upload-stats-fileprogres').html( |
509 | | - gM('upload-stats-fileprogres', [ |
510 | | - formatSize( data.upload['loaded'] ), |
511 | | - gM('upload-unknown-size') |
512 | | - ] |
513 | | - ) |
514 | | - ); |
515 | | - } |
516 | | - //(we got a result) set it to 100ms + your server update interval (in our case 2s) |
517 | | - setTimeout(uploadStatus, 2100); |
518 | | - }); |
519 | | - } |
520 | | - uploadStatus(); |
521 | | - }, |
522 | | - processApiResult: function( apiRes ){ |
523 | | - var _this = this; |
524 | | - |
525 | | - //check for upload api error: |
526 | | - // {"upload":{"result":"Failure","error":"unknown-error","code":{"status":5,"filtered":"NGC2207%2BIC2163.jpg"}}} |
527 | | - if( apiRes.error || ( apiRes.upload && apiRes.upload.result == "Failure" ) ){ |
528 | | - |
529 | | - //check a few places for the error code: |
530 | | - var error_code=0; |
531 | | - if( apiRes.error && apiRes.error.code ){ |
532 | | - error_code = apiRes.error.code; |
533 | | - }else if( apiRes.upload.code ){ |
534 | | - if(typeof apiRes.upload.code == 'object'){ |
535 | | - if(apiRes.upload.code[0]){ |
536 | | - error_code = apiRes.upload.code[0]; |
537 | | - } |
538 | | - if(apiRes.upload.code['status']){ |
539 | | - error_code = apiRes.upload['status']; |
540 | | - } |
541 | | - }else{ |
542 | | - apiRes.upload.code; |
543 | | - } |
544 | | - } |
545 | | - |
546 | | - var error_msg = ''; |
547 | | - if(typeof apiRes.error == 'string') |
548 | | - error_msg = apiRes.error; |
549 | | - //error space is too large so we don't front load it |
550 | | - //do a remote call to get the error msg: |
551 | | - if(!error_code || error_code == 'unknown-error'){ |
552 | | - if(typeof JSON != 'undefined'){ |
553 | | - js_log('Error: apiRes: ' + JSON.stringify( apiRes) ); |
554 | | - } |
555 | | - _this.updateUploadError( gM('unknown-error') + '<br>' + error_msg); |
556 | | - }else{ |
557 | | - gMsgLoadRemote(error_code, function(){ |
558 | | - js_log('send msg: ' + gM( error_code )); |
559 | | - _this.updateUploadError( gM( error_code )); |
560 | | - }); |
561 | | - } |
562 | | - js_log("api.erorr"); |
563 | | - return ; |
564 | | - } |
565 | | - //check for upload_session key for async upload: |
566 | | - if( apiRes.upload && apiRes.upload.upload_session_key ){ |
567 | | - //set the session key |
568 | | - _this.upload_session_key = apiRes.upload.upload_session_key; |
569 | | - |
570 | | - //do ajax upload status: |
571 | | - _this.doAjaxUploadStatus(); |
572 | | - js_log("set upload_session_key: " + _this.upload_session_key); |
573 | | - return ; |
574 | | - } |
575 | | - |
576 | | - if( apiRes.upload.imageinfo && apiRes.upload.imageinfo.descriptionurl ){ |
577 | | - _this.updateUploadDone( apiRes.upload.imageinfo.descriptionurl ); |
578 | | - js_log('apiRes.upload.imageinfo:: updateUploadDone'); |
579 | | - return ; |
580 | | - } |
581 | | - |
582 | | - //check for upload error: |
583 | | - if( apiRes.upload && apiRes.upload.error){ |
584 | | - js_log(' apiRes.upload.error: ' + apiRes.upload.error ); |
585 | | - return ; |
586 | | - } |
587 | | - //check for known warnings: |
588 | | - if( apiRes.upload.warnings ){ |
589 | | - //debugger; |
590 | | - var wmsg = '<ul>'; |
591 | | - for(var wtype in apiRes.upload.warnings){ |
592 | | - var winfo = apiRes.upload.warnings[wtype] |
593 | | - wmsg+='<li>'; |
594 | | - switch(wtype){ |
595 | | - case 'duplicate': |
596 | | - case 'exists': |
597 | | - if(winfo[1] && winfo[1].title && winfo[1].title.mTextform){ |
598 | | - wmsg += gM('file-exists-duplicate') +' '+ |
599 | | - '<b>' + winfo[1].title.mTextform + '</b>'; |
600 | | - }else{ |
601 | | - //misc error (weird that winfo[1] not present |
602 | | - wmsg += gM('upload-misc-error') + ' ' + wtype; |
603 | | - } |
604 | | - break; |
605 | | - case 'file-thumbnail-no': |
606 | | - wmsg += gM('file-thumbnail-no', winfo); |
607 | | - break; |
608 | | - default: |
609 | | - wmsg += gM('upload-misc-error') + ' ' + wtype; |
610 | | - break; |
611 | | - } |
612 | | - wmsg+='</li>'; |
613 | | - } |
614 | | - wmsg+='</ul>'; |
615 | | - if( apiRes.upload.warnings.sessionkey) |
616 | | - _this.warnings_sessionkey = apiRes.upload.warnings.sessionkey; |
617 | | - _this.updateUploadWarning( wmsg ); |
618 | | - return false; |
619 | | - } |
620 | | - |
621 | | - //nothing fits assume unkown error: |
622 | | - js_log('could not parse upload api request result'); |
623 | | - _this.updateUploadError( gM('unknown-error')); |
624 | | - return false; |
625 | | - |
626 | | - }, |
627 | | - updateUploadWarning:function( msg ){ |
628 | | - $j( '#dlbox-centered' ).html( '<h3>' + gM('uploadwarning') + '</h3>' + |
629 | | - msg + '<p>' + |
630 | | - '<a id="mv-ignore-warnings">' + gM('ignorewarning') + '</a>' |
631 | | - ); |
632 | | - //setup ignore warnings binding and ajax query: |
633 | | - }, |
634 | | - updateUploadError:function( msg ){ |
635 | | - $j( '#dlbox-centered' ).html( '<h3>' + gM('uploaderror') + '</h3>' + |
636 | | - msg + '<p>' + |
637 | | - '<a id="mv-return-to-form" href="#" >' + gM('return-to-form') + '</a>'); |
638 | | - $j('#mv-return-to-form').click(function(){ |
639 | | - //hide / close up shop |
640 | | - $j('#dlbox-overlay,#dlbox-centered').hide(); |
641 | | - return false; |
642 | | - }); |
643 | | - }, |
644 | | - updateUploadDone:function( url ){ |
645 | | - $j( '#dlbox-centered' ).html( '<h3>' + gM('successfulupload') + '</h3>' + |
646 | | - gM( 'mv_upload_done', url) ); |
647 | | - }, |
648 | | - updateEmptyLoadingStatus:function(){ |
649 | | - $j('#dlbox-centered').html( '<h5>' + _this.getProgressTitle() + '</h5>' + |
650 | | - mv_get_loading_img( 'left:40%;top:20%') |
651 | | - ); |
652 | | - }, |
653 | | - getProgressTitle:function(){ |
654 | | - return gM('upload-in-progress'); |
655 | | - }, |
656 | | - getEditForm:function(){ |
657 | | - this.editForm = $j( '#mw-upload-form' ).get(0); |
658 | | - }, |
659 | | - updateProgress:function( perc ){ |
660 | | - $j( '#up-progressbar' ).css( 'width', parseInt( perc * 100 ) + '%' ); |
661 | | - $j( '#up-pstatus' ).html( parseInt( perc * 100 ) + '% - ' ); |
662 | | - }, |
663 | | - dispProgressOverlay:function(){ |
664 | | - var _this = this; |
665 | | - //remove old instance: |
666 | | - $j('#dlbox-centered,#dlbox-overlay').remove(); |
667 | | - //hard code style (since not always easy to import style sheets) |
668 | | - $j('body').append('<div id="dlbox-centered" class="dlbox-centered" style="'+ |
669 | | - 'position:fixed;background:#DDD;border:3px solid #AAA;font-size:115%;width:40%;'+ |
670 | | - 'height:300px;padding: 10px;z-index:100;top:100px;bottom:40%;left:20%;" >'+ |
671 | | - '<h5>' + _this.getProgressTitle() + '</h5>' + |
672 | | - '<div id="up-pbar-container" style="border:solid thin gray;width:90%;height:15px;" >' + |
673 | | - '<div id="up-progressbar" style="background:#AAC;width:0%;height:15px;"></div>' + |
674 | | - '</div>' + |
675 | | - '<span id="up-pstatus">0% - </span> ' + |
676 | | - '<span id="up-status-state">' + gM('uploaded-status') + '</span> ' + |
677 | | - '<span id="upload-stats-fileprogres"></span>'+ |
678 | | - '</div>' + |
679 | | - '<div id="dlbox-overlay" class="dlbox-overlay" style="background:#000;cursor:wait;height:100%;'+ |
680 | | - 'left:0;top:0;position:fixed;width:100%;z-index:99;filter:alpha(opacity=60);'+ |
681 | | - '-moz-opacity: 0.6; opacity: 0.6;" ></div>'); |
682 | | - //fade them in: |
683 | | - $j('#dlbox-centered,#dlbox-overlay').show(); |
684 | | - } |
685 | | -} |
Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js |
— | — | @@ -2,11 +2,54 @@ |
3 | 3 | * autodetects: new upload api or old http POST. |
4 | 4 | */ |
5 | 5 | |
| 6 | +loadGM({ |
| 7 | + 'fogg-select_file' : 'Select File', |
| 8 | + 'fogg-select_new_file' : 'Select New File', |
| 9 | + 'fogg-save_local_file' : 'Save Ogg', |
| 10 | + 'fogg-check_for_fogg' : 'Checking for Firefogg <blink>...</blink>', |
| 11 | + 'fogg-installed' : 'Firefogg is Installed', |
| 12 | + 'fogg-please_install' : 'You don\'t have firefogg, please <a href="$1">install firefogg</a>', |
| 13 | + 'fogg-use_latest_fox' : 'You need a <a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 3.5</a> to use Firefogg', |
| 14 | + 'passthrough_mode' : 'Your selected file is already ogg or not a video file', |
| 15 | + |
| 16 | +}); |
| 17 | + |
| 18 | +var firefogg_install_links = { |
| 19 | + 'macosx': 'http://firefogg.org/macosx/Firefogg.xpi', |
| 20 | + 'win32' : 'http://firefogg.org/win32/Firefogg.xpi', |
| 21 | + 'linux' : 'http://firefogg.org/linux/Firefogg.xpi' |
| 22 | +}; |
| 23 | + |
6 | 24 | var default_firefogg_options = { |
7 | 25 | 'upload_done_action':'redirect', |
8 | 26 | 'fogg_enabled':false, |
9 | 27 | 'api_url':null, |
10 | | - 'passthrough': false |
| 28 | + 'passthrough': false, |
| 29 | + 'encoder_interface': false, |
| 30 | + |
| 31 | + //callbacks: |
| 32 | + 'new_source_cb': false, //called on source name update passes along source name |
| 33 | + |
| 34 | + //target control container or form (can't be left null) |
| 35 | + 'selector' : '', |
| 36 | + |
| 37 | + 'form_rewrite' : false,//if not rewriting a form we are encoding local. |
| 38 | + |
| 39 | + |
| 40 | + //taget buttons: |
| 41 | + 'target_btn_select_file' : false, |
| 42 | + 'target_btn_select_new_file': false, |
| 43 | + 'target_input_file_name' : false, |
| 44 | + 'target_btn_save_local_file': false, |
| 45 | + |
| 46 | + |
| 47 | + //target install descriptions (visability will be set based ) |
| 48 | + 'target_check_for_fogg' : false, |
| 49 | + 'target_installed' : false, |
| 50 | + 'target_please_install' : false, |
| 51 | + 'target_use_latest_fox': false, |
| 52 | + //status: |
| 53 | + 'target_passthrough_mode':false |
11 | 54 | } |
12 | 55 | |
13 | 56 | |
— | — | @@ -15,16 +58,17 @@ |
16 | 59 | } |
17 | 60 | mvFirefogg.prototype = { //extends mvBaseUploadInterface |
18 | 61 | |
19 | | - min_firefogg_version : '0.9.5', |
| 62 | + min_firefogg_version : '0.9.6', |
20 | 63 | fogg_enabled : false, //if firefogg is enabled or not. |
21 | 64 | encoder_settings:{ //@@todo allow server to set this |
22 | 65 | 'maxSize': 400, |
23 | 66 | 'videoBitrate': 400, |
24 | 67 | 'noUpscaling':true |
25 | 68 | }, |
| 69 | + sourceFileInfo:{}, |
26 | 70 | ogg_extensions: ['ogg', 'ogv', 'oga'], |
27 | | - video_extensions: ['avi', 'mov', 'mp4', 'mp2', 'mpeg', 'mpeg2', 'mpeg4', 'dv', 'wmv'], |
28 | | - passthrough_extensions: ['png', 'gif', 'jpg', 'jpeg'], //@@todo allow server to set this |
| 71 | + video_extensions: ['avi', 'mov', 'mp4', 'mp2', 'mpeg', 'mpeg2', 'mpeg4', 'dv', 'wmv'], |
| 72 | + |
29 | 73 | passthrough: false, |
30 | 74 | |
31 | 75 | init: function( iObj ){ |
— | — | @@ -46,110 +90,169 @@ |
47 | 91 | }else{ |
48 | 92 | this[i] = myBUI[i]; |
49 | 93 | } |
50 | | - } |
| 94 | + } |
| 95 | + if(!this.selector){ |
| 96 | + js_log('Error: firefogg: missing selector '); |
| 97 | + } |
51 | 98 | }, |
52 | | - setupForm: function(){ |
53 | | - var _this = this; |
54 | | - //call the parent form setup |
55 | | - _this.pe_setupForm(); |
56 | | - |
57 | | - //do all firefogg form setup: |
58 | | - if(typeof(Firefogg) == 'undefined'){ |
59 | | - $j('#wgfogg_not_installed').show(); |
60 | | - return false; |
| 99 | + doRewrite:function( callback ){ |
| 100 | + //check if we are rewriting an input or a form: |
| 101 | + if( this.form_rewrite ){ |
| 102 | + this.setupForm(); |
| 103 | + }else{ |
| 104 | + this.doControlHTML(); |
| 105 | + this.doControlBindings(); |
61 | 106 | } |
62 | | - //make sure all the error msgs are hidden: |
63 | | - $j('#wgfogg_not_installed,#wgfogg_wrong_version').hide(); |
64 | 107 | |
65 | | - //show firefogg enabler: |
66 | | - $j('#wgfogg_installed,#wgEnableFirefogg').show(); |
| 108 | + //doRewrite is done: |
| 109 | + if(callback) |
| 110 | + callback(); |
| 111 | + }, |
| 112 | + doControlHTML: function(){ |
| 113 | + var _this = this; |
| 114 | + var out = ''; |
| 115 | + $j.each(default_firefogg_options, function(target, na){ |
| 116 | + if(target.substring(0, 6)=='target'){ |
| 117 | + //check for the target if missing add to the output: |
| 118 | + if( _this[target] === false){ |
| 119 | + if( target.substr(7,3)=='btn'){ |
| 120 | + out+='<input class="' + target + '" type="button" value="' + gM( 'fogg-' + target.substring(11)) + '"/> '; |
| 121 | + }else if(target.substr(7,5)=='input'){ |
| 122 | + out+='<input class="' + target + '" type="text" value="' + gM( 'fogg-' + target.substring(11)) + '"/> '; |
| 123 | + }else{ |
| 124 | + out+='<div class="' + target + '">'+ gM('fogg-'+ target.substring(7)) + '</div> '; |
| 125 | + } |
| 126 | + } |
| 127 | + //update the target selector |
| 128 | + _this[target] = _this.selector + ' .' + target; |
| 129 | + } |
| 130 | + }); |
| 131 | + //output the html |
| 132 | + $j( this.selector ).html( out ).show(); |
| 133 | + }, |
| 134 | + doControlBindings: function(){ |
| 135 | + var _this = this; |
67 | 136 | |
68 | | - if( $j('#wgEnableFirefogg').length > 0 ){ |
69 | | - _this.fogg = new Firefogg(); |
70 | | - //do the version check: |
71 | | - if( this.fogg.version.replace(/[^0-9]/gi, '') < this.min_firefogg_version.replace(/[^0-9]/gi, '' ) ){ |
72 | | - //show wrong version error: |
73 | | - $j('#wgfogg_wrong_version').show(); |
74 | | - //hide the installed parent div: |
75 | | - $j('#wgfogg_installed').hide(); |
76 | | - } |
77 | | - //make sure the checkbox accurately reflects the current state per config: |
78 | | - $j('#wgEnableFirefogg').get(0).checked = this.fogg_enabled; |
79 | | - |
80 | | - //setup the click bindding: |
81 | | - $j('#wgEnableFirefogg').click( function(){ |
82 | | - if( _this.fogg_enabled ){ |
83 | | - _this.disable_fogg(); |
84 | | - }else{ |
85 | | - _this.enable_fogg(); |
86 | | - } |
87 | | - }); |
| 137 | + //hide all targets: |
| 138 | + var hide_target_list=''; |
| 139 | + var coma=''; |
| 140 | + $j.each(default_firefogg_options, function(target, na){ |
| 141 | + if(target.substring(0, 6)=='target'){ |
| 142 | + hide_target_list+=coma + _this[target]; |
| 143 | + coma=','; |
| 144 | + } |
| 145 | + }); |
| 146 | + $j( hide_target_list ).hide(); |
| 147 | + |
| 148 | + //hide all but check-for-fogg |
| 149 | + //check for firefogg |
| 150 | + if( _this.firefoggCheck() ){ |
| 151 | + //show select file: |
| 152 | + $j(this.target_btn_select_file).click(function(){ |
| 153 | + _this.select_fogg(); |
| 154 | + }).show().attr('disabled', false); |
88 | 155 | }else{ |
89 | | - js_log('could not find wgEnableFirefogg'); |
| 156 | + var os_link = false; |
| 157 | + if(navigator.oscpu){ |
| 158 | + if(navigator.oscpu.search('Linux') >= 0) |
| 159 | + os_link = firefogg_install_links['linux']; |
| 160 | + else if(navigator.oscpu.search('Mac') >= 0) |
| 161 | + os_link = firefogg_install_links['macosx']; |
| 162 | + else if(navigator.oscpu.search('Win') >= 0) |
| 163 | + os_link = firefogg_install_links['win32']; |
| 164 | + } |
| 165 | + $j(_this.target_please_install).html( gM('fogg-please_install',os_link )).show(); |
90 | 166 | } |
| 167 | + //setup the target save local file bindins: |
| 168 | + $j( _this.target_btn_save_local_file ).click(function(){ |
| 169 | + //update the output target |
| 170 | + if(_this.fogg){ |
| 171 | + //if(_this.fogg.saveVideoAs()){ |
| 172 | + _this.doEncode(); |
| 173 | + //} |
| 174 | + } |
| 175 | + }) |
91 | 176 | }, |
92 | | - enable_fogg:function(){ |
93 | | - var _this = this; |
94 | | - |
95 | | - //enable the FOGG_TOGGLE |
96 | | - this.fogg_enabled=true; |
| 177 | + firefoggCheck:function(){ |
| 178 | + var _this = this; |
| 179 | + if(typeof(Firefogg) != 'undefined' && Firefogg().version >= '0.9.6'){ |
| 180 | + _this.fogg = new Firefogg(); |
| 181 | + return true; |
| 182 | + }else{ |
| 183 | + return false; |
| 184 | + } |
| 185 | + }, |
| 186 | + //assume input target |
| 187 | + setupForm: function(){ |
97 | 188 | |
98 | | - //make sure file is "checked" |
99 | | - if( $j( '#wpSourceTypeFile' ).length != 0 ) |
100 | | - $j( '#wpSourceTypeFile' ).get(0).checked = true; |
| 189 | + js_log('firefogg::setupForm::'); |
| 190 | + //call the parent form setup |
| 191 | + _this.pe_setupForm(); |
101 | 192 | |
102 | | - //hide normal file upload stuff |
103 | | - $j( '#wg-base-upload' ).hide(); |
104 | | - //setup the form pointer: |
105 | | - _this.getEditForm(); |
106 | | - |
107 | | - //show fogg & add click binding: |
108 | | - $j( '#fogg-video-file' ).unbind().show().click( function(){ |
109 | | - _this.select_fogg(); |
110 | | - }); |
| 193 | + //firefogg is always "enabled" with passthrough mode (if not uploading video) |
111 | 194 | }, |
112 | | - disable_fogg:function(){ |
113 | | - var _this = this; |
114 | | - //not enabled: |
115 | | - this.fogg_enabled=false; |
116 | | - |
117 | | - $j( '#wg-base-upload' ).show(); |
118 | | - |
119 | | - //hide any errors warnings and video select: |
120 | | - $j( '#wgfogg_waring_ogg_upload,#wgfogg_waring_bad_extension,#fogg-video-file' ).hide(); |
121 | | - }, |
122 | 195 | select_fogg:function(){ |
123 | 196 | var _this = this; |
124 | 197 | if( _this.fogg.selectVideo() ) { |
125 | 198 | |
126 | | - //update destination filename: |
127 | | - if( _this.fogg.sourceFilename ){ |
128 | | - var sf = _this.fogg.sourceFilename; |
129 | | - var ext = ''; |
130 | | - if( sf.lastIndexOf('.') != -1){ |
131 | | - ext = sf.substring( sf.lastIndexOf('.')+1 ).toLowerCase(); |
| 199 | + var videoSelectReady= function(){ |
| 200 | + js_log('videoSelectReady'); |
| 201 | + //if not already hidden hide select file and show "select new": |
| 202 | + $j(_this.target_btn_select_file).hide(); |
| 203 | + //show and setup binding for new file: |
| 204 | + $j(_this.target_btn_select_new_file).show().click(function(){ |
| 205 | + _this.select_fogg(); |
| 206 | + }); |
| 207 | + //update if we are in passthrough mode or going to encode |
| 208 | + if( _this.fogg.sourceInfo && _this.fogg.sourceFilename ){ |
| 209 | + //update the source status |
| 210 | + _this.sourceFileInfo = JSON.parse( _this.fogg.sourceInfo) ; |
| 211 | + |
| 212 | + //now setup encoder settings based source type: |
| 213 | + _this.autoEncoderSettings(); |
| 214 | + |
| 215 | + //if set to passthough update the interface: |
| 216 | + if(_this.encoder_settings['passthrough']==true){ |
| 217 | + $j(_this.target_passthrough_mode).show(); |
| 218 | + }else{ |
| 219 | + //if set to encoder expose the encode button: |
| 220 | + if( !_this.form_rewrite ){ |
| 221 | + $j(_this.target_btn_save_local_file).show(); |
| 222 | + } |
| 223 | + } |
| 224 | + //~otherwise the encoding will be triggered by the form~ |
| 225 | + |
| 226 | + //do source name update callback: |
| 227 | + $j(_this.target_input_file_name).val(_this.fogg.sourceFilename).show(); |
| 228 | + |
| 229 | + if(_this.new_source_cb){ |
| 230 | + new_source_cb( _this.fogg.sourceFilename ); |
| 231 | + } |
132 | 232 | } |
133 | | - //set upload warning |
134 | | - if( $j.inArray(ext, _this.ogg_extensions) > -1 ){ |
135 | | - $j('#wgfogg_waring_ogg_upload').show(); |
136 | | - return false; |
137 | | - }else if( $j.inArray(ext, _this.video_extensions) > -1 ){ |
138 | | - //hide ogg warning |
139 | | - $j('#wgfogg_waring_ogg_upload').hide(); |
140 | | - var extreg = new RegExp(ext + '$', 'i'); |
141 | | - sf = sf.replace(extreg, 'ogg'); |
142 | | - $j('#wpDestFile').val( sf ); |
143 | | - }else if( $j.inArray(ext, _this.passthrough_extensions) > -1 ){ |
144 | | - $j('#wpDestFile').val( sf ); |
145 | | - _this.passthrough = true; |
146 | | - }else{ |
147 | | - //not video extension error: |
148 | | - $j('#wgfogg_waring_bad_extension').show(); |
149 | | - return false; |
150 | | - } |
151 | | - } |
| 233 | + } |
| 234 | + //wait 100ms to get video info: |
| 235 | + setTimeout(videoSelectReady, 200); |
152 | 236 | } |
153 | 237 | }, |
| 238 | + //simple auto encoder settings just enable passthough if file is not video or > 480 pixles tall |
| 239 | + autoEncoderSettings:function(){ |
| 240 | + var _this = this; |
| 241 | + //grab the extension: |
| 242 | + var sf = _this.fogg.sourceFilename; |
| 243 | + var ext = ''; |
| 244 | + if( sf.lastIndexOf('.') != -1){ |
| 245 | + ext = sf.substring( sf.lastIndexOf('.')+1 ).toLowerCase(); |
| 246 | + } |
| 247 | + //ogg video or audio |
| 248 | + if( $j.inArray(ext, _this.ogg_extensions) > -1 ){ |
| 249 | + //in the default case passthrough |
| 250 | + _this.encoder_settings['passthrough'] = true; |
| 251 | + }else if( $j.inArray(ext, _this.video_extensions) > -1 ){ |
| 252 | + //we are going to run the encoder |
| 253 | + }else{ |
| 254 | + _this.encoder_settings['passthrough'] = true; |
| 255 | + } |
| 256 | + }, |
154 | 257 | getProgressTitle:function(){ |
155 | 258 | //return the parent if we don't have fogg turned on: |
156 | 259 | if(! this.fogg_enabled ) |
— | — | @@ -165,7 +268,7 @@ |
166 | 269 | |
167 | 270 | //check what mode to use firefogg in: |
168 | 271 | if( _this.upload_mode == 'post' ){ |
169 | | - _this.doEncUpload(); |
| 272 | + _this.doEncode(); |
170 | 273 | }else if( _this.upload_mode == 'api' && _this.chunks_supported){ //if api mode and chunks supported do chunkUpload |
171 | 274 | _this.doChunkUpload(); |
172 | 275 | }else{ |
— | — | @@ -210,21 +313,20 @@ |
211 | 314 | aReq['ignorewarnings'] = _this.formData['wpIgnoreWarning']; |
212 | 315 | |
213 | 316 | js_log('do fogg upload call: '+ _this.api_url + ' :: ' + JSON.stringify( aReq ) ); |
| 317 | + |
| 318 | + _this.fogg.upload( JSON.stringify( _this.encoder_settings ), _this.api_url , JSON.stringify( aReq ) ); |
214 | 319 | |
215 | | - var enc_settings = _this.encoder_settings; |
216 | | - if( _this.passthrough ){ |
217 | | - enc_settings = {'passthrough': true}; |
218 | | - } |
219 | | - _this.fogg.upload( JSON.stringify( enc_settings ), _this.api_url , JSON.stringify( aReq ) ); |
220 | | - |
221 | 320 | //update upload status: |
222 | 321 | _this.doUploadStatus(); |
223 | 322 | }, |
224 | | - //doEncUpload first encodes then uploads |
225 | | - doEncUpload : function(){ |
226 | | - var _this = this; |
| 323 | + //doEncode and monitor progress: |
| 324 | + doEncode : function(){ |
| 325 | + var _this = this; |
| 326 | + _this.dispProgressOverlay(); |
| 327 | + js_log('doEncode: with: ' + JSON.stringify( _this.encoder_settings ) ); |
227 | 328 | _this.fogg.encode( JSON.stringify( _this.encoder_settings ) ); |
228 | 329 | |
| 330 | + |
229 | 331 | //show transcode status: |
230 | 332 | $j('#up-status-state').html( gM('upload-transcoded-status') ); |
231 | 333 | |
— | — | @@ -238,29 +340,33 @@ |
239 | 341 | //loop to get new status if still encoding |
240 | 342 | if( _this.fogg.state == 'encoding' ) { |
241 | 343 | setTimeout(encodingStatus, 500); |
242 | | - }else if ( _this.fogg.state == 'encoding done' ) { //encoding done, state can also be 'encoding failed |
243 | | - // ignore warnings & set source type |
244 | | - //_this.formData[ 'wpIgnoreWarning' ]='true'; |
245 | | - _this.formData[ 'wpSourceType' ]='file'; |
246 | | - _this.formData[ 'action' ] = 'submit'; |
247 | | - |
248 | | - //send to the post url: |
249 | | - //js_log('sending form data to : ' + _this.editForm.action); |
250 | | - //for(var fk in _this.formData){ |
251 | | - // js_log(fk + ' : ' + _this.formData[fk]); |
252 | | - //} |
253 | | - _this.fogg.post( _this.editForm.action, 'wpUploadFile', JSON.stringify( _this.formData ) ); |
254 | | - |
255 | | - //update upload status: |
256 | | - _this.doUploadStatus(); |
257 | | - |
| 344 | + }else if ( _this.fogg.state == 'encoding done' ) { //encoding done, state can also be 'encoding failed |
| 345 | + _this.encodeDone(); |
258 | 346 | }else if(_this.fogg.state == 'encoding fail'){ |
259 | 347 | //@@todo error handling: |
260 | | - alert('encoding failed'); |
| 348 | + js_error('encoding failed'); |
261 | 349 | } |
262 | 350 | } |
263 | 351 | encodingStatus(); |
264 | 352 | }, |
| 353 | + encodeDone:function(){ |
| 354 | + var _this = this; |
| 355 | + js_log('::encodeDone::'); |
| 356 | + //send to the post url: |
| 357 | + if( _this.form_rewrite ){ |
| 358 | + js_log('done with encoding do upload:'); |
| 359 | + // ignore warnings & set source type |
| 360 | + //_this.formData[ 'wpIgnoreWarning' ]='true'; |
| 361 | + _this.formData[ 'wpSourceType' ]= 'file'; |
| 362 | + _this.formData[ 'action' ] = 'submit'; |
| 363 | + |
| 364 | + _this.fogg.post( _this.editForm.action, 'wpUploadFile', JSON.stringify( _this.formData ) ); |
| 365 | + //update upload status: |
| 366 | + _this.doUploadStatus(); |
| 367 | + }else{ |
| 368 | + js_log('done with encode (no upload cuz we don\'t have a target)'); |
| 369 | + } |
| 370 | + }, |
265 | 371 | doUploadStatus:function() { |
266 | 372 | var _this = this; |
267 | 373 | $j('#up-status-state').html( gM('uploaded-status') ); |
Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/mediaWikiUploadHelper.OFF.js |
— | — | @@ -0,0 +1,163 @@ |
| 2 | +/* the upload javascript |
| 3 | +presently does hackery to work with Special:Upload page... |
| 4 | +will be replaced with upload API once that is ready |
| 5 | +*/ |
| 6 | + |
| 7 | +loadGM({ |
| 8 | + "upload-enable-converter" : "Enable video converter (to upload source video not yet converted to theora format) <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>", |
| 9 | + "upload-fogg_not_installed": "If you want to upload video consider installing <a href=\"http://firefogg.org\">firefogg.org</a>, <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>", |
| 10 | + "upload-transcode-in-progress":"Doing Transcode & Upload (do not close this window)", |
| 11 | + "upload-in-progress": "Upload in Progress (do not close this window)", |
| 12 | + "upload-transcoded-status": "Transcoded", |
| 13 | + "uploaded-status": "Uploaded", |
| 14 | + "upload-select-file": "Select File...", |
| 15 | + "wgfogg_wrong_version": "You have firefogg installed but its outdated, <a href=\"http://firefogg.org\">please upgrade</a> ", |
| 16 | + "wgfogg_waring_ogg_upload": "You have selected an ogg file for conversion to ogg (this is probably unnessesary). Maybe disable the video converter?", |
| 17 | + "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 help</a>", |
| 18 | + "upload-stats-fileprogres": "$1 of $2", |
| 19 | + |
| 20 | + "mv_upload_done" : "Your upload <i>should be</i> accessible <a href=\"$1\">here</a>", |
| 21 | + "upload-unknown-size": "Unknown size", |
| 22 | + |
| 23 | + "successfulupload" : "Successful upload", |
| 24 | + "uploaderror" : "Upload error", |
| 25 | + "uploadwarning": "Upload warning", |
| 26 | + "unknown-error": "Unknown Error", |
| 27 | + "return-to-form": "Return to form", |
| 28 | + |
| 29 | + "file-exists-duplicate" : "This file is a duplicate of the following file", |
| 30 | + "fileexists" : "A file with this name exists already, please check <b><tt>$1</tt></b> if you are not sure if you want to change it.", |
| 31 | + "fileexists-thumb": "<center><b>Existing file</b></center>", |
| 32 | + "ignorewarning" : "Ignore warning and save file anyway", |
| 33 | + "file-thumbnail-no" : "The filename begins with <b><tt>$1</tt></b>" |
| 34 | +}); |
| 35 | + |
| 36 | +var default_upload_options = { |
| 37 | + 'target_div':'', |
| 38 | + 'upload_done_action':'redirect', |
| 39 | + 'api_url':false |
| 40 | +} |
| 41 | + |
| 42 | +var mediaWikiUploadHelper = function(initObj){ |
| 43 | + return this.init( initObj ); |
| 44 | +} |
| 45 | +mediaWikiUploadHelper.prototype = { |
| 46 | + init:function( iObj ){ |
| 47 | + var _this = this; |
| 48 | + js_log('init uploader'); |
| 49 | + if(!iObj) |
| 50 | + iObj = {}; |
| 51 | + for(var i in default_upload_options){ |
| 52 | + if(iObj[i]){ |
| 53 | + this[i] = iObj[i]; |
| 54 | + }else{ |
| 55 | + this[i] = default_upload_options[i]; |
| 56 | + } |
| 57 | + } |
| 58 | + //check if we are on the uplaod page: |
| 59 | + this.on_upload_page = ( wgPageName== "Special:Upload")?true:false; |
| 60 | + js_log('f:mvUploader: onuppage:' + this.on_upload_page); |
| 61 | + //grab firefogg.js: |
| 62 | + mvJsLoader.doLoad({ |
| 63 | + 'mvFirefogg' : 'libAddMedia/mvFirefogg.js' |
| 64 | + },function(){ |
| 65 | + //if we are not on the upload page grab the upload html via ajax: |
| 66 | + //@@todo refactor with |
| 67 | + if( !_this.on_upload_page){ |
| 68 | + $j.get(wgArticlePath.replace(/\$1/, 'Special:Upload'), {}, function(data){ |
| 69 | + //add upload.js: |
| 70 | + $j.getScript( stylepath + '/common/upload.js', function(){ |
| 71 | + //really _really_ need an "upload api"! |
| 72 | + wgAjaxUploadDestCheck = true; |
| 73 | + wgAjaxLicensePreview = false; |
| 74 | + wgUploadAutoFill = true; |
| 75 | + //strip out inline scripts: |
| 76 | + sp = data.indexOf('<div id="content">'); |
| 77 | + se = data.indexOf('<!-- end content -->'); |
| 78 | + if(sp!=-1 && se !=-1){ |
| 79 | + result_data = data.substr(sp, (se-sp) ).replace('/\<script\s.*?\<\/script\>/gi',' '); |
| 80 | + js_log("trying to set: " + result_data ); |
| 81 | + //$j('#'+_this.target_div).html( result_data ); |
| 82 | + } |
| 83 | + _this.setupFirefogg(); |
| 84 | + }); |
| 85 | + }); |
| 86 | + }else{ |
| 87 | + //@@could check if firefogg is enabled here: |
| 88 | + _this.setupFirefogg(); |
| 89 | + //if only want httpUploadFrom help enable it here: |
| 90 | + } |
| 91 | + } |
| 92 | + ); |
| 93 | + }, |
| 94 | + /** |
| 95 | + * setupBaseUpInterface supports intefaces for progress indication if the browser supports it |
| 96 | + * also sets up ajax progress updates for http posts |
| 97 | + * //pre |
| 98 | + */ |
| 99 | + setupBaseUpInterface:function(){ |
| 100 | + //check if this feature is not false (we want it on by default (null) instances that don't have the upload api or any modifications) |
| 101 | + this.upForm = new mvBaseUploadInterface( { |
| 102 | + 'api_url' : this.api_url, |
| 103 | + 'parent_uploader': this |
| 104 | + } |
| 105 | + ); |
| 106 | + this.upForm.setupForm(); |
| 107 | + }, |
| 108 | + setupFirefogg:function(){ |
| 109 | + var _this = this; |
| 110 | + //add firefogg html if not already there: ( same as $wgEnableFirebug added in SpecialUpload.php ) |
| 111 | + if( $j('#fogg-video-file').length==0 ){ |
| 112 | + js_log('add addFirefoggHtml'); |
| 113 | + _this.addFirefoggHtml(); |
| 114 | + }else{ |
| 115 | + js_log('firefogg already init:'); |
| 116 | + } |
| 117 | + //set up the upload_done action |
| 118 | + //redirect if we are on the upload page |
| 119 | + //do a callback if in called from gui) |
| 120 | + var intFirefoggObj = ( this.on_upload_page )? |
| 121 | + {'upload_done_action':'redirect'}: |
| 122 | + {'upload_done_action':function( rTitle ){ |
| 123 | + js_log( 'add_done_action callback for uploader' ); |
| 124 | + //call the parent insert resource preview |
| 125 | + _this.upload_done_action( rTitle ); |
| 126 | + } |
| 127 | + }; |
| 128 | + |
| 129 | + if( _this.api_url ) |
| 130 | + intFirefoggObj['api_url'] = _this.api_url; |
| 131 | + |
| 132 | + js_log('new mvFirefogg extends mvUploader (this)'); |
| 133 | + this.fogg = new mvFirefogg( intFirefoggObj ); |
| 134 | + this.fogg.setupForm(); |
| 135 | + }, |
| 136 | + //same add code as specialUpload if($wgEnableFirefogg){ |
| 137 | + addFirefoggHtml:function(){ |
| 138 | + var itd_html = $j('#mw-upload-table .mw-input:first').html(); |
| 139 | + $j('#mw-upload-table .mw-input').eq(0).html('<div id="wg-base-upload">' + itd_html + '</div>'); |
| 140 | + //add in firefogg control |
| 141 | + $j('#wg-base-upload').after('<p id="fogg-enable-item" >' + |
| 142 | + '<input style="display:none" id="fogg-video-file" name="fogg-video-file" type="button" value="' + gM('upload-select-file') + '">' + |
| 143 | + "<span id='wgfogg_not_installed'>" + |
| 144 | + gM('upload-fogg_not_installed') + |
| 145 | + "</span>" + |
| 146 | + "<span class='error' id='wgfogg_wrong_version' style='display:none;'><br>" + |
| 147 | + gM('wgfogg_wrong_version') + |
| 148 | + "<br>" + |
| 149 | + "</span>" + |
| 150 | + "<span class='error' id='wgfogg_waring_ogg_upload' style='display:none;'><br>"+ |
| 151 | + gM('wgfogg_waring_ogg_upload') + |
| 152 | + "<br>" + |
| 153 | + "</span>" + |
| 154 | + "<span class='error' id='wgfogg_waring_bad_extension' style='display:none;'><br>"+ |
| 155 | + gM('wgfogg_waring_bad_extension') + |
| 156 | + "<br>" + |
| 157 | + "</span>" + |
| 158 | + "<span id='wgfogg_installed' style='display:none' >"+ |
| 159 | + '<input id="wgEnableFirefogg" type="checkbox" name="wgEnableFirefogg" >' + |
| 160 | + gM('upload-enable-converter') + |
| 161 | + '</span><br></p>'); |
| 162 | + }, |
| 163 | + |
| 164 | +} |
Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js |
— | — | @@ -0,0 +1,444 @@ |
| 2 | +/** |
| 3 | + * the base Upload Interface for uploading. |
| 4 | + * |
| 5 | + * this base uploader is optionally extended by firefogg |
| 6 | + */ |
| 7 | + |
| 8 | + loadGM({ |
| 9 | + "upload-transcode-in-progress":"Doing Transcode & Upload (do not close this window)", |
| 10 | + "upload-in-progress": "Upload in Progress (do not close this window)", |
| 11 | + "upload-transcoded-status": "Transcoded", |
| 12 | + "uploaded-status": "Uploaded", |
| 13 | + |
| 14 | + "wgfogg_wrong_version": "You have firefogg installed but its outdated, <a href=\"http://firefogg.org\">please upgrade</a> ", |
| 15 | + "upload-stats-fileprogres": "$1 of $2", |
| 16 | + |
| 17 | + "mv_upload_done" : "Your upload <i>should be</i> accessible <a href=\"$1\">here</a>", |
| 18 | + "upload-unknown-size": "Unknown size", |
| 19 | + |
| 20 | + "successfulupload" : "Successful upload", |
| 21 | + "uploaderror" : "Upload error", |
| 22 | + "uploadwarning": "Upload warning", |
| 23 | + "unknown-error": "Unknown Error", |
| 24 | + "return-to-form": "Return to form", |
| 25 | + |
| 26 | + "file-exists-duplicate" : "This file is a duplicate of the following file", |
| 27 | + "fileexists" : "A file with this name exists already, please check <b><tt>$1</tt></b> if you are not sure if you want to change it.", |
| 28 | + "fileexists-thumb": "<center><b>Existing file</b></center>", |
| 29 | + "ignorewarning" : "Ignore warning and save file anyway", |
| 30 | + "file-thumbnail-no" : "The filename begins with <b><tt>$1</tt></b>" |
| 31 | +}); |
| 32 | + |
| 33 | + |
| 34 | +var default_bui_options = { |
| 35 | + 'api_url':null, |
| 36 | + 'parent_uploader':null |
| 37 | +} |
| 38 | +var mvBaseUploadInterface = function( iObj ){ |
| 39 | + return this.init( iObj ); |
| 40 | +} |
| 41 | +mvBaseUploadInterface.prototype = { |
| 42 | + parent_uploader:false, |
| 43 | + formData:{}, //the form to be submitted |
| 44 | + upload_mode:'autodetect', //can be 'post', 'chunks' or autodetect. (autodetect issues an api call) |
| 45 | + warnings_sessionkey:null, |
| 46 | + chunks_supported:false, |
| 47 | + form_post_override:false, |
| 48 | + init: function( iObj ){ |
| 49 | + if(!iObj) |
| 50 | + iObj = {}; |
| 51 | + //inherit iObj properties: |
| 52 | + for(var i in default_bui_options){ |
| 53 | + if(iObj[i]){ |
| 54 | + this[i] = iObj[i]; |
| 55 | + }else{ |
| 56 | + this[i] = default_bui_options[i]; |
| 57 | + } |
| 58 | + } |
| 59 | + }, |
| 60 | + setupForm:function(){ |
| 61 | + var _this = this; |
| 62 | + //set up the local pointer to the edit form: |
| 63 | + _this.getEditForm(); |
| 64 | + |
| 65 | + if(_this.editForm){ |
| 66 | + //set up the org_onsubmit if not set: |
| 67 | + if( typeof( _this.org_onsubmit ) == 'undefined' ) |
| 68 | + _this.org_onsubmit = _this.editForm.onsubmit; |
| 69 | + |
| 70 | + //have to define the onsubmit function inline or its hard to pass the "_this" instance |
| 71 | + _this.editForm.onsubmit = function(){ |
| 72 | + //run the original onsubmit (if not run yet set flag to avoid excessive chaining ) |
| 73 | + if( typeof( _this.org_onsubmit ) == 'function' ){ |
| 74 | + if( ! _this.org_onsubmit() ){ |
| 75 | + //error in org submit return false; |
| 76 | + return false; |
| 77 | + } |
| 78 | + } |
| 79 | + //check for post action override: |
| 80 | + if( _this.form_post_override ){ |
| 81 | + //alert('woudld submit here'); |
| 82 | + return true; |
| 83 | + } |
| 84 | + //get the input form data in flat json: |
| 85 | + var tmpAryData = $j( _this.editForm ).serializeArray(); |
| 86 | + for(var i=0; i < tmpAryData.length; i++){ |
| 87 | + if( tmpAryData[i]['name'] ) |
| 88 | + _this.formData[ tmpAryData[i]['name'] ] = tmpAryData[i]['value']; |
| 89 | + } |
| 90 | + //put into a try catch so we are sure to return false: |
| 91 | + try{ |
| 92 | + //get a clean loader: |
| 93 | + _this.dispProgressOverlay(); |
| 94 | + |
| 95 | + //for some unknown reason we have to drop down the #p-search z-index: |
| 96 | + $j('#p-search').css('z-index', 1); |
| 97 | + |
| 98 | + //select upload mode: |
| 99 | + _this.detectUploadMode(); |
| 100 | + }catch(e){} |
| 101 | + |
| 102 | + //don't submit the form we will do the post in ajax |
| 103 | + return false; |
| 104 | + }; |
| 105 | + } |
| 106 | + |
| 107 | + }, |
| 108 | + detectUploadMode:function( callback ){ |
| 109 | + var _this = this; |
| 110 | + js_log('detectUploadMode::' + _this.upload_mode + ' api:' + _this.api_url); |
| 111 | + //check the upload mode: |
| 112 | + if( _this.upload_mode == 'autodetect' ){ |
| 113 | + if( ! _this.api_url ) |
| 114 | + return js_error( 'Error: can\'t autodetect mode without api url' ); |
| 115 | + do_api_req( { |
| 116 | + 'data':{ 'action':'paraminfo','modules':'upload' }, |
| 117 | + 'url' :_this.api_url |
| 118 | + }, function(data){ |
| 119 | + if( typeof data.paraminfo == 'undefined' || typeof data.paraminfo.modules == 'undefined' ) |
| 120 | + return js_error( 'Error: bad api results' ); |
| 121 | + if( typeof data.paraminfo.modules[0].classname == 'undefined'){ |
| 122 | + js_log( 'Autodetect Upload Mode: \'post\' '); |
| 123 | + _this.upload_mode = 'post'; |
| 124 | + }else{ |
| 125 | + js_log( 'Autodetect Upload Mode: api ' ); |
| 126 | + _this.upload_mode = 'api'; |
| 127 | + //check to see if chunks are supported: |
| 128 | + for( var i in data.paraminfo.modules[0].parameters ){ |
| 129 | + var pname = data.paraminfo.modules[0].parameters[i].name; |
| 130 | + if( pname == 'enablechunks' ){ |
| 131 | + js_log( 'this.chunks_supported = true' ); |
| 132 | + _this.chunks_supported = true; |
| 133 | + break; |
| 134 | + } |
| 135 | + } |
| 136 | + } |
| 137 | + _this.doUploadSwitch(); |
| 138 | + }); |
| 139 | + }else{ |
| 140 | + _this.doUploadSwitch(); |
| 141 | + } |
| 142 | + }, |
| 143 | + doUploadSwitch:function(){ |
| 144 | + |
| 145 | + js_log('mvUPload:doUploadSwitch()'); |
| 146 | + var _this = this; |
| 147 | + //issue a normal post request |
| 148 | + if( _this.upload_mode == 'post' || $j('#wpSourceTypeFile').get(0).checked ){ |
| 149 | + js_log('do normal submit form'); |
| 150 | + //update the status |
| 151 | + _this.updateEmptyLoadingStatus(); |
| 152 | + |
| 153 | + //do normal post upload no status indicators (also since its a file I think we have to submit the form) |
| 154 | + _this.form_post_override = true; |
| 155 | + |
| 156 | + //trick the browser into thinking the wpUpload button was pressed (there might be a cleaner way to do this) |
| 157 | + $j(_this.editForm).append('<input type="hidden" name="wpUpload" value="' + $j('#wpUpload').val() + '"/>'); |
| 158 | + |
| 159 | + //@@todo support firefox 3.0 ajax file upload progress |
| 160 | + //http://igstan.blogspot.com/2009/01/pure-javascript-file-upload.html |
| 161 | + |
| 162 | + //do the submit : |
| 163 | + _this.editForm.submit(); |
| 164 | + return true; |
| 165 | + }else if( _this.upload_mode == 'api' && $j('#wpSourceTypeURL').get(0).checked){ |
| 166 | + js_log('doHttpUpload (no form submit) '); |
| 167 | + //if the api is supported.. && source type is http do upload with http status updates |
| 168 | + _this.doHttpUpload(); |
| 169 | + }else{ |
| 170 | + js_error( 'Error: unrecongized upload mode: ' + _this.upload_mode ); |
| 171 | + } |
| 172 | + return false; |
| 173 | + }, |
| 174 | + doHttpUpload:function(){ |
| 175 | + var _this = this; |
| 176 | + //set the http box to loading (in case we don't get an update for some time) |
| 177 | + $j('#dlbox-centered').html( '<h5>' + _this.getProgressTitle() + '</h5>' + |
| 178 | + mv_get_loading_img( 'left:40%;top:20%') |
| 179 | + ); |
| 180 | + //build the api query: |
| 181 | + do_api_req({ |
| 182 | + 'data':{ |
| 183 | + 'action' : 'upload', |
| 184 | + 'url' : $j('#wpUploadFileURL').val(), |
| 185 | + 'filename' : $j('#wpDestFile').val(), |
| 186 | + 'comment' : $j('#wpUploadDescription').val(), |
| 187 | + 'asyncdownload': true |
| 188 | + }, |
| 189 | + 'url' : _this.api_url |
| 190 | + }, function( data ){ |
| 191 | + _this.processApiResult( data ); |
| 192 | + }); |
| 193 | + }, |
| 194 | + doAjaxWarningIgnore:function(){ |
| 195 | + var _this = this; |
| 196 | + if( !_this.upload_session_key ) |
| 197 | + return js_error('missing upload_session_key (can\'t ignore warnigns'); |
| 198 | + //do the ignore warnings submit to the api: |
| 199 | + do_api_req({ |
| 200 | + 'data':{ |
| 201 | + 'ignorewarnings' : 'true', |
| 202 | + 'sessionkey' :!_this.upload_session_key |
| 203 | + }, |
| 204 | + 'url': _this.api_url |
| 205 | + },function(data){ |
| 206 | + _this.processApiResult(data); |
| 207 | + }); |
| 208 | + }, |
| 209 | + doAjaxUploadStatus:function() { |
| 210 | + var _this = this; |
| 211 | + |
| 212 | + //set up the progress display for status updates: |
| 213 | + _this.dispProgressOverlay(); |
| 214 | + |
| 215 | + var uploadStatus = function(){ |
| 216 | + //do the api request: |
| 217 | + do_api_req({ |
| 218 | + 'data':{ |
| 219 | + 'action' : 'upload', |
| 220 | + 'httpstatus' : 'true', |
| 221 | + 'sessionkey' : _this.upload_session_key |
| 222 | + }, |
| 223 | + 'url' : _this.api_url |
| 224 | + }, function( data ){ |
| 225 | + //@@check if we are done |
| 226 | + if( data.upload['apiUploadResult'] ){ |
| 227 | + //update status to 100% |
| 228 | + _this.updateProgress( 1 ); |
| 229 | + if(typeof JSON == 'undefined'){ |
| 230 | + //we need to load the jQuery json parser: (older browsers don't have JSON.parse |
| 231 | + mvJsLoader.doLoad({ |
| 232 | + '$j.secureEvalJSON':'jquery/plugins/jquery.json-1.3.js' |
| 233 | + },function(){ |
| 234 | + var apiResult = $j.secureEvalJSON( data.upload['apiUploadResult'] ); |
| 235 | + _this.processApiResult( apiResult ); |
| 236 | + }); |
| 237 | + }else{ |
| 238 | + var apiResult = {}; |
| 239 | + try{ |
| 240 | + apiResult = JSON.parse ( data.upload['apiUploadResult'] ) ; |
| 241 | + }catch (e){ |
| 242 | + //could not parse api result |
| 243 | + js_log('errro: could not parse apiUploadResult ') |
| 244 | + } |
| 245 | + _this.processApiResult( apiResult ); |
| 246 | + } |
| 247 | + return ; |
| 248 | + } |
| 249 | + |
| 250 | + //@@ else update status: |
| 251 | + if( data.upload['content_length'] && data.upload['loaded'] ){ |
| 252 | + //we have content length we can show percentage done: |
| 253 | + var perc = data.upload['loaded'] / data.upload['content_length']; |
| 254 | + //update the status: |
| 255 | + _this.updateProgress( perc ); |
| 256 | + //special case update the file progress where we have data size: |
| 257 | + $j('#upload-stats-fileprogres').html( |
| 258 | + gM('upload-stats-fileprogres', [ |
| 259 | + formatSize( data.upload['loaded'] ), |
| 260 | + formatSize( data.upload['content_length'] ) |
| 261 | + ] |
| 262 | + ) |
| 263 | + ); |
| 264 | + }else if( data.upload['loaded'] ){ |
| 265 | + //for lack of content-length requests: |
| 266 | + $j('#upload-stats-fileprogres').html( |
| 267 | + gM('upload-stats-fileprogres', [ |
| 268 | + formatSize( data.upload['loaded'] ), |
| 269 | + gM('upload-unknown-size') |
| 270 | + ] |
| 271 | + ) |
| 272 | + ); |
| 273 | + } |
| 274 | + //(we got a result) set it to 100ms + your server update interval (in our case 2s) |
| 275 | + setTimeout(uploadStatus, 2100); |
| 276 | + }); |
| 277 | + } |
| 278 | + uploadStatus(); |
| 279 | + }, |
| 280 | + processApiResult: function( apiRes ){ |
| 281 | + var _this = this; |
| 282 | + |
| 283 | + //check for upload api error: |
| 284 | + // {"upload":{"result":"Failure","error":"unknown-error","code":{"status":5,"filtered":"NGC2207%2BIC2163.jpg"}}} |
| 285 | + if( apiRes.error || ( apiRes.upload && apiRes.upload.result == "Failure" ) ){ |
| 286 | + |
| 287 | + //check a few places for the error code: |
| 288 | + var error_code=0; |
| 289 | + if( apiRes.error && apiRes.error.code ){ |
| 290 | + error_code = apiRes.error.code; |
| 291 | + }else if( apiRes.upload.code ){ |
| 292 | + if(typeof apiRes.upload.code == 'object'){ |
| 293 | + if(apiRes.upload.code[0]){ |
| 294 | + error_code = apiRes.upload.code[0]; |
| 295 | + } |
| 296 | + if(apiRes.upload.code['status']){ |
| 297 | + error_code = apiRes.upload['status']; |
| 298 | + } |
| 299 | + }else{ |
| 300 | + apiRes.upload.code; |
| 301 | + } |
| 302 | + } |
| 303 | + |
| 304 | + var error_msg = ''; |
| 305 | + if(typeof apiRes.error == 'string') |
| 306 | + error_msg = apiRes.error; |
| 307 | + //error space is too large so we don't front load it |
| 308 | + //do a remote call to get the error msg: |
| 309 | + if(!error_code || error_code == 'unknown-error'){ |
| 310 | + if(typeof JSON != 'undefined'){ |
| 311 | + js_log('Error: apiRes: ' + JSON.stringify( apiRes) ); |
| 312 | + } |
| 313 | + _this.updateUploadError( gM('unknown-error') + '<br>' + error_msg); |
| 314 | + }else{ |
| 315 | + gMsgLoadRemote(error_code, function(){ |
| 316 | + js_log('send msg: ' + gM( error_code )); |
| 317 | + _this.updateUploadError( gM( error_code )); |
| 318 | + }); |
| 319 | + } |
| 320 | + js_log("api.erorr"); |
| 321 | + return ; |
| 322 | + } |
| 323 | + //check for upload_session key for async upload: |
| 324 | + if( apiRes.upload && apiRes.upload.upload_session_key ){ |
| 325 | + //set the session key |
| 326 | + _this.upload_session_key = apiRes.upload.upload_session_key; |
| 327 | + |
| 328 | + //do ajax upload status: |
| 329 | + _this.doAjaxUploadStatus(); |
| 330 | + js_log("set upload_session_key: " + _this.upload_session_key); |
| 331 | + return ; |
| 332 | + } |
| 333 | + |
| 334 | + if( apiRes.upload.imageinfo && apiRes.upload.imageinfo.descriptionurl ){ |
| 335 | + _this.updateUploadDone( apiRes.upload.imageinfo.descriptionurl ); |
| 336 | + js_log('apiRes.upload.imageinfo:: updateUploadDone'); |
| 337 | + return ; |
| 338 | + } |
| 339 | + |
| 340 | + //check for upload error: |
| 341 | + if( apiRes.upload && apiRes.upload.error){ |
| 342 | + js_log(' apiRes.upload.error: ' + apiRes.upload.error ); |
| 343 | + return ; |
| 344 | + } |
| 345 | + //check for known warnings: |
| 346 | + if( apiRes.upload.warnings ){ |
| 347 | + //debugger; |
| 348 | + var wmsg = '<ul>'; |
| 349 | + for(var wtype in apiRes.upload.warnings){ |
| 350 | + var winfo = apiRes.upload.warnings[wtype] |
| 351 | + wmsg+='<li>'; |
| 352 | + switch(wtype){ |
| 353 | + case 'duplicate': |
| 354 | + case 'exists': |
| 355 | + if(winfo[1] && winfo[1].title && winfo[1].title.mTextform){ |
| 356 | + wmsg += gM('file-exists-duplicate') +' '+ |
| 357 | + '<b>' + winfo[1].title.mTextform + '</b>'; |
| 358 | + }else{ |
| 359 | + //misc error (weird that winfo[1] not present |
| 360 | + wmsg += gM('upload-misc-error') + ' ' + wtype; |
| 361 | + } |
| 362 | + break; |
| 363 | + case 'file-thumbnail-no': |
| 364 | + wmsg += gM('file-thumbnail-no', winfo); |
| 365 | + break; |
| 366 | + default: |
| 367 | + wmsg += gM('upload-misc-error') + ' ' + wtype; |
| 368 | + break; |
| 369 | + } |
| 370 | + wmsg+='</li>'; |
| 371 | + } |
| 372 | + wmsg+='</ul>'; |
| 373 | + if( apiRes.upload.warnings.sessionkey) |
| 374 | + _this.warnings_sessionkey = apiRes.upload.warnings.sessionkey; |
| 375 | + _this.updateUploadWarning( wmsg ); |
| 376 | + return false; |
| 377 | + } |
| 378 | + |
| 379 | + //nothing fits assume unkown error: |
| 380 | + js_log('could not parse upload api request result'); |
| 381 | + _this.updateUploadError( gM('unknown-error')); |
| 382 | + return false; |
| 383 | + |
| 384 | + }, |
| 385 | + updateUploadWarning:function( msg ){ |
| 386 | + $j( '#dlbox-centered' ).html( '<h3>' + gM('uploadwarning') + '</h3>' + |
| 387 | + msg + '<p>' + |
| 388 | + '<a id="mv-ignore-warnings">' + gM('ignorewarning') + '</a>' |
| 389 | + ); |
| 390 | + //setup ignore warnings binding and ajax query: |
| 391 | + }, |
| 392 | + updateUploadError:function( msg ){ |
| 393 | + $j( '#dlbox-centered' ).html( '<h3>' + gM('uploaderror') + '</h3>' + |
| 394 | + msg + '<p>' + |
| 395 | + '<a id="mv-return-to-form" href="#" >' + gM('return-to-form') + '</a>'); |
| 396 | + $j('#mv-return-to-form').click(function(){ |
| 397 | + //hide / close up shop |
| 398 | + $j('#dlbox-overlay,#dlbox-centered').hide(); |
| 399 | + return false; |
| 400 | + }); |
| 401 | + }, |
| 402 | + updateUploadDone:function( url ){ |
| 403 | + $j( '#dlbox-centered' ).html( '<h3>' + gM('successfulupload') + '</h3>' + |
| 404 | + gM( 'mv_upload_done', url) ); |
| 405 | + }, |
| 406 | + updateEmptyLoadingStatus:function(){ |
| 407 | + $j('#dlbox-centered').html( '<h5>' + _this.getProgressTitle() + '</h5>' + |
| 408 | + mv_get_loading_img( 'left:40%;top:20%') |
| 409 | + ); |
| 410 | + }, |
| 411 | + getProgressTitle:function(){ |
| 412 | + return gM('upload-in-progress'); |
| 413 | + }, |
| 414 | + getEditForm:function(){ |
| 415 | + this.editForm = $j( '#mw-upload-form' ).get(0); |
| 416 | + }, |
| 417 | + updateProgress:function( perc ){ |
| 418 | + js_log('updateProgress::' + perc); |
| 419 | + $j( '#up-progressbar' ).css( 'width', parseInt( perc * 100 ) + '%' ); |
| 420 | + $j( '#up-pstatus' ).html( parseInt( perc * 100 ) + '% - ' ); |
| 421 | + }, |
| 422 | + /*update to jQuery.ui progress display type */ |
| 423 | + dispProgressOverlay:function(){ |
| 424 | + var _this = this; |
| 425 | + //remove old instance: |
| 426 | + $j('#dlbox-centered,#dlbox-overlay').remove(); |
| 427 | + //hard code style (since not always easy to import style sheets) |
| 428 | + $j('body').append('<div id="dlbox-centered" class="dlbox-centered" style="'+ |
| 429 | + 'position:fixed;background:#DDD;border:3px solid #AAA;font-size:115%;width:40%;'+ |
| 430 | + 'height:300px;padding: 10px;z-index:100;top:100px;bottom:40%;left:20%;" >'+ |
| 431 | + '<h5>' + _this.getProgressTitle() + '</h5>' + |
| 432 | + '<div id="up-pbar-container" style="border:solid thin gray;width:90%;height:15px;" >' + |
| 433 | + '<div id="up-progressbar" style="background:#AAC;width:0%;height:15px;"></div>' + |
| 434 | + '</div>' + |
| 435 | + '<span id="up-pstatus">0% - </span> ' + |
| 436 | + '<span id="up-status-state">' + gM('uploaded-status') + '</span> ' + |
| 437 | + '<span id="upload-stats-fileprogres"></span>'+ |
| 438 | + '</div>' + |
| 439 | + '<div id="dlbox-overlay" class="dlbox-overlay" style="background:#000;cursor:wait;height:100%;'+ |
| 440 | + 'left:0;top:0;position:fixed;width:100%;z-index:99;filter:alpha(opacity=60);'+ |
| 441 | + '-moz-opacity: 0.6; opacity: 0.6;" ></div>'); |
| 442 | + //fade them in: |
| 443 | + $j('#dlbox-centered,#dlbox-overlay').show(); |
| 444 | + } |
| 445 | +} |
Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/mvAdvFirefogg.js |
— | — | @@ -4,7 +4,6 @@ |
5 | 5 | |
6 | 6 | //@@todo put all msg text into loadGM json |
7 | 7 | |
8 | | - |
9 | 8 | var mvAdvFirefogg = function( initObj ){ |
10 | 9 | return this.init( initObj ); |
11 | 10 | } |
— | — | @@ -12,23 +11,17 @@ |
13 | 12 | //which config groups to include |
14 | 13 | 'config_groups' : ['preset', 'quality', 'meta', 'advVideo', 'advAudio'], |
15 | 14 | |
16 | | - //if you want to load any custom presets to chose from |
| 15 | + //if you want to load any custom presets must follow the mvAdvFirefogg.presetConf json outline below |
17 | 16 | 'custom_presets' : {}, |
18 | 17 | |
19 | 18 | //any firefog config properties that may need to be excluded from options |
20 | 19 | 'exclude_settings' : [], |
21 | 20 | |
22 | | - //taget buttons: |
23 | | - 'btn_select_file' : '', |
24 | | - 'btn_select_new_file': '', |
25 | | - 'btn_save_local_file': '', |
26 | | - |
27 | 21 | //the control container (where we put all the controls) |
28 | 22 | 'control_container' : '' |
29 | 23 | } |
30 | 24 | |
31 | | -mvAdvFirefogg.prototype = { |
32 | | - |
| 25 | +mvAdvFirefogg.prototype = { |
33 | 26 | //the global groupings and titles for for configuration options : |
34 | 27 | config_groups :{ |
35 | 28 | 'preset' : "Preset: $1", |
— | — | @@ -216,24 +209,24 @@ |
217 | 210 | 'help' : "Contact link" |
218 | 211 | } |
219 | 212 | }, |
220 | | - //inherit mvFirefog (which provides access point to ogg and inherits mvUploader) |
221 | | - init:function( initObj ){ |
| 213 | + init:function( initObj ){ |
222 | 214 | //setup a "supported" initObj: |
223 | 215 | for(var i in initObj){ |
224 | | - if( default_mvAdvFirefogg_config [i] ){ |
225 | | - this[i] = initObj[i]; |
| 216 | + if( typeof default_mvAdvFirefogg_config [i] != 'undefined' ){ |
| 217 | + this[i] = initObj[i]; |
| 218 | + } |
| 219 | + } |
| 220 | + //inherit the base mvFirefogg class: |
| 221 | + var myFogg = new mvFirefogg( initObj ); |
| 222 | + for(var i in myFogg){ |
| 223 | + if( typeof this[i] != 'undefined'){ |
| 224 | + this[ 'pfogg_' + i ] = mvFogg[i]; |
| 225 | + }else{ |
| 226 | + this[ i ] = mvFogg[i]; |
226 | 227 | } |
227 | 228 | } |
228 | | - //do inherit myFogg: |
229 | | - var myFogg = new mvFirefogg ( {} ) |
230 | | - for(var i in myFogg){ |
231 | | - if(this[i]) |
232 | | - this['parent_'+i] = myFogg[i]; |
233 | | - else |
234 | | - this[i] = myFogg[i]; |
235 | | - } |
236 | 229 | }, |
237 | | - setupForm:function(){ |
| 230 | + setupForm:function(){ |
238 | 231 | //if we have a target control form gennerate the html and setup the bindings |
239 | 232 | if( this.control_container != ''){ |
240 | 233 | //gennerate the control html |
— | — | @@ -423,5 +416,30 @@ |
424 | 417 | collapsible: true, |
425 | 418 | active: false |
426 | 419 | }); |
| 420 | + }, |
| 421 | + //sets up the local settings for the encode (restored from a cookie if you have them) |
| 422 | + setupSettings:function( force ){ |
| 423 | + if(!force){ |
| 424 | + if($.cookie('firefogg_settings')){ |
| 425 | + firefogg_settings = JSON.parse( $.cookie('firefogg_settings') ); |
| 426 | + } |
| 427 | + } |
| 428 | + for(var i in firefogg_defaults){ |
| 429 | + if( firefogg_defaults[i]['d'] ){ |
| 430 | + firefogg_settings[i] = firefogg_defaults[i]['d']; |
| 431 | + } |
| 432 | + } |
| 433 | + setValuesInHtml(); |
| 434 | + }, |
| 435 | + setValuesInHtml:function(){ |
| 436 | + //set the actual HTML: |
| 437 | + $.each(firefogg_settings, function(inx, val){ |
| 438 | + if($j('#_'+inx).length !=0){ |
| 439 | + $j('#_'+inx).val( val ); |
| 440 | + } |
| 441 | + }) |
| 442 | + }, |
| 443 | + saveSettings:function(){ |
| 444 | + $j.cookie('firefogg_settings', JSON.stringify( firefogg_settings ) ); |
427 | 445 | } |
428 | 446 | } |
\ No newline at end of file |
Index: branches/new-upload/phase3/js2/uploadPage.js |
— | — | @@ -3,43 +3,162 @@ |
4 | 4 | * controls the invocation of the mvUploader class based on local config. |
5 | 5 | */ |
6 | 6 | mwAddOnloadHook( function(){ |
7 | | - //setup the upload handler for firefogg and normal uploads: |
8 | | - mvJsLoader.doLoad( { |
9 | | - 'mvFirefogg' : 'libAddMedia/mvFirefogg.js', |
10 | | - 'mvUploader' : 'libAddMedia/mvUploader.js' |
11 | | - },function(){ |
12 | | - mvUp = new mvUploader( { 'api_url' : wgServer + wgScriptPath + '/api.php' } ); |
13 | | - setupUploadFormBindings( mvUp ); |
14 | | - }); |
| 7 | + mwUploadHelper.init(); |
15 | 8 | }); |
16 | 9 | //set up the upoload form bindings once all dom manipluation is done |
17 | | -function setupUploadFormBindings( mvUp ){ |
18 | | - if( wgAjaxUploadDestCheck ){ |
19 | | - //do destination check: |
20 | | - $j('#wpDestFile').change( mvUp.doDestCheck ); |
21 | | - } |
22 | | - //check if we have http enabled & setup enable/disable toggle: |
23 | | - if($j('#wpUploadFileURL').length != 0){ |
24 | | - var toggleUpType = function( set ){ |
25 | | - $j('#wpSourceTypeFile').get(0).checked = set; |
26 | | - $j('#wpUploadFile').get(0).disabled = !set; |
| 10 | +var mwUploadHelper = { |
| 11 | + init:function(){ |
| 12 | + if( wgEnableFirefogg ){ |
| 13 | + //setup the upload handler to firefogg (supports our upload proccess) |
| 14 | + $j('#wpUploadFile').firefogg({ |
| 15 | + //an api url (we won't submit directly to action of the form) if the api supports action=upload: |
| 16 | + 'api_url' : wgServer + wgScriptPath + '/api.php', |
| 17 | + |
| 18 | + 'new_source_cb' : function( filename ){ |
| 19 | + $j('#wpDestFile').val( filename ) |
| 20 | + mwUploadHelper.doDestCheck(); |
| 21 | + } |
| 22 | + }); |
| 23 | + }else{ |
| 24 | + //we can try and do basic upload profile support ( http status monitoring, progress box for browsers that support it etc. ) |
| 25 | + } |
| 26 | + |
| 27 | + if( wgAjaxUploadDestCheck ){ |
| 28 | + //do destination check: |
| 29 | + $j('#wpDestFile').change( mwUploadHelper.doDestCheck ); |
| 30 | + } |
| 31 | + //check if we have http enabled & setup enable/disable toggle: |
| 32 | + if($j('#wpUploadFileURL').length != 0){ |
| 33 | + var toggleUpType = function( set ){ |
| 34 | + $j('#wpSourceTypeFile').get(0).checked = set; |
| 35 | + $j('#wpUploadFile').get(0).disabled = !set; |
| 36 | + |
| 37 | + $j('#wpSourceTypeURL').get(0).checked = !set; |
| 38 | + $j('#wpUploadFileURL').get(0).disabled = set; |
| 39 | + } |
| 40 | + //set the initial toggleUpType |
| 41 | + toggleUpType(true); |
27 | 42 | |
28 | | - $j('#wpSourceTypeURL').get(0).checked = !set; |
29 | | - $j('#wpUploadFileURL').get(0).disabled = set; |
| 43 | + $j("input[name='wpSourceType']").click(function(){ |
| 44 | + toggleUpType( this.id == 'wpSourceTypeFile' ); |
| 45 | + }); |
| 46 | + } |
| 47 | + $j('#wpUploadFile,#wpUploadFileURL').focus(function(){ |
| 48 | + toggleUpType( this.id == 'wpUploadFile' ); |
| 49 | + }).change(function(){ //also setup the onChange event binding: |
| 50 | + if ( wgUploadAutoFill ) { |
| 51 | + mvUp.doDestinationFill( this ); |
| 52 | + } |
| 53 | + }); |
| 54 | + }, |
| 55 | + /** |
| 56 | + * doDestCheck checks the destination |
| 57 | + * @@todo we should be able to configure its "targets" via parent config |
| 58 | + */ |
| 59 | + doDestCheck:function(){ |
| 60 | + var _this = this; |
| 61 | + $j('#wpDestFile-warning').empty(); |
| 62 | + //show loading |
| 63 | + $j('#wpDestFile').after('<img id = "mw-spinner-wpDestFile" src ="'+ stylepath + '/common/images/spinner.gif" />'); |
| 64 | + //try and get a thumb of the current file (check its destination) |
| 65 | + do_api_req({ |
| 66 | + 'data':{ |
| 67 | + 'titles': 'File:' + $j('#wpDestFile').val(),//@@todo we may need a more clever way to get a the filename |
| 68 | + 'prop': 'imageinfo', |
| 69 | + 'iiprop':'url|mime|size', |
| 70 | + 'iiurlwidth': 150 |
| 71 | + }, |
| 72 | + 'url': _this.api_url |
| 73 | + },function(data){ |
| 74 | + $j('#mw-spinner-wpDestFile').remove(); |
| 75 | + if(data && data.query && data.query.pages){ |
| 76 | + if( data.query.pages[-1] ){ |
| 77 | + //all good no file there |
| 78 | + }else{ |
| 79 | + for(var page_id in data.query.pages){ |
| 80 | + if( data.query.normalized){ |
| 81 | + var ntitle = data.query.normalized[0].to; |
| 82 | + }else{ |
| 83 | + var ntitle = data.query.pages[ page_id ].title; |
| 84 | + } |
| 85 | + var img = data.query.pages[ page_id ].imageinfo[0]; |
| 86 | + $j('#wpDestFile-warning').html( |
| 87 | + '<ul>' + |
| 88 | + '<li>'+ |
| 89 | + gM('fileexists', ntitle) + |
| 90 | + '</li>'+ |
| 91 | + '<div class="thumb tright">' + |
| 92 | + '<div style="width: ' + ( parseInt(img.thumbwidth)+2 ) + 'px;" class="thumbinner">' + |
| 93 | + '<a title="' + ntitle + '" class="image" href="' + img.descriptionurl + '">' + |
| 94 | + '<img width="' + img.thumbwidth + '" height="' + img.thumbheight + '" border="0" class="thumbimage" ' + |
| 95 | + 'src="' + img.thumburl + '"' + |
| 96 | + ' alt="' + ntitle + '"/>' + |
| 97 | + '</a>' + |
| 98 | + '<div class="thumbcaption">' + |
| 99 | + '<div class="magnify">' + |
| 100 | + '<a title="' + gM('thumbnail-more') + '" class="internal" ' + |
| 101 | + 'href="' + img.descriptionurl +'"><img width="15" height="11" alt="" ' + |
| 102 | + 'src="' + stylepath +"/>" + |
| 103 | + '</a>'+ |
| 104 | + '</div>'+ |
| 105 | + gM('fileexists-thumb') + |
| 106 | + '</div>' + |
| 107 | + '</div>'+ |
| 108 | + '</div>' + |
| 109 | + '</ul>' |
| 110 | + ); |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + }); |
| 115 | + }, |
| 116 | + /** |
| 117 | + * doDestinationFill fills in a destination file-name based on a source asset name. |
| 118 | + * @@todo we should be able to configure its "targets" via parent config |
| 119 | + */ |
| 120 | + doDestinationFill:function( targetElm ){ |
| 121 | + js_log("doDestinationFill") |
| 122 | + //remove any previously flagged errors |
| 123 | + $j('#mw-upload-permitted,#mw-upload-prohibited').hide(); |
| 124 | + |
| 125 | + var path = $j(targetElm).val(); |
| 126 | + // Find trailing part |
| 127 | + var slash = path.lastIndexOf('/'); |
| 128 | + var backslash = path.lastIndexOf('\\'); |
| 129 | + var fname; |
| 130 | + if (slash == -1 && backslash == -1) { |
| 131 | + fname = path; |
| 132 | + } else if (slash > backslash) { |
| 133 | + fname = path.substring(slash+1, 10000); |
| 134 | + } else { |
| 135 | + fname = path.substring(backslash+1, 10000); |
30 | 136 | } |
31 | | - //set the initial toggleUpType |
32 | | - toggleUpType(true); |
33 | | - |
34 | | - $j("input[name='wpSourceType']").click(function(){ |
35 | | - toggleUpType( this.id == 'wpSourceTypeFile' ); |
36 | | - }); |
| 137 | + //urls are less likely to have a usefull extension don't include them in the extention check |
| 138 | + if( wgFileExtensions && $j(targetElm).attr('id') != 'wpUploadFileURL' ){ |
| 139 | + var found = false; |
| 140 | + if( fname.lastIndexOf('.')!=-1 ){ |
| 141 | + var ext = fname.substr( fname.lastIndexOf('.')+1 ); |
| 142 | + for(var i=0; i < wgFileExtensions.length; i++){ |
| 143 | + if( wgFileExtensions[i].toLowerCase() == ext.toLowerCase() ) |
| 144 | + found = true; |
| 145 | + } |
| 146 | + } |
| 147 | + if(!found){ |
| 148 | + //clear the upload set mw-upload-permitted to error |
| 149 | + $j(targetElm).val(''); |
| 150 | + $j('#mw-upload-permitted,#mw-upload-prohibited').show().addClass('error'); |
| 151 | + //clear the wpDestFile as well: |
| 152 | + $j('#wpDestFile').val(''); |
| 153 | + return false; |
| 154 | + } |
| 155 | + } |
| 156 | + // Capitalise first letter and replace spaces by underscores |
| 157 | + fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_'); |
| 158 | + // Output result |
| 159 | + $j('#wpDestFile').val( fname ); |
| 160 | + |
| 161 | + //do a destination check |
| 162 | + this.doDestCheck(); |
37 | 163 | } |
| 164 | +} |
38 | 165 | |
39 | | - $j('#wpUploadFile,#wpUploadFileURL').focus(function(){ |
40 | | - toggleUpType( this.id == 'wpUploadFile' ); |
41 | | - }).change(function(){ //also setup the onChange event binding: |
42 | | - if ( wgUploadAutoFill ) { |
43 | | - mvUp.doDestinationFill( this ); |
44 | | - } |
45 | | - }); |
46 | | -} |
Index: branches/new-upload/phase3/includes/DefaultSettings.php |
— | — | @@ -440,7 +440,15 @@ |
441 | 441 | $wgMaxUploadSize = 1024*1024*100; # 100MB |
442 | 442 | |
443 | 443 | |
| 444 | +/** |
| 445 | +* Enable firefogg support |
| 446 | +* add support for in-browser transcoding to ogg theora |
| 447 | +* add support for chunk uploads for large image files |
| 448 | +* add support for client side hash checks |
| 449 | +*/ |
| 450 | +$wgEnableFirefogg = true; |
444 | 451 | |
| 452 | + |
445 | 453 | /** |
446 | 454 | * Point the upload navigation link to an external URL |
447 | 455 | * Useful if you want to use a shared repository by default |
Index: branches/new-upload/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -561,7 +561,7 @@ |
562 | 562 | * @access private |
563 | 563 | */ |
564 | 564 | function mainUploadForm( $msg='' ) { |
565 | | - global $wgOut, $wgUser, $wgLang, $wgMaxUploadSize; |
| 565 | + global $wgOut, $wgUser, $wgLang, $wgMaxUploadSize, $wgEnableFirefogg; |
566 | 566 | global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview; |
567 | 567 | global $wgRequest; |
568 | 568 | global $wgStylePath, $wgStyleVersion; |
— | — | @@ -571,11 +571,14 @@ |
572 | 572 | |
573 | 573 | $adc = wfBoolToStr( $useAjaxDestCheck ); |
574 | 574 | $alp = wfBoolToStr( $useAjaxLicensePreview ); |
575 | | - $autofill = wfBoolToStr( $this->mDesiredDestName == '' ); |
| 575 | + $uef = wfBoolToStr( $wgEnableFirefogg ); |
| 576 | + $autofill = wfBoolToStr( $this->mDesiredDestName == '' ); |
| 577 | + |
576 | 578 | |
577 | 579 | $wgOut->addScript( "<script type=\"text/javascript\"> |
578 | 580 | wgAjaxUploadDestCheck = {$adc}; |
579 | 581 | wgAjaxLicensePreview = {$alp}; |
| 582 | +wgEnableFirefogg = {$uef}; |
580 | 583 | wgUploadAutoFill = {$autofill}; |
581 | 584 | </script>" ); |
582 | 585 | //legacy upload code: |