Initial commit

This commit is contained in:
Jamie Curnow
2017-12-21 09:02:37 +10:00
parent dc830df253
commit 6e7435c35d
140 changed files with 19554 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
'use strict';
import numeral from 'numeral';
import moment from 'moment';
module.exports = {
/**
* @param {Integer} number
* @returns {String}
*/
niceNumber: function (number) {
return numeral(number).format('0,0');
},
/**
* @param {String} 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;
}
};

View File

@@ -0,0 +1,46 @@
'use strict';
import _ from 'underscore';
import Mn from 'backbone.marionette';
let render = Mn.Renderer.render;
Mn.Renderer.render = function (template, data, view) {
data = _.clone(data);
/**
* @param {String} string
* @returns {String}
*/
data.escape = function (string) {
let entityMap = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'\'': '&#39;',
'/': '&#x2F;'
};
return String(string).replace(/[&<>"'\/]/g, function (s) {
return entityMap[s];
});
};
/**
* @param {String} string
* @param {Integer} length
* @returns {String}
*/
data.trim = function (string, length) {
if (string.length > length) {
let trimmedString = string.substr(0, length);
return trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(' '))) + '...';
}
return string;
};
return render.call(this, template, data, view);
};
module.exports = Mn;