file-upload.js modified : Remaining upload time corrected

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
SarthikaDhawan 2017-03-06 16:38:35 +05:30 committed by Roeland Jago Douma
parent ec5377306d
commit 62fb3bb3ef
No known key found for this signature in database
GPG key ID: F941078878347C0C

11
apps/files/js/file-upload.js Normal file → Executable file
View file

@ -960,6 +960,7 @@ OC.Uploader.prototype = _.extend({
var bufferSize = 20;
var buffer = [];
var bufferIndex = 0;
var bufferIndex2 = 0;
var bufferTotal = 0;
for(var i = 0; i < bufferSize;i++){
buffer[i] = 0;
@ -1005,8 +1006,16 @@ OC.Uploader.prototype = _.extend({
bufferTotal = bufferTotal - (buffer[bufferIndex]) + remainingSeconds;
buffer[bufferIndex] = remainingSeconds; //buffer to make it smoother
bufferIndex = (bufferIndex + 1) % bufferSize;
bufferIndex2 = bufferIndex2++;
}
var smoothRemainingSeconds = (bufferTotal / bufferSize); //seconds
var smoothRemainingSeconds;
if(bufferIndex2<20) {
smoothRemainingSeconds = bufferTotal / bufferIndex2;
}
else {
smoothRemainingSeconds = bufferTotal / bufferSize;
}
var h = moment.duration(smoothRemainingSeconds, "seconds").humanize();
$('#uploadprogressbar .label .mobile').text(h);
$('#uploadprogressbar .label .desktop').text(h);