From 991e965a10e90b749c2b2ca5b5e42b506391ba07 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 21 Jan 2021 11:40:51 +0100 Subject: [PATCH] Use correct size format in features.js --- customize.dist/pages/features.js | 5 +++-- www/common/common-util.js | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/customize.dist/pages/features.js b/customize.dist/pages/features.js index 14c901ce4..835c90c90 100644 --- a/customize.dist/pages/features.js +++ b/customize.dist/pages/features.js @@ -1,12 +1,13 @@ define([ 'jquery', '/common/hyperscript.js', + '/common/common-util.js', '/customize/messages.js', '/customize/application_config.js', '/common/outer/local-store.js', '/customize/pages.js', '/api/config', -], function ($, h, Msg, AppConfig, LocalStore, Pages, Config) { +], function ($, h, Util, Msg, AppConfig, LocalStore, Pages, Config) { var accounts = { donateURL: AppConfig.donateURL || "https://opencollective.com/cryptpad/", upgradeURL: AppConfig.upgradeURL @@ -55,7 +56,7 @@ define([ }; SPECIAL_GROUP_ITEMS.storage1 = function (f) { return groupItemTemplate( - Msg._getKey('features_f_' + f, [Config.defaultStorageLimit / 1024 / 1024]), + Msg._getKey('features_f_' + f, [Util.getPrettySize(Config.defaultStorageLimit)]), Msg['features_f_' + f + '_note'] ); }; diff --git a/www/common/common-util.js b/www/common/common-util.js index 603e38a30..1518cf0d8 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -272,6 +272,14 @@ else if (bytes >= oneMegabyte) { return 'MB'; } }; + Util.getPrettySize = function (bytes, Messages) { + var unit = Util.magnitudeOfBytes(bytes); + if (unit === 'GB') { + return Messages._getKey('formattedGB', [Util.bytesToGigabytes(bytes)]); + } + return Messages._getKey('formattedMB', [Util.bytesToMegabytes(bytes)]); + }; + // given a path, asynchronously return an arraybuffer var getCacheKey = function (src) {