Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Stats now display in byte, KB or MB units.
Added template filter for converting byte values.
- Loading branch information
Showing
2 changed files
with
20 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
exports.json = function(input) { | ||
return JSON.stringify(input, null, ' '); | ||
}; | ||
|
||
exports.convertBytes= function(input) { | ||
input = parseInt(input, 10); | ||
if (input < 1024) { | ||
return input.toString() + ' Bytes'; | ||
} else if (input < 1024 * 1024) { | ||
//Convert to KB and keep 2 decimal values | ||
input = Math.round((input / 1024) * 100) / 100; | ||
return input.toString() + ' KB'; | ||
} else if (input < 1024 * 1024 * 1024) { | ||
input = Math.round((input / (1024 * 1024)) * 100) / 100; | ||
return input.toString() + ' MB'; | ||
} else { | ||
return input.toString() + ' Bytes'; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters