First pass at a Hanging Protocol implementation and editor (LT-131)

This commit is contained in:
Erik Ziegler committed 2016-05-07 12:40:02 +02:00
1 parent dfcb33153f
commit 2e52d9e3c1
157 files changed
+8869 -23585

No files matched your search

@@ -0,0 +1,14 @@
/**
* A global Blaze UI helper to capitalizes the first letter of an input String
*
* Credit to:
*
* http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
*/
UI.registerHelper('capitalizeFirstLetter', function (context) {
if (!context) {
return;
}
return context.charAt(0).toUpperCase() + context.slice(1);
});
@@ -0,0 +1,16 @@
/**
* A global Blaze UI helper function to format JavaScript Dates using the Moment library
*/
UI.registerHelper('formatJSDate', function(context, format, options) {
if (!context) {
return;
}
var dateAsMoment = moment(new Date(context));
var strFormat = 'MMM D, YYYY';
if (options) {
strFormat = format;
}
return dateAsMoment.format(strFormat);
});
@@ -0,0 +1,12 @@
/**
* Helper for retrieving username given userId
*/
UI.registerHelper('getUsername', function(userId) {
var user = Meteor.users.findOne({
userId: userId
});
if (user && user.name) {
return user.name;
}
});
@@ -0,0 +1,10 @@
/**
* Helper for checking datatype of a variable
*/
UI.registerHelper('ifTypeIs', function(value, match, attributeName) {
if (typeof(value) === match) {
return attributeName;
}
return '';
});
+3
View File
@@ -0,0 +1,3 @@
UI.registerHelper('inc', function(value) {
return parseInt(value) + 1;
});
@@ -0,0 +1,13 @@
/**
* A global Blaze UI helper function to format JavaScript Dates using the Moment library
*/
UI.registerHelper('jsDateFromNow', function(context, format, options) {
if (!context) {
return;
}
Session.get('timeAgoVariable');
var dateAsMoment = moment(new Date(context));
return dateAsMoment.fromNow();
});
@@ -0,0 +1,6 @@
UI.registerHelper('objectEach', function(object) {
// http://stackoverflow.com/questions/30234732/how-to-print-key-and-values-in-meteor-template
return _.map(object, function(value, key) {
return _.extend({key: key}, value);
});
});
@@ -0,0 +1,9 @@
UI.registerHelper('objectToPairs', function(object) {
// http://stackoverflow.com/questions/30234732/how-to-print-key-and-values-in-meteor-template
return _.map(object, function(value, key) {
return {
key: key,
value: value
};
});
});
@@ -0,0 +1,19 @@
/**
* A global Blaze UI helper to Stringify a JavaScript object
*
* Credit to:
*
* http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
*/
UI.registerHelper('prettyPrintStringify', function(context) {
if (!context) {
return;
}
var string = JSON.stringify(context, null, 2);
string = string.replace(/['"]+/g, '');
string = string.replace('{', '');
string = string.replace('}', '');
string = string.replace(',', '\n');
return string;
});