summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-12-19 15:40:36 +0100
committerLukas Reschke <lukas@statuscode.ch>2016-12-22 10:01:58 +0100
commit2bf4661e40abe13a22b8e445f912ba768f970ff4 (patch)
tree04f1e90b8748f25ea580ae3e0db429afd8beab35 /apps
parent0b64e96c9b064de5990a9a63ad2c03ed4b8dfa82 (diff)
downloadnextcloud-server-2bf4661e40abe13a22b8e445f912ba768f970ff4.tar.gz
nextcloud-server-2bf4661e40abe13a22b8e445f912ba768f970ff4.zip
Just use moment to comupte the time left for the upload - translations are delivered as part of moment.js - fixes #26804
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/file-upload.js40
1 files changed, 3 insertions, 37 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 25136d042a9..d1ceb436720 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -1040,43 +1040,9 @@ OC.Uploader.prototype = _.extend({
bufferIndex = (bufferIndex + 1) % bufferSize;
}
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: ( smoothRemainingSeconds === 3600 ? "": "s") // 1 hour = 1*60m*60s = 3600s
- });
- timeStringMobile = t('files', '{hours}:{minutes}h' , {
- hours:date.getUTCHours(),
- minutes: ('0' + date.getUTCMinutes()).slice(-2),
- seconds: ('0' + date.getUTCSeconds()).slice(-2)
- });
- } else if(date.getUTCMinutes() > 0){
- timeStringDesktop = t('files', '{minutes}:{seconds} minute{plural_s} left' , {
- minutes: date.getUTCMinutes(),
- seconds: ('0' + date.getUTCSeconds()).slice(-2),
- plural_s: (smoothRemainingSeconds === 60 ? "": "s") // 1 minute = 1*60s = 60s
- });
- timeStringMobile = t('files', '{minutes}:{seconds}m' , {
- minutes: date.getUTCMinutes(),
- seconds: ('0' + date.getUTCSeconds()).slice(-2)
- });
- } else if(date.getUTCSeconds() > 0){
- timeStringDesktop = t('files', '{seconds} second{plural_s} left' , {
- seconds: date.getUTCSeconds(),
- plural_s: (smoothRemainingSeconds === 1 ? "": "s") // 1 second = 1s = 1s
- });
- timeStringMobile = t('files', '{seconds}s' , {seconds: date.getUTCSeconds()});
- } else {
- timeStringDesktop = t('files', 'Any moment now...');
- timeStringMobile = t('files', 'Soon...');
- }
- $('#uploadprogressbar .label .mobile').text(timeStringMobile);
- $('#uploadprogressbar .label .desktop').text(timeStringDesktop);
+ var h = moment.duration(smoothRemainingSeconds, "seconds").humanize();
+ $('#uploadprogressbar .label .mobile').text(h);
+ $('#uploadprogressbar .label .desktop').text(h);
$('#uploadprogressbar').attr('original-title',
t('files', '{loadedSize} of {totalSize} ({bitrate})' , {
loadedSize: humanFileSize(data.loaded),