aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorluckydonald <luckydonald@flutterb.at>2014-08-14 12:32:08 +0200
committerluckydonald <luckydonald@flutterb.at>2014-08-14 12:32:08 +0200
commitcacf5ed23f74524e537b5c51a55f4a406a7fa5fb (patch)
treeed03c4bafab0d45bbc62e8c75d6c71de56f4ef29 /apps
parentf261c45b0ed470ca1419260d02f1f80f4a9e3f60 (diff)
downloadnextcloud-server-cacf5ed23f74524e537b5c51a55f4a406a7fa5fb.tar.gz
nextcloud-server-cacf5ed23f74524e537b5c51a55f4a406a7fa5fb.zip
Optimized time formatting, optimized time smoothing.
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/file-upload.js19
1 files changed, 8 insertions, 11 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index b703e15bbfa..9a6e27d30e3 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -488,24 +488,21 @@ OC.Upload = {
lastSize = data.loaded;
diffSize = diffSize / diffUpdate; // apply timing factor, eg. 1mb/2s = 0.5mb/s
var remainingSeconds = ((data.total - data.loaded) / diffSize);
- if(remainingSeconds > 0){ //buffer to make it smoother
+ if(remainingSeconds >= 0) {
bufferTotal = bufferTotal - (buffer[bufferIndex]) + remainingSeconds;
- buffer[bufferIndex] = remainingSeconds;
+ buffer[bufferIndex] = remainingSeconds; //buffer to make it smoother
bufferIndex = (bufferIndex + 1) % bufferSize;
}
- var smoothRemaining = (bufferTotal / bufferSize);
- var date = new Date(smoothRemaining * 1000);
- var timeStringMobile = "";
+ var smoothRemainingSeconds = (bufferTotal / bufferSize); //seconds
+ var date = new Date(smoothRemainingSeconds * 1000);
var timeStringDesktop = "";
+ var timeStringMobile = "";
if(date.getUTCHours() > 0){
timeStringDesktop = t('files', '{hours}:{minutes}:{seconds} hour{plural_s} left' , {
hours:date.getUTCHours(),
minutes: ('0' + date.getUTCMinutes()).slice(-2),
seconds: ('0' + date.getUTCSeconds()).slice(-2),
- plural_s: ( date.getUTCHours() === 1
- && date.getUTCMinutes() === 0
- && date.getUTCSeconds() === 0 ? "": "s"
- )
+ plural_s: ( smoothRemainingSeconds === 3600 ? "": "s") // 1 hour = 1*60m*60s = 3600s
});
timeStringMobile = t('files', '{hours}:{minutes}h' , {
hours:date.getUTCHours(),
@@ -516,7 +513,7 @@ OC.Upload = {
timeStringDesktop = t('files', '{minutes}:{seconds} minute{plural_s} left' , {
minutes: date.getUTCMinutes(),
seconds: ('0' + date.getUTCSeconds()).slice(-2),
- plural_s: (date.getUTCMinutes() === 1 && date.getUTCSeconds() === 0 ? "": "s")
+ plural_s: (smoothRemainingSeconds === 60 ? "": "s") // 1 minute = 1*60s = 60s
});
timeStringMobile = t('files', '{minutes}:{seconds}m' , {
minutes: date.getUTCMinutes(),
@@ -525,7 +522,7 @@ OC.Upload = {
} else if(date.getUTCSeconds() > 0){
timeStringDesktop = t('files', '{seconds} second{plural_s} left' , {
seconds: date.getUTCSeconds(),
- plural_s: (date.getUTCSeconds() === 1 ? "": "s")
+ plural_s: (smoothRemainingSeconds === 1 ? "": "s") // 1 second = 1s = 1s
});
timeStringMobile = t('files', '{seconds}s' , {seconds: date.getUTCSeconds()});
} else {