Skip to content

Commit

Permalink
Butefaed file size
Browse files Browse the repository at this point in the history
  • Loading branch information
afedyk-sugarcrm committed May 22, 2014
1 parent afe9cca commit 7dffbbe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,22 @@
"</span>";
return new Handlebars.SafeString(wrapper);
});

Handlebars.registerHelper('fileSizeFormat', function (size) {
var round = 0, sizes = ['B', 'KB', 'MB', 'GB'], size_index = 0;
size = size || 0;

while (size > 1024 && size_index < sizes.length - 1) {
size_index++;
size /= 1024;
}
if (size_index >= 2){
round = 2;
}
size = size.toFixed(round);

return size + sizes[size_index];
});
},

recalcTask: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<a target="_blank" href="{{getFieldValue this "view_link"}}">{{str 'LBL_IBM-CONNECTIONS_LIST_FILE_VIEW' this.module}}</a>
{{str 'LBL_IBM-CONNECTIONS_LIST_VERSION' this.module}}: {{getFieldValue this "version" "No version"}}
{{str 'LBL_IBM-CONNECTIONS_LIST_FILE_SIZE' this.module}}: {{getFieldValue this "fileSize" "0"}}
{{str 'LBL_IBM-CONNECTIONS_LIST_FILE_SIZE' this.module}}: {{fileSizeFormat attributes.fileSize}}
</div>
</li>
{{/each}}
Expand Down

0 comments on commit 7dffbbe

Please sign in to comment.