* Add missing modules to package.json

* Start replacing some code with momentjs
This commit is contained in:
Bryan Ashby 2015-07-22 16:37:11 -06:00
parent 735b572f9f
commit 40a4f8caba
4 changed files with 19 additions and 6 deletions

View File

@ -20,6 +20,7 @@ var packageJson = require('../package.json');
var assert = require('assert');
var os = require('os');
var _ = require('lodash');
var moment = require('moment');
exports.MCIViewFactory = MCIViewFactory;
@ -39,7 +40,8 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
UR : this.client.user.properties.real_name,
LO : this.client.user.properties.location,
UA : this.client.user.getAge().toString(),
UB : this.client.user.getFormattedBirthDate('medium'),
UB : moment(this.client.user.properties.birthdate).format('MM/DD/YYYY'),
//UB : this.client.user.getFormattedBirthDate('medium'),
US : this.client.user.properties.sex,
UE : this.client.user.properties.email_address,
UW : this.client.user.properties.web_address,

View File

@ -43,7 +43,7 @@ function MenuModule(options) {
switch(artAsset.type) {
case 'art' :
theme.displayThemeArt(dispOptions, function displayed(err, themeArtData) {
cb(err, { mciMap : themeArtData.mciMap, height : themeArtData.extraInfo.height } );
cb(err, err ? null : { mciMap : themeArtData.mciMap, height : themeArtData.extraInfo.height } );
});
break;
@ -77,7 +77,9 @@ function MenuModule(options) {
function displayMenuArt(callback) {
if(_.isString(self.menuConfig.art)) {
self.displayArtAsset(self.menuConfig.art, function displayed(err, artData) {
mciData.menu = artData.mciMap;
if(!err) {
mciData.menu = artData.mciMap;
}
callback(err);
});
} else {
@ -103,7 +105,9 @@ function MenuModule(options) {
// :TODO: allow inline prompts in the future, e.g. @inline:memberName -> { "memberName" : { "text" : "stuff", ... } }
var promptConfig = self.menuConfig.promptConfig;
self.displayArtAsset(promptConfig.art, function displayed(err, artData) {
mciData.prompt = artData.mciMap;
if(!err) {
mciData.prompt = artData.mciMap;
}
callback(err);
});
} else {

View File

@ -9,6 +9,7 @@ var crypto = require('crypto');
var assert = require('assert');
var async = require('async');
var _ = require('lodash');
var moment = require('moment');
exports.User = User;
exports.getUserIdAndName = getUserIdAndName;
@ -333,7 +334,10 @@ User.prototype.getFormattedBirthDate = function(style) {
};
User.prototype.getAge = function() {
var birthDate = new Date(Date.parse(this.properties.birthdate));
if(_.has(this.properties, 'birthdate')) {
return moment().diff(this.properties.birthdate, 'years');
}
/*
if(!isNaN(birthDate)) {
var today = new Date();
var age = today.getFullYear() - birthDate.getFullYear();
@ -344,6 +348,7 @@ User.prototype.getAge = function() {
return age;
}
*/
};
///////////////////////////////////////////////////////////////////////////////

View File

@ -14,7 +14,9 @@
"ssh2" : "0.4.x",
"strip-json-comments" : "1.0.x",
"gapbuffer" : "0.0.2",
"node-uuid" : "1.4.x"
"node-uuid" : "1.4.x",
"moment" : "2.10.x",
"gaze" : "0.5.x"
},
"engine" : "node >= 0.12.2"
}