Frontend
This commit is contained in:
36
src/frontend/js/lib/helpers.js
Normal file
36
src/frontend/js/lib/helpers.js
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
const numeral = require('numeral');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* @param {Integer} number
|
||||
* @returns {String}
|
||||
*/
|
||||
niceNumber: function (number) {
|
||||
return numeral(number).format('0,0');
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String|Integer} date
|
||||
* @returns {String}
|
||||
*/
|
||||
shortTime: function (date) {
|
||||
let shorttime = '';
|
||||
|
||||
if (typeof date === 'number') {
|
||||
shorttime = moment.unix(date).format('H:mm A');
|
||||
} else {
|
||||
shorttime = moment(date).format('H:mm A');
|
||||
}
|
||||
|
||||
return shorttime;
|
||||
},
|
||||
|
||||
replaceSlackLinks: function (content) {
|
||||
return content.replace(/<(http[^|>]+)\|([^>]+)>/gi, '<a href="$1" target="_blank">$2</a>');
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user