summaryrefslogtreecommitdiff
path: root/web-ui/app/js/helpers
diff options
context:
space:
mode:
authorNavaL <mnandri@thoughtworks.com>2016-01-11 17:54:53 +0100
committerNavaL <mnandri@thoughtworks.com>2016-01-11 17:54:53 +0100
commit0c6c8bed304884ab5f3ade69fb0d68d2cbe043e6 (patch)
tree1d95481fe628ac4878bc1c0670c9e4b50a10e9cc /web-ui/app/js/helpers
parent058d14143c179d9923eea433fc63094f4f9059aa (diff)
format attachment size
Issue #573
Diffstat (limited to 'web-ui/app/js/helpers')
-rw-r--r--web-ui/app/js/helpers/view_helper.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/web-ui/app/js/helpers/view_helper.js b/web-ui/app/js/helpers/view_helper.js
index 8d841cc7..e4e9277d 100644
--- a/web-ui/app/js/helpers/view_helper.js
+++ b/web-ui/app/js/helpers/view_helper.js
@@ -121,11 +121,19 @@ define(
}
}
+ function formatSize(bytes) {
+ var e = Math.floor(Math.log(bytes) / Math.log(1024));
+ return (bytes / Math.pow(1024, e)).toFixed(2) + ' ' + ' KMGTP'.charAt(e) + 'b';
+ }
+
+
Handlebars.registerHelper('formatDate', formatDate);
+ Handlebars.registerHelper('formatSize', formatSize);
Handlebars.registerHelper('formatStatusClasses', formatStatusClasses);
return {
formatStatusClasses: formatStatusClasses,
+ formatSize: formatSize,
formatMailBody: formatMailBody,
moveCaretToEndOfText: moveCaretToEndOfText,
quoteMail: quoteMail,