Skip to content

Commit

Permalink
🗿 Added Batman filter 'shortenedBytes'
Browse files Browse the repository at this point in the history
Helps in displaying information about disks. Use in the same manner from a widget as 'shortenedNumber'.
  • Loading branch information
mdehaas authored and Tyler Mauthe committed Feb 21, 2018
1 parent 3051934 commit 353415c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions javascripts/dashing.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ Batman.Filters.shortenedNumber = (num) ->
else
num

Batman.Filters.shortenedBytes = (num) ->
return num if isNaN(num)
if num >= (1125899906842624)
(num / 1125899906842624).toFixed(1) + 'PB'
else if num >= (1099511627776)
(num / 1099511627776).toFixed(1) + 'TB'
else if num >= (1073741824)
(num / 1073741824).toFixed(1) + 'GB'
else if num >= (1048576)
(num / 1048576).toFixed(1) + 'MB'
else if num >= (1024)
(num / 1024).toFixed(1) + 'KB'
else
(num).toFixed(1) + 'B'

class window.Dashing extends Batman.App
@on 'reload', (data) ->
window.location.reload(true)
Expand Down

0 comments on commit 353415c

Please sign in to comment.