summaryrefslogtreecommitdiff
path: root/frontend/app
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/app')
-rw-r--r--frontend/app/utils/index.js20
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)