See #195: track detail page now includes bitrate, duration and size

This commit is contained in:
Eliot Berriot 2018-05-15 22:24:20 +02:00
parent 417a1b81ae
commit 01cabc705d
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
2 changed files with 69 additions and 1 deletions

View file

@ -47,4 +47,23 @@ export function capitalize (str) {
Vue.filter('capitalize', capitalize)
export function humanSize (bytes) {
let si = true
var thresh = si ? 1000 : 1024
if (Math.abs(bytes) < thresh) {
return bytes + ' B'
}
var units = si
? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
var u = -1
do {
bytes /= thresh
++u
} while (Math.abs(bytes) >= thresh && u < units.length - 1)
return bytes.toFixed(1) + ' ' + units[u]
}
Vue.filter('humanSize', humanSize)
export default {}