Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js |
— | — | @@ -302,7 +302,7 @@ |
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | | - // Otherwise show the "install Firefogg" message |
| 306 | + // Otherwise show the "install Firefogg" message |
307 | 307 | var upMsg = ( _this.form_type == 'upload' ) ? gM( 'fogg-for_improved_uploads' ) : ''; |
308 | 308 | var firefoggUrl = _this.getFirefoggInstallUrl(); |
309 | 309 | if( firefoggUrl ){ |
— | — | @@ -826,13 +826,15 @@ |
827 | 827 | |
828 | 828 | /** |
829 | 829 | * Do an upload, with the mode given by this.upload_mode |
| 830 | + * XXX should probably be dispatched from baseUploadInterface doUpload instead |
830 | 831 | */ |
831 | 832 | doUpload: function() { |
832 | 833 | var _this = this; |
833 | 834 | mw.log( "firefogg: doUpload:: " + |
834 | 835 | ( this.getFirefogg() ? 'on' : 'off' ) + |
835 | 836 | ' up mode:' + _this.upload_mode ); |
836 | | - |
| 837 | + |
| 838 | + _this.uploadBeginTime = (new Date()).getTime(); |
837 | 839 | // If Firefogg is disabled or doing an copyByUrl upload, just invoke the parent method |
838 | 840 | if( !this.getFirefogg() || this.isCopyUpload() ) { |
839 | 841 | _this.pe_doUpload(); |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.BaseUploadInterface.js |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | "mwe-upload-transcode-in-progress" : "Transcode and upload in progress (do not close this window)", |
13 | 13 | "mwe-upload-in-progress" : "Upload in progress (do not close this window)", |
14 | 14 | "mwe-upload-transcoded-status" : "Transcoded", |
| 15 | + "mwe-uploaded-time-remaining" : "Time remaining: $1", |
15 | 16 | "mwe-uploaded-status" : "Uploaded", |
16 | 17 | "mwe-upload-stats-fileprogress" : "$1 of $2", |
17 | 18 | "mwe-upload_completed" : "Your upload is complete", |
— | — | @@ -84,6 +85,11 @@ |
85 | 86 | // The DOM node for the upload form |
86 | 87 | form: false, |
87 | 88 | |
| 89 | + // The following are really state of the upload, not the interface. |
| 90 | + // we are currently only managing one, so this is okay... for now. |
| 91 | + uploadBeginTime: null, |
| 92 | + |
| 93 | + |
88 | 94 | /** |
89 | 95 | * Object initialisation |
90 | 96 | * @param {Object} options BaseUpload options see default_bui_options |
— | — | @@ -248,6 +254,7 @@ |
249 | 255 | */ |
250 | 256 | doUpload: function() { |
251 | 257 | // Note "api" should be called "http_copy_upload" and /post/ should be "form_upload" |
| 258 | + this.uploadBeginTime = (new Date()).getTime(); |
252 | 259 | if ( this.upload_mode == 'api' ) { |
253 | 260 | this.doApiCopyUpload(); |
254 | 261 | } else if ( this.upload_mode == 'post' ) { |
— | — | @@ -947,11 +954,23 @@ |
948 | 955 | |
949 | 956 | /** |
950 | 957 | * Update the progress bar to a given completion fraction (between 0 and 1) |
| 958 | + * XXX This progress bar is used for encoding AND for upload... may need to fix that |
951 | 959 | */ |
952 | 960 | updateProgress: function( fraction ) { |
953 | | - //mw.log('update progress: ' + fraction); |
| 961 | + var _this = this; |
| 962 | + |
954 | 963 | $j( '#up-progressbar' ).progressbar( 'value', parseInt( fraction * 100 ) ); |
955 | 964 | $j( '#up-pstatus' ).html( parseInt( fraction * 100 ) + '% - ' ); |
| 965 | + |
| 966 | + if (_this.uploadBeginTime) { |
| 967 | + var elapsedMilliseconds = ( new Date() ).getTime() - _this.uploadBeginTime; |
| 968 | + if (fraction > 0.0 && elapsedMilliseconds > 0) { // or some other minimums for good data |
| 969 | + var fractionPerMillisecond = fraction / elapsedMilliseconds; |
| 970 | + var remainingSeconds = parseInt( ( ( 1.0 - fraction ) / fractionPerMillisecond ) / 1000 ); |
| 971 | + $j( '#up-etr' ).html( gM( 'mwe-uploaded-time-remaining', mw.seconds2npt(remainingSeconds) ) ); |
| 972 | + } |
| 973 | + } |
| 974 | + |
956 | 975 | }, |
957 | 976 | |
958 | 977 | /** |
— | — | @@ -986,14 +1005,15 @@ |
987 | 1006 | buttons: _this.getCancelButton() |
988 | 1007 | } ); |
989 | 1008 | mw.log( 'upProgressDialog::dialog done' ); |
990 | | - |
| 1009 | + |
991 | 1010 | $j( '#upProgressDialog' ).html( |
992 | 1011 | '<div id="up-pbar-container" style="width:90%;height:15px;" >' + |
993 | 1012 | '<div id="up-progressbar" style="height:15px;"></div>' + |
994 | 1013 | '<div id="up-status-container">' + |
995 | 1014 | '<span id="up-pstatus">0% - </span> ' + |
996 | 1015 | '<span id="up-status-state">' + gM( 'mwe-uploaded-status' ) + '</span> ' + |
997 | | - '</div>'+ |
| 1016 | + '</div>' + |
| 1017 | + '<div id="up-etr">' + gM( 'mwe-uploaded-time-remaining', '' ) + '</div>' + |
998 | 1018 | '</div>' |
999 | 1019 | ); |
1000 | 1020 | // Open the empty progress window |
— | — | @@ -1030,6 +1050,7 @@ |
1031 | 1051 | $j( dialogElement ).dialog( 'close' ); |
1032 | 1052 | } |
1033 | 1053 | } |
| 1054 | + |
1034 | 1055 | }; |
1035 | 1056 | |
1036 | 1057 | // jQuery plugins |