Index: branches/uploadwizard-firefogg/resources/mw.FirefoggTransport.js |
— | — | @@ -33,6 +33,7 @@ |
34 | 34 | } |
35 | 35 | }, |
36 | 36 | isChunkUpload: function(){ |
| 37 | + // for now just test post |
37 | 38 | return false; |
38 | 39 | return ( mw.UploadWizard.config[ 'enableFirefoggChunkUpload' ] ); |
39 | 40 | }, |
— | — | @@ -41,9 +42,9 @@ |
42 | 43 | */ |
43 | 44 | isPassThrough: function(){ |
44 | 45 | // Check if the server supports raw webm uploads: |
45 | | - var wembExt = ( $j.inArray( mw.UploadWizard.config[ 'fileExtensions'], 'webm') !== -1 ) |
| 46 | + var wembExt = ( $j.inArray( 'webm', mw.UploadWizard.config[ 'fileExtensions'] ) !== -1 ) |
46 | 47 | // Determine passthrough mode |
47 | | - if ( this.isOggFormat() || ( wembExt && isWebMFormat() ) ) { |
| 48 | + if ( this.isOggFormat() || ( wembExt && this.isWebMFormat() ) ) { |
48 | 49 | // Already Ogg, no need to encode |
49 | 50 | return true; |
50 | 51 | } else if ( this.isSourceAudio() || this.isSourceVideo() ) { |
— | — | @@ -107,20 +108,23 @@ |
108 | 109 | getEncodeExt: function(){ |
109 | 110 | if( this.getEncodeSettings()['videoCodec'] |
110 | 111 | && |
111 | | - this.getEncodeSettings()['videoCodec'] == 'vp8' ) |
112 | | - { |
| 112 | + this.getEncodeSettings()['videoCodec'] == 'vp8' ) |
| 113 | + { |
113 | 114 | return 'webm'; |
114 | 115 | } else { |
115 | 116 | return 'ogv'; |
116 | 117 | } |
117 | 118 | }, |
| 119 | + |
118 | 120 | /** |
119 | 121 | * Get the encode settings from configuration and the current selected video type |
120 | 122 | */ |
121 | 123 | getEncodeSettings: function(){ |
122 | | - var encodeSettings = $j.extend( {}, mw.UploadWizard.config[ 'firefoggEncodeSettings'] , { |
123 | | - 'passthrough' : this.isPassThrough() |
124 | | - }); |
| 124 | + if( this.isPassThrough() ){ |
| 125 | + return { 'passthrough' : true } ; |
| 126 | + } |
| 127 | + // Get the default encode settings: |
| 128 | + var encodeSettings = mw.UploadWizard.config[ 'firefoggEncodeSettings']; |
125 | 129 | // Update the format: |
126 | 130 | this.fogg.setFormat( ( this.getEncodeExt == 'webm' )? 'webm' : 'ogg' ); |
127 | 131 | |
— | — | @@ -132,18 +136,12 @@ |
133 | 137 | * Encode then upload |
134 | 138 | */ |
135 | 139 | doEncodeThenUpload: function(){ |
136 | | - // If doing passthrough jump direct to upload: |
137 | | - if( this.isPassThrough() ){ |
138 | | - this.doFoggPost(); |
139 | | - return ; |
140 | | - } |
141 | 140 | this.fogg.encode( JSON.stringify( this.getEncodeSettings() ) ); |
142 | | - |
143 | 141 | this.monitorProgress(); |
144 | 142 | }, |
145 | 143 | |
146 | 144 | /** |
147 | | - * do fogg post |
| 145 | + * Do fogg post |
148 | 146 | */ |
149 | 147 | doFoggPost: function(){ |
150 | 148 | var _this = this; |
— | — | @@ -159,6 +157,7 @@ |
160 | 158 | _this.monitorProgress(); |
161 | 159 | } ); |
162 | 160 | }, |
| 161 | + |
163 | 162 | /** |
164 | 163 | * Encode and upload in chunks |
165 | 164 | */ |
— | — | @@ -173,6 +172,7 @@ |
174 | 173 | }); |
175 | 174 | _this.monitorProgress(); |
176 | 175 | }, |
| 176 | + |
177 | 177 | /** |
178 | 178 | * Get the upload url |
179 | 179 | */ |
— | — | @@ -228,7 +228,7 @@ |
229 | 229 | } |
230 | 230 | // return the api result: |
231 | 231 | if( state == 'done' || state == 'upload done' ){ |
232 | | - this.transportedCb( this.getResponseText() ); |
| 232 | + this.transportedCb( JSON.parse( this.getResponseText() ) ); |
233 | 233 | } |
234 | 234 | |
235 | 235 | }, |
Index: branches/uploadwizard-firefogg/resources/mw.UploadWizard.js |
— | — | @@ -96,10 +96,9 @@ |
97 | 97 | var _this = this; |
98 | 98 | if ( _this.state == 'aborted' ) { |
99 | 99 | return ; |
100 | | - } |
101 | | - |
| 100 | + } |
102 | 101 | if ( result.upload && result.upload.imageinfo ) { |
103 | | - mw.log( 'UploadWizard::setTransported> process api imageinfo' ); |
| 102 | + mw.log( 'UploadWizard::setTransported> process api imageinfo' ); |
104 | 103 | // success |
105 | 104 | _this.state = 'transported'; |
106 | 105 | _this.transportProgress = 1; |
— | — | @@ -108,7 +107,7 @@ |
109 | 108 | |
110 | 109 | // use blocking preload for thumbnail, no loading spinner. |
111 | 110 | _this.getThumbnail( |
112 | | - function( image ) { |
| 111 | + function( image ) { |
113 | 112 | _this.ui.setPreview( image ); |
114 | 113 | _this.deedPreview.setup(); |
115 | 114 | _this.details.populate(); |
— | — | @@ -248,15 +247,16 @@ |
249 | 248 | this.api.get( params, function( data ) { |
250 | 249 | if ( !data || !data.query || !data.query.stashimageinfo ) { |
251 | 250 | mw.log("mw.UploadWizardUpload::getThumbnail> No data? "); |
252 | | - // XXX do something about the thumbnail spinner, maybe call the callback with a broken image. |
| 251 | + // XXX do something about the thumbnail spinner, maybe call the callback with a broken image. |
253 | 252 | return; |
254 | 253 | } |
255 | 254 | var thumbnails = data.query.stashimageinfo; |
256 | | - for ( var i = 0; i < thumbnails.length; i++ ) { |
| 255 | + for ( var i = 0; i < thumbnails.length; i++ ) { |
257 | 256 | var thumb = thumbnails[i]; |
258 | 257 | if ( ! ( thumb.thumburl && thumb.thumbwidth && thumb.thumbheight ) ) { |
259 | 258 | mw.log( "mw.UploadWizardUpload::getThumbnail> thumbnail missing information" ); |
260 | 259 | // XXX error |
| 260 | + return ; |
261 | 261 | } |
262 | 262 | var image = document.createElement( 'img' ); |
263 | 263 | $j( image ).load( function() { |