diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2021-04-28 22:49:17 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2021-04-28 22:49:17 +0200 |
| commit | 938545387a234b2cd34bd5f52e0efe5fdd1b71c0 (patch) | |
| tree | 7c24b838795b2e4cca6b3021e26c6bcd53a0b7f8 /frontend/app | |
| parent | cae0d53e2dab523327f93a0a6df277789543c6fd (diff) | |
jakrawal fix
Diffstat (limited to 'frontend/app')
| -rw-r--r-- | frontend/app/utils/index.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/frontend/app/utils/index.js b/frontend/app/utils/index.js index d67d89a..b8a2ed7 100644 --- a/frontend/app/utils/index.js +++ b/frontend/app/utils/index.js @@ -54,6 +54,26 @@ export const capitalize = s => s.split(' ').map(capitalizeWord).join(' ') export const capitalizeWord = s => s.substr(0, 1).toUpperCase() + s.substr(1) export const padSeconds = n => n < 10 ? '0' + n : n +export const commatize = (n, radix) => { + radix = radix || -1 + var nums = [], i, counter = 0, r = Math.floor + if (radix !== -1 && n > radix) { + n /= radix + nums.unshift(r((n * 10) % 10)) + nums.unshift(".") + } + do { + i = r(n % 10) + n = r(n / 10) + counter += 1 + if (n && ! (counter % 3)) + { i = ',' + r(i) } + nums.unshift(i) + } + while (n) + return nums.join("") +} + export const timestamp = (n = 0, fps = 25) => { n /= fps let s = padSeconds(Math.round(n) % 60) |
