nginx-proxy-manager/src/frontend/js/lib/helpers.js

37 lines
781 B
JavaScript
Raw Normal View History

2018-06-19 18:48:14 -04:00
'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>');
}
};