Permalink
Browse files

pulled over byte count math from mediabox

  • Loading branch information...
1 parent 8511c85 commit b8cb65092fd57298e6a3f63b80a7e21f3d01c20c @coolaj86 committed Feb 29, 2012
Showing with 21 additions and 0 deletions.
  1. +20 −0 public/app.js
  2. +1 −0 public/includes/drop.jade
View
20 public/app.js
@@ -13,6 +13,25 @@
, linkTpl
;
+ function toByteCount(size) {
+ // 102.4
+ if (size < 102) {
+ return size + ' B';
+ }
+
+ // 104857.6
+ if (size < 104858) {
+ return (size / 1024).toFixed(1) + ' KiB';
+ }
+
+ // 107374182.4
+ if (size < 107374182) {
+ return (size / (1024 * 1024)).toFixed(1) + ' MiB';
+ }
+
+ // 1099511627776
+ return (size / (1024 * 1024 * 1024)).toFixed(1) + ' GiB';
+ }
function uploadMeta(files, meta) {
// I was attaching directly files[i].link = link
@@ -129,6 +148,7 @@
link.find('progress').attr('value', bytesLoaded);
link.find('progress').find('.val').text(bytesLoaded);
+ link.find('.byte-count').text(toByteCount(bytesLoaded));
//}
});
// TODO
View
1 public/includes/drop.jade
@@ -36,5 +36,6 @@
span.val 0
span.div /
span.max 0
+ span.byte-count
.clear
#delete-notice Files are deleted after 3 days.

0 comments on commit b8cb650

Please sign in to comment.