diff --git a/www/common/common-util.js b/www/common/common-util.js index 29b25c4fb..5b54f5381 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -81,5 +81,13 @@ define([], function () { .replace(/_+/g, '_'); }; + var bytesToMegabytes = Util.bytesToMegabytes = function (bytes) { + return Math.floor((bytes / (1024 * 1024) * 100)) / 100; + }; + + var bytesToKilobytes = Util.bytesToKilobytes = function (bytes) { + return Math.floor(bytes / 1024 * 100) / 100; + }; + return Util; }); diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 36d045407..ffb6936c5 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -63,6 +63,8 @@ define([ var replaceHash = common.replaceHash = Util.replaceHash; var getHash = common.getHash = Util.getHash; var fixFileName = common.fixFileName = Util.fixFileName; + common.bytesToMegabytes = Util.bytesToMegabytes; + common.bytesToKilobytes = Util.bytesToKilobytes; // import hash utilities for export var createRandomHash = common.createRandomHash = Hash.createRandomHash; diff --git a/www/settings/main.js b/www/settings/main.js index 8600dba4d..0d66b7886 100644 --- a/www/settings/main.js +++ b/www/settings/main.js @@ -226,10 +226,6 @@ define([ return $div; }; - var bytesToMegabytes = function (bytes) { - return Math.floor((bytes / (1024 * 1024) * 100)) / 100; - }; - var createUsageButton = function (obj) { var proxy = obj.proxy; @@ -252,7 +248,7 @@ define([ Cryptpad.alert(Messages.settings_pinningError); return; } - Cryptpad.alert(Messages._getKey('settings_usageAmount', [bytesToMegabytes(bytes)])); + Cryptpad.alert(Messages._getKey('settings_usageAmount', [Cryptpad.bytesToMegabytes(bytes)])); }); }) .appendTo($div);