add pretty-printers for byte-counts
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user