mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 02:49:24 +02:00
See #195: track detail page now includes bitrate, duration and size
This commit is contained in:
parent
417a1b81ae
commit
01cabc705d
2 changed files with 69 additions and 1 deletions
|
@ -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 {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue