r62206 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62205‎ | r62206 | r62207 >
Date:23:29, 9 February 2010
Author:neilk
Status:deferred (Comments)
Tags:
Comment:
bug 21682, add estimated time remaining
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.BaseUploadInterface.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js
@@ -302,7 +302,7 @@
303303 return;
304304 }
305305
306 - // Otherwise show the "install Firefogg" message
 306+ // Otherwise show the "install Firefogg" message
307307 var upMsg = ( _this.form_type == 'upload' ) ? gM( 'fogg-for_improved_uploads' ) : '';
308308 var firefoggUrl = _this.getFirefoggInstallUrl();
309309 if( firefoggUrl ){
@@ -826,13 +826,15 @@
827827
828828 /**
829829 * Do an upload, with the mode given by this.upload_mode
 830+ * XXX should probably be dispatched from baseUploadInterface doUpload instead
830831 */
831832 doUpload: function() {
832833 var _this = this;
833834 mw.log( "firefogg: doUpload:: " +
834835 ( this.getFirefogg() ? 'on' : 'off' ) +
835836 ' up mode:' + _this.upload_mode );
836 -
 837+
 838+ _this.uploadBeginTime = (new Date()).getTime();
837839 // If Firefogg is disabled or doing an copyByUrl upload, just invoke the parent method
838840 if( !this.getFirefogg() || this.isCopyUpload() ) {
839841 _this.pe_doUpload();
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.BaseUploadInterface.js
@@ -11,6 +11,7 @@
1212 "mwe-upload-transcode-in-progress" : "Transcode and upload in progress (do not close this window)",
1313 "mwe-upload-in-progress" : "Upload in progress (do not close this window)",
1414 "mwe-upload-transcoded-status" : "Transcoded",
 15+ "mwe-uploaded-time-remaining" : "Time remaining: $1",
1516 "mwe-uploaded-status" : "Uploaded",
1617 "mwe-upload-stats-fileprogress" : "$1 of $2",
1718 "mwe-upload_completed" : "Your upload is complete",
@@ -84,6 +85,11 @@
8586 // The DOM node for the upload form
8687 form: false,
8788
 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+
8894 /**
8995 * Object initialisation
9096 * @param {Object} options BaseUpload options see default_bui_options
@@ -248,6 +254,7 @@
249255 */
250256 doUpload: function() {
251257 // Note "api" should be called "http_copy_upload" and /post/ should be "form_upload"
 258+ this.uploadBeginTime = (new Date()).getTime();
252259 if ( this.upload_mode == 'api' ) {
253260 this.doApiCopyUpload();
254261 } else if ( this.upload_mode == 'post' ) {
@@ -947,11 +954,23 @@
948955
949956 /**
950957 * 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
951959 */
952960 updateProgress: function( fraction ) {
953 - //mw.log('update progress: ' + fraction);
 961+ var _this = this;
 962+
954963 $j( '#up-progressbar' ).progressbar( 'value', parseInt( fraction * 100 ) );
955964 $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+
956975 },
957976
958977 /**
@@ -986,14 +1005,15 @@
9871006 buttons: _this.getCancelButton()
9881007 } );
9891008 mw.log( 'upProgressDialog::dialog done' );
990 -
 1009+
9911010 $j( '#upProgressDialog' ).html(
9921011 '<div id="up-pbar-container" style="width:90%;height:15px;" >' +
9931012 '<div id="up-progressbar" style="height:15px;"></div>' +
9941013 '<div id="up-status-container">' +
9951014 '<span id="up-pstatus">0% - </span> ' +
9961015 '<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>' +
9981018 '</div>'
9991019 );
10001020 // Open the empty progress window
@@ -1030,6 +1050,7 @@
10311051 $j( dialogElement ).dialog( 'close' );
10321052 }
10331053 }
 1054+
10341055 };
10351056
10361057 // jQuery plugins

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59546UsabilityInitiative: EditWarning: (bug 21682) Check for wgAction == 'submit' ...catrope15:17, 29 November 2009

Comments

#Comment by Mdale (talk | contribs)   16:27, 15 February 2010

I think he meant bug 21862

#Comment by NeilK (talk | contribs)   14:58, 16 February 2010

Mdale is correct.

Status & tagging log