1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2026-01-18 05:49:47 +00:00

initial commit from appmail

هذا الالتزام موجود في:
Adam Cooke
2017-04-19 13:07:25 +01:00
الأصل a3eff53792
التزام 2fdba0ceb5
474 ملفات معدلة مع 51228 إضافات و0 حذوفات

عرض الملف

@@ -0,0 +1,29 @@
Postal.Helpers =
numberWithDelimiters: (number)->
number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
pluralize: (number, word)->
if number == 1
"1 #{word}"
else
"#{number} #{word}s"
numberToHumanSize: (sizeInBytes)->
wholes = Math.floor(Math.log(sizeInBytes) / Math.log(1024))
unit = ['bytes', 'KB', 'MB', 'GB', 'TB'][wholes]
i = (sizeInBytes / Math.pow(1024, wholes))
if unit
i = if unit == 'bytes' then i.toFixed(0) else i.toFixed(2)
"#{i} #{unit}"
else
"0 bytes"
styleWidth: (width)->
width = 100 if width > 100.0
width = 0 if width < 0
string = "width:#{width}%;"
if width >= 100
string = string + "background-color:#e2383a;"
else if width >= 90
string = string + "background-color:#e8581f;"
string