stubs for select from url for firefogg
authorMichael Dale <dale@users.mediawiki.org>
Tue, 4 Aug 2009 17:42:31 +0000 (17:42 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Tue, 4 Aug 2009 17:42:31 +0000 (17:42 +0000)
js2/mwEmbed/libAddMedia/mvAdvFirefogg.js
js2/mwEmbed/libAddMedia/mvFirefogg.js

index 9bbc4a7..eb97042 100644 (file)
@@ -248,7 +248,7 @@ mvAdvFirefogg.prototype = {
                        'group' : 'meta',
                        'help'  : "Contact link"
                }
-       },
+       },      
        init:function( iObj ){                          
                //setup a "supported" iObj:
                for(var i in iObj){
@@ -321,15 +321,19 @@ mvAdvFirefogg.prototype = {
                                
        },
        //custom advanced target rewrites: 
-       getTargetHtml:function(target){         
+       getTargetHtml:function(target){                         
                if(     target=='target_btn_select_file' || 
-                       target=='target_btn_select_new_file'||
+                       target=='target_btn_select_new_file'||                  
                        target=='target_btn_save_local_file'){
-                       var icon = (target=='target_btn_save_local_file')?'ui-icon-video':'ui-icon-folder-open';
+                       var icon = (target=='target_btn_save_local_file')?'ui-icon-video':'ui-icon-folder-open';        
                        return   '<a class="ui-state-default ui-corner-all ui-icon_link '+
                                                target +'" href="#"><span class="ui-icon ' + icon + '"/>' + 
                                                gM( 'fogg-' + target.substring(11) ) +
                                        '</a>';
+               }else if(  target=='target_btn_select_url'){                    
+                       //return the btnHtml:
+                       return $j.btnHtml( gM( 'fogg-' + target.substring(11) ), target,  'link');
+                       
                }else if(       target=='target_use_latest_fox' || 
                                        target=='target_please_install' || 
                                        target == 'target_passthrough_mode'){
@@ -339,8 +343,8 @@ mvAdvFirefogg.prototype = {
                                        gM( 'fogg-' + target.substring(7)) +'</p>'+
                                '</div>';       
                }else if( target == 'target_input_file_name'){
-                       return '<input style="" class="text ui-widget-content ui-corner-all ' + target + '" '+
-                                       'type="text" value="' + gM( 'fogg-' + target.substring(11)) + '"/> ';
+                       return '<br><br><input style="" class="text ui-widget-content ui-corner-all ' + target + '" '+
+                                       'type="text" value="' + gM( 'fogg-' + target.substring(11)) + '" size="60" /> ';
                }else{
                        js_log('call : basefogg_getTargetHtml');
                        return this.basefogg_getTargetHtml(target);
@@ -423,10 +427,32 @@ mvAdvFirefogg.prototype = {
                }
                out+='</td></tr><tr><td colspan="2" height="10"></td></tr>';
                return out;
+       },
+       selectByUrl:function(){
+               var urlValue = prompt("Please enter the source media url you would like to transcode from.","http://");
+               if( urlValue ){                 
+                       //update the mode:
+                       this.sourceMode = 'url';
+                       this.sourceUrl = urlValue;                                                                                      
+                       this.selectFoggActions();
+                       this.autoEncoderSettings();
+                       //update the input target
+                       $j(this.target_input_file_name).unbind().val( urlValue ).removeAttr('readonly');                                
+               }
        },       
        doControlBindings:function(){
                var _this = this;
                _this.basefogg_doControlBindings();
+               //show the select by url if present:
+               /*$j( this.target_btn_select_url ).unbind(
+                       ).attr('disabled', false
+                       ).css({'display':'inline'}
+                       ).click(function(){                                     
+                               _this.selectByUrl();
+               });
+               */                      
+               
+               
                //hide the base advanced controls untill a file is selected:
                $j(this.target_control_container).hide();
                
index ddeb2ef..c412b4d 100644 (file)
@@ -5,6 +5,7 @@
 loadGM({ 
        "fogg-select_file"                      : "Select File", 
        "fogg-select_new_file"          : "Select New File",
+       "fogg-select_url"                       : "Select Url",
        "fogg-save_local_file"          : "Save Ogg",
        "fogg-check_for_fogg"           : "Checking for Firefogg <blink>...</blink>",
        "fogg-installed"                        : "Firefogg is Installed",
@@ -49,8 +50,11 @@ var default_firefogg_options = {
        //taget buttons: 
        'target_btn_select_file'        : false,
        'target_btn_select_new_file': false,    
-       'target_input_file_name'        : false,
-       'target_btn_save_local_file': false,    
+       
+       //'target_btn_select_url'               : false,
+       
+       'target_btn_save_local_file': false,
+       'target_input_file_name'        : false,        
        
        
        //target install descriptions 
@@ -78,12 +82,13 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface
                'videoBitrate': 400,
                'noUpscaling':true
        },      
-       sourceFileInfo:{},
-       ogg_extensions: ['ogg', 'ogv', 'oga'],
+       sourceFileInfo  : {},
+       ogg_extensions  : ['ogg', 'ogv', 'oga'],
        video_extensions: ['avi', 'mov', 'mp4', 'mp2', 'mpeg', 'mpeg2', 'mpeg4', 'dv', 'wmv'],
        
-       passthrough: false,
-
+       passthrough     : false,
+       sourceMode      : 'file',
+       
        init: function( iObj ){
                if(!iObj)
                        iObj = {};
@@ -144,9 +149,10 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface
                var out = '';           
                $j.each(default_firefogg_options, function(target, na){                 
                        if(target.substring(0, 6)=='target'){
+                               js_log('check for target html: ' + target);
                                //check for the target if missing add to the output: 
                                if( _this[target] === false){                                   
-                                       out+= _this.getTargetHtml(target) + ' ';
+                                       out += _this.getTargetHtml(target) + ' ';
                                        //update the target selector 
                                    _this[target] = _this.selector + ' .' + target;
                                }                                                                                       
@@ -194,7 +200,8 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface
                                ).css({'display':'inline'}
                                ).click(function(){                                     
                                        _this.selectFogg();
-                               });                             
+                               });                                                                             
+                               
                    //also setup the text file display on Click to select file:  
                    $j(this.target_input_file_name).unbind().attr('readonly', 'readonly').click(function(){                     
                        _this.selectFogg();
@@ -305,60 +312,64 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface
        },   
        selectFogg:function(){                  
                var _this = this;
-               if( _this.fogg.selectVideo() ) {                                        
-                       js_log('videoSelectReady');
-                       //if not already hidden hide select file and show "select new": 
-                       $j(_this.target_btn_select_file).hide();
-                       //show and setup binding for select new file: 
-                       $j(_this.target_btn_select_new_file).show().unbind().click(function(){
-                               //create new fogg instance:                              
-                               _this.fogg = new Firefogg();
-                               _this.selectFogg();
-                       });
-                       //update if we are in passthrough mode or going to encode                                       
-                       if( _this.fogg.sourceInfo && _this.fogg.sourceFilename ){                                                                       
-                               //update the source status
-                               try{
-                                       _this.sourceFileInfo = JSON.parse( _this.fogg.sourceInfo ) ;
-                               }catch (e){
-                                       js_error('error could not parse fogg sourceInfo');
-                               }                                       
-                                               
-                               //now setup encoder settings based source type:
-                               _this.autoEncoderSettings();                                    
-                               
-                               //if set to passthough update the interface:
-                               if(_this.encoder_settings['passthrough']==true){
-                                       $j(_this.target_passthrough_mode).show();
-                               }else{                                  
-                                       $j(_this.target_passthrough_mode).hide();       
-                                       //if set to encoder expose the encode button: 
-                                       if( !_this.form_rewrite ){
-                                               $j(_this.target_btn_save_local_file).show();
-                                       }
+               if(_this.fogg.selectVideo() ){                  
+                       this.selectFoggActions();                       
+               }
+       },
+       selectFoggActions:function(){
+               var _this = this;
+               js_log('videoSelectReady');
+               //if not already hidden hide select file and show "select new": 
+               $j(_this.target_btn_select_file).hide();
+               
+               //show and setup binding for select new file: 
+               $j(_this.target_btn_select_new_file).show().unbind().click(function(){
+                       //create new fogg instance:                              
+                       _this.fogg = new Firefogg();
+                       _this.selectFogg();
+               });
+               
+               //update if we are in passthrough mode or going to encode                                       
+               if( _this.fogg.sourceInfo && _this.fogg.sourceFilename  ){                                                                      
+                       //update the source status
+                       try{
+                               _this.sourceFileInfo = JSON.parse( _this.fogg.sourceInfo ) ;
+                       }catch (e){
+                               js_error('error could not parse fogg sourceInfo');
+                       }                                       
+                                       
+                       //now setup encoder settings based source type:
+                       _this.autoEncoderSettings();                                    
+                       
+                       //if set to passthough update the interface:
+                       if(_this.encoder_settings['passthrough']==true){
+                               $j(_this.target_passthrough_mode).show();
+                       }else{                                  
+                               $j(_this.target_passthrough_mode).hide();       
+                               //if set to encoder expose the encode button: 
+                               if( !_this.form_rewrite ){
+                                       $j(_this.target_btn_save_local_file).show();
                                }
-                               //~otherwise the encoding will be triggered by the form~
-                               
-                               //do source name update callback:       
-                               js_log(" should update: " + _this.target_input_file_name + ' to: ' + _this.fogg.sourceFilename );                                
-                               $j(_this.target_input_file_name).val(_this.fogg.sourceFilename).show();
-                               
-                               if(_this.new_source_cb){                                                                                                
-                                       if(_this.encoder_settings['passthrough']){
-                                               var fName = _this.fogg.sourceFilename
-                                       }else{  
-                                           var oggExt = (_this.isSourceAudio())?'oga':'ogg';
-                           oggExt = (_this.isSourceVideo())?'ogv':oggExt;
-                           oggExt = (_this.isUnknown())?'ogg':oggExt;
-                                           oggName = _this.fogg.sourceFilename.substr(0,
-                                                         _this.fogg.sourceFilename.lastIndexOf('.'));
-                                           var fName = oggName +'.'+ oggExt              
-                                       }
-                                       _this.new_source_cb( _this.fogg.sourceFilename , fName);
+                       }
+                       //~otherwise the encoding will be triggered by the form~
+                       
+                       //do source name update callback:       
+                       js_log(" should update: " + _this.target_input_file_name + ' to: ' + _this.fogg.sourceFilename );                                
+                       $j(_this.target_input_file_name).val(_this.fogg.sourceFilename).show();
+                       
+                       if(_this.new_source_cb){                                                                                                
+                               if(_this.encoder_settings['passthrough']){
+                                       var fName = _this.fogg.sourceFilename
+                               }else{  
+                                   var oggExt = (_this.isSourceAudio())?'oga':'ogg';
+                    oggExt = (_this.isSourceVideo())?'ogv':oggExt;
+                    oggExt = (_this.isUnknown())?'ogg':oggExt;
+                                   oggName = _this.fogg.sourceFilename.substr(0,
+                                                 _this.fogg.sourceFilename.lastIndexOf('.'));
+                                   var fName = oggName +'.'+ oggExt              
                                }
-                       }                                                                                                       
-               }else{
-                       //js_error("Firefogg error selecting file");
+                               _this.new_source_cb( _this.fogg.sourceFilename , fName);
+                       }
                }
        },
        saveLocalFogg:function(){