diff --git a/customize.dist/translations/messages.es.js b/customize.dist/translations/messages.es.js index 2346579fb..d2359c44b 100644 --- a/customize.dist/translations/messages.es.js +++ b/customize.dist/translations/messages.es.js @@ -410,6 +410,10 @@ define(function () { out.upgrade = "Mejorar"; out.upgradeTitle = "Mejora tu cuenta para obtener más espacio"; out.MB = "MB"; + out.GB = "GB"; + out.formattedMB = "{0} MB"; + out.formattedGB = "{0} GB"; + out.pinLimitReached = "Has llegado al limite de espacio"; out.pinLimitReachedAlert = "Has llegado al limite de espacio. Nuevos pads no serán movidos a tu CryptDrive.
Para resolver este problema, puedes quitar pads de tu CryptDrive (incluso en la papelera) o mejorar tu cuenta para obtener más espacio."; out.pinLimitNotPinned = "Has llegado al limite de espacio.
Este pad no estará presente en tu CryptDrive."; diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index e8cc86ce2..5dfd383b0 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -61,6 +61,9 @@ define(function () { out.upgrade = "Améliorer"; out.upgradeTitle = "Améliorer votre compte pour augmenter la limite de stockage"; out.MB = "Mo"; + out.GB = "Go"; + out.formattedMB = "{0} Mo"; + out.formattedGB = "{0} Go"; out.greenLight = "Tout fonctionne bien"; out.orangeLight = "Votre connexion est lente, ce qui réduit la qualité de l'éditeur"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index f0ce247fc..6cbff3d7f 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -63,6 +63,10 @@ define(function () { out.upgrade = "Upgrade"; out.upgradeTitle = "Upgrade your account to increase the storage limit"; out.MB = "MB"; + out.GB = "GB"; + + out.formattedMB = "{0} MB"; + out.formattedGB = "{0} GB"; out.greenLight = "Everything is working fine"; out.orangeLight = "Your slow connection may impact your experience"; diff --git a/www/common/common-util.js b/www/common/common-util.js index a5822c743..f04b85199 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -81,12 +81,25 @@ define([], function () { .replace(/_+/g, '_'); }; + var oneKilobyte = 1024; + var oneMegabyte = 1024 * oneKilobyte; + var oneGigabyte = 1024 * oneMegabyte; + + Util.bytesToGigabytes = function (bytes) { + return Math.ceil(bytes / oneGigabyte * 100) / 100; + }; + Util.bytesToMegabytes = function (bytes) { - return Math.floor((bytes / (1024 * 1024) * 100)) / 100; + return Math.ceil(bytes / oneMegabyte * 100) / 100; }; Util.bytesToKilobytes = function (bytes) { - return Math.floor(bytes / 1024 * 100) / 100; + return Math.ceil(bytes / oneKilobyte * 100) / 100; + }; + + Util.magnitudeOfBytes = function (bytes) { + if (bytes >= oneGigabyte) { return 'GB'; } + else if (bytes >= oneMegabyte) { return 'MB'; } }; Util.fetch = function (src, cb) { diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 6f0a5e256..9bbebbed3 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -745,8 +745,7 @@ define([ if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } rpc.updatePinLimits(function (e, limit, plan) { if (e) { return cb(e); } - var MB = common.bytesToMegabytes(limit); - cb(e, MB, plan); + cb(e, limit, plan); }); }; @@ -754,8 +753,7 @@ define([ if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } rpc.getLimit(function (e, limit, plan) { if (e) { return cb(e); } - var MB = common.bytesToMegabytes(limit); - cb(void 0, MB, plan); + cb(void 0, limit, plan); }); }; @@ -771,7 +769,7 @@ define([ return void cb (null, false, data); }; var todo = function (e, used) { - usage = common.bytesToMegabytes(used); + usage = used; //common.bytesToMegabytes(used); if (e) { return void cb(e); } common.getPinLimit(andThen); }; @@ -802,9 +800,14 @@ define([ common.isOverPinLimit(todo); }, LIMIT_REFRESH_RATE); } - var usage = data.usage; - var limit = data.limit; - var unit = Messages.MB; + + var unit = Util.magnitudeOfBytes(data.limit); + + var usage = unit === 'GB'? Util.bytesToGigabytes(data.usage): + Util.bytesToMegabytes(data.usage); + var limit = unit === 'GB'? Util.bytesToGigabytes(data.limit): + Util.bytesToMegabytes(data.limit); + var $limit = $('', {'class': 'cryptpad-limit-bar'}).appendTo($container); var quota = usage/limit; var width = Math.floor(Math.min(quota, 1)*200); // the bar is 200px width @@ -823,11 +826,22 @@ define([ }).text(Messages.upgrade).appendTo($upgradeLink); } + var prettyUsage; + var prettyLimit; + + if (unit === 'GB') { + prettyUsage = usage; //Messages._getKey('formattedGB', [usage]); + prettyLimit = Messages._getKey('formattedGB', [limit]); + } else { + prettyUsage = usage; //Messages._getKey('formattedMB', [usage]); + prettyLimit = Messages._getKey('formattedMB', [limit]); + } + if (quota < 0.8) { $usage.addClass('normal'); } else if (quota < 1) { $usage.addClass('warning'); } else { $usage.addClass('above'); } var $text = $('', {'class': 'usageText'}); - $text.text(usage + ' / ' + limit + ' ' + unit); + $text.text(prettyUsage + ' / ' + prettyLimit); $limit.append($usage).append($text); window.setTimeout(function () { common.isOverPinLimit(todo);