summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-01-12 19:03:00 +0100
committerChristophe Simonis <chs@odoo.com>2018-01-12 19:03:00 +0100
commit56974322f8c67ec5680654ed4bcb08ca57117c46 (patch)
treee64c00274a47c46cf78e99b6ba62df4bc4dbbba4 /addons/web/static/src/js/core
parentf6ef0c776096774fc4c6821449ab42cfc2f53e62 (diff)
parent3b80a059ff4305fe10c9b40a3118508b1b849ead (diff)
[MERGE] forward port branch 11.0 up to 3b80a059ff4
Diffstat (limited to 'addons/web/static/src/js/core')
-rw-r--r--addons/web/static/src/js/core/utils.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/addons/web/static/src/js/core/utils.js b/addons/web/static/src/js/core/utils.js
index 99534708a94..1bdd9e70a69 100644
--- a/addons/web/static/src/js/core/utils.js
+++ b/addons/web/static/src/js/core/utils.js
@@ -24,6 +24,22 @@ var utils = {
}
},
/**
+ * Check if the value is a bin_size or not.
+ * If not, compute an approximate size out of the base64 encoded string.
+ *
+ * @param {string} value original format
+ * @return {string} bin_size (human-readable)
+ */
+ binaryToBinsize: function (value) {
+ if (!this.is_bin_size(value)) {
+ // Computing approximate size out of base64 encoded string
+ // http://en.wikipedia.org/wiki/Base64#MIME
+ return this.human_size(value.length / 1.37);
+ }
+ // already bin_size
+ return value;
+ },
+ /**
* Confines a value inside an interval
*
* @param {number} [val] the value to confine
@@ -132,7 +148,7 @@ var utils = {
size /= 1024;
++i;
}
- return size.toFixed(2) + ' ' + units[i];
+ return size.toFixed(2) + ' ' + units[i].trim();
},
/**
* Insert "thousands" separators in the provided number (which is actually