add old versions of playlyfe-odysseus

This commit is contained in:
Peter Dave Hello
2014-10-27 00:07:34 +08:00
parent ee4a8d33fa
commit 77e02239a8
14 changed files with 2137 additions and 0 deletions
@@ -0,0 +1,295 @@
(function(global, factory) {
if (typeof define === 'function' && define.amd) {
return define(['lodash', 'moment', 'bignumber'], factory);
} else if (typeof exports === 'object') {
return module.exports = factory(require('lodash'), require('moment'), require('bignumber.js'));
} else {
return global['Odysseus'] = factory(global['_'], global['moment'], global['BigNumber']);
}
})(this, function(_, moment, BigNumber) {
var Odysseus;
_.templateSettings.interpolate = /@\{([\s\S]+?)\}@/g;
_.templateSettings.escape = /\{\{([\s\S]+?)\}\}/g;
_.templateSettings.evaluate = /\$\{([\s\S]+?)\}\$/g;
_.templateSettings.variable = 'od';
_.templateSettings.imports = {
'_': _,
'moment': moment,
'ZERO': new BigNumber(0)
};
Odysseus = (function() {
/**
* A map of the default markup tags to be inserted into the rendered HTML
* in-case no object is supplied in the constructor
* @type {Object}
*/
Odysseus.default_markup = {
content: "od-content",
image: "od-image",
actor: "od-actor",
target: "od-target",
object: "od-object",
role_list: "od-role-list",
role: "od-role",
lane: "od-lane",
timestamp: "od-ts"
};
/**
* A list of all the available templates
* @type {Object}
*/
Odysseus.stored_templates = {
/**
* Activity Templates
*/
"create": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} created the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> created the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"delete": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} deleted the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> deleted the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }$ as <ul class='@{od.markup.role_list}@'>${ if (od.ctx.isTeam) { }$${ _.forEach(od.story.roles, function(enabled, role) { }$<li><span class='@{od.markup.role}@'>{{role}}</span></li>${ }) }$${ } else if (od.ctx.isProcess) { }$${ _.forEach(od.story.roles, function(role, lane) { }$<li><span class='@{od.markup.role}@'>{{role}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ })}$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: "${ if (od.ctx.isDummy) { }$<i class='@{od.markup.dummy_icon}@'></i>${ } else { }$<img src='{{od.ext.base_url}}/{{od.ctx.amActor ? od.ext.profile.id : od.story.actor.id}}'>${ } }$"
},
"leave": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} left {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> left " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"kick": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} kicked {{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}} from {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> kicked " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}}" + "</span> from " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} accepted {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> accepted " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} rejected {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> rejected " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:change": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - ${ if (od.story.admin) { }$[Admin Event] {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}${ } else { }${{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>${ if (od.story.admin) { }$<span class='@{od.markup.target}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}</span>${ } else { }$<span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'><li class='@{od.markup.list_header}@'>Changes</li>${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{role}}</span></li>${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$<li class='@{od.markup.diff_change}@'><span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from <span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane}}</span> lane</li>${ } else { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ } }$${ }); }$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"role:assign": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ have been changed${ if (!od.story.admin) { }$ by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}${ } }$.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ have been changed" + "${ if (!od.story.admin) { }$" + " by <span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : " + "od.story.actor.alias||od.story.actor.id}}" + "</span>" + "${ } }$." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to join ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amMetaActor ? 'you' : od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amMetaActor ? 'you' : od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to join " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"invite": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your invitation to {{od.story.invitee.alias||od.story.invitee.id}} to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} invited you to join ${ } }$the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.story.actor.alias||od.story.actor.id}} withdrew the invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'.${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$[{{moment(od.story.accepted_at||od.story.rejected_at).format('llll')}}] - {{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}} {{od.story.accepted_at ? 'accepted' : 'rejected'}} {{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}} invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> invitation to " + "<span class='@{od.markup.target}@'>{{od.story.invitee.alias||od.story.invitee.id}}</span>" + " to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>{{od.story.actor.alias||od.story.actor.id}}</span> " + "invited <span class='@{od.markup.target}@'>you</span> to join " + "${ } }$" + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span>" + " withdrew the invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}}" + "</span> {{od.story.accepted_at ? 'accepted' : 'rejected'}} " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}" + "</span>" + " invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at||od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"role:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request for change of roles in ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to change roles in ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.\n New Roles:${ if (od.ctx.isTeam) { }$\n [*] {{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) {_.forEach(od.story.roles, function(role, lane) { }$\n [*] {{role}} in {{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}} {{lane === '*' || lane === '~' ? 'lanes' : 'lane'}}${ });} }$${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request for change of roles in " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to change roles in " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "<ul class='@{od.markup.role_list}@'>" + "<li class='@{od.markup.list_header}@'>New Roles</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ })" + "} else if (od.ctx.isProcess) {" + "_.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ });" + "} }$" + "</ul>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"progress": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$.${ if (od.story.changes) { }$\n Changes:${ } }$${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString(); }$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span>.${ if(od.story.changes) { }$<table class='@{od.markup.score_table}@'>${ }_.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old'] || '--'}}</span></td></tr></tbody>${ }});if(od.story.changes) { }$</table>${ }if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"resolution": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$ and credited {{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}} for completing '{{od.story.deferred.activity.name}}'.\n Changes:${ _.forEach(od.story.deferred.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span> and credited <span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}}</span> for completing <span class='@{od.markup.score_activity}@'>{{od.story.deferred.activity.name}}</span>.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.deferred.changes, function(change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span></td></tr></tbody>${ }}); }$</table>${ if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"level": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} ${ change = od.story.changes[0]; }$'{{change.metric.name}}' level changed to '{{change.delta['new']}}'${ if (change.delta['old']) { }$ from '{{change.delta['old']}}'${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}</span> ${ change = od.story.changes[0]; }$<span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span> level changed to <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span>${ if (change.delta['old']) { }$ from <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span>${ } }$.</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"achievement": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Congratulations! You' : od.story.actor.alias||od.story.actor.id}} unlocked an achievement.\n" + " Changes:" + "${ _.forEach(od.story.changes, function(change) { }$" + "\n [>] {{change.metric.name}}" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']);" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "\n [*] {{diff}} {{item}}" + "${ }); }$" + "${ }); }$",
html: "<div class='@{od.markup.content}@'>" + "{{od.ctx.amActor ? 'Congratulations! ' : ''}}<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " unlocked an achievement." + "<table class='@{od.markup.score_table}@ @{od.markup.achievement_table}@'>" + "${ _.forEach(od.story.changes, function(change) { }$" + "<tbody class='@{od.markup.score_table_header}@'>" + "<tr>" + "<td colspan='2'>" + "<span class='@{od.markup.score_metric}@'>" + "{{change.metric.name}}" + "</span>" + "</td>" + "</tr>" + "</tbody>" + "<tbody class='@{od.markup.score_table_body}@'>" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']);" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "<tr>" + "<td>" + "<span class='@{od.markup.score_delta_item}@'>" + "{{item}}" + "</span>" + "</td>" + "<td>" + "<span class='@{od.markup.score_delta_value}@'>" + "{{diff}}" + "</span>" + "</td>" + "</tr>" + "${ }); }$" + "</tbody>" + "${ }); }$" + "</table>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"score": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} scores were changed.\n New Scores:${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') { }$\n [*] {{change.delta['new']}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) { }$\n [*] {{delta['new']}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [*] {{change.metric.name}} - {{change.delta['new']}}${ }}); }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}</span> scores were changed.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) { }$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{delta['new']}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ }}); }$</table>${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"escalation": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.story.message}}${ if (!!od.story.completed) { var completed = od.story.completed; }$ [*] {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}}\n [{{moment(od.story.timestamp).format('llll')}}]${ } }$",
html: "<div class='@{od.markup.content}@@{!!od.story.completed?' '+od.markup.escalation_inactive:''}@'>{{od.story.message}}</div>${ if (!!od.story.completed) { var completed = od.story.completed; }$<footer class='@{od.markup.footer}@ @{od.markup.escalation_footer}@'><span class='@{od.markup.escalation_player}@'> {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}} </span><time class='@{od.markup.escalation_timestamp}@ @{od.markup.timestamp}@' title='Completed on {{(ts = moment(completed.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time> </footer>${ } }$<time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
}
};
function Odysseus(options) {
options = options || {};
this.options = _.defaults(options, {
markup: Odysseus.default_markup,
external: {}
});
}
Odysseus.prototype.buildContext = function(story, ext) {
var ctx, _ref, _ref1, _ref10, _ref11, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
ctx = {};
ctx.isDummy = ext.env === 'debug';
ctx.isItem = (_ref = ext.context) === 'team' || _ref === 'process';
if ((story.team != null) || ext.context === 'team') {
ctx.isTeam = true;
} else if ((story.process != null) || ext.context === 'process') {
ctx.isProcess = true;
}
if ((_ref1 = story.event) === 'create' || _ref1 === 'delete' || _ref1 === 'join' || _ref1 === 'leave' || _ref1 === 'kick' || _ref1 === 'join:request' || _ref1 === 'join:request:accept' || _ref1 === 'join:request:reject' || _ref1 === 'invite' || _ref1 === 'invite:accept' || _ref1 === 'invite:reject' || _ref1 === 'role:change' || _ref1 === 'role:request' || _ref1 === 'role:request:accept' || _ref1 === 'role:request:reject' || _ref1 === 'role:assign' || _ref1 === 'progress' || _ref1 === 'level' || _ref1 === 'achievement' || _ref1 === 'resolution') {
if (!((story.actor != null) && ((_ref2 = ext.profile) != null ? _ref2.id : void 0) !== story.actor.id)) {
ctx.amActor = true;
}
}
if ((_ref3 = story.event) === 'kick' || _ref3 === 'join:request:accept' || _ref3 === 'join:request:reject' || _ref3 === 'role:request:accept' || _ref3 === 'role:request:reject' || _ref3 === 'role:assign' || _ref3 === 'score') {
if (!((story.player != null) && ((_ref4 = ext.profile) != null ? _ref4.id : void 0) !== story.player.id)) {
ctx.amPlayer = true;
}
} else if (story.event === 'resolution') {
if (!((story.deferred.actor != null) && ((_ref5 = ext.profile) != null ? _ref5.id : void 0) !== story.deferred.actor.id)) {
ctx.amPlayer = true;
}
} else if ((_ref6 = story.event) === 'invite:accept' || _ref6 === 'invite:reject') {
if (!((story.inviter != null) && ((_ref7 = ext.profile) != null ? _ref7.id : void 0) !== story.inviter.id)) {
ctx.amInviter = true;
}
} else if (story.event === 'invite') {
if (!((story.invitee != null) && ((_ref8 = ext.profile) != null ? _ref8.id : void 0) !== story.invitee.id)) {
ctx.amInvitee = true;
}
} else if (story.event === 'join:request') {
if (story.state === 'ACCEPTED' && ((_ref9 = ext.profile) != null ? _ref9.id : void 0) === story.accepted_by.id || story.state === 'REJECTED' && ((_ref10 = ext.profile) != null ? _ref10.id : void 0) === story.rejected_by.id) {
ctx.amMetaActor = true;
}
} else if (story.event === 'escalation') {
if ((story.completed != null) && ((_ref11 = ext.profile) != null ? _ref11.id : void 0) === story.completed.player.id) {
ctx.amPlayer = true;
}
}
return ctx;
};
Odysseus.prototype.compile = function(evt, type) {
var tpl, tpl_collection;
if ((tpl_collection = Odysseus.stored_templates[evt]) == null) {
throw "The " + evt + " event is not supported";
}
if ((tpl = tpl_collection[type]) == null) {
throw "The " + type + " template for " + evt + " event cannot be found";
}
return _.template(tpl);
};
Odysseus.prototype.toString = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'text');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context
});
};
Odysseus.prototype.toHTML = function(story, external_data, config) {
var context, html, image, template;
if (external_data == null) {
external_data = {};
}
if (config == null) {
config = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'html');
context = this.buildContext(story, external_data);
html = template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
if (story.event === 'escalation') {
html = _.unescape(html);
}
if (config.image === true) {
image = "<div class='" + this.options.markup.image + "'>" + (this.getImage(story, external_data)) + "</div>";
html = image + html;
}
return html;
};
Odysseus.prototype.getImage = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
if (external_data.base_url == null) {
throw 'The base source url is not specified';
}
template = this.compile(story.event, 'image');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
};
return Odysseus;
})();
return Odysseus;
});
File diff suppressed because one or more lines are too long
@@ -0,0 +1,302 @@
/**
* playlyfe-odysseus - Parse and build stories out of Playlyfe Events.
* version: 0.5.0
* repository: http://github.com/playlyfe/odysseus
* license: MIT
* author: Kumar Harsh (khs@playlyfe.com)
**/
(function(global, factory) {
if (typeof define === 'function' && define.amd) {
return define(['lodash', 'moment', 'bignumber'], factory);
} else if (typeof exports === 'object') {
return module.exports = factory(require('lodash'), require('moment'), require('bignumber.js'));
} else {
return global['Odysseus'] = factory(global['_'], global['moment'], global['BigNumber']);
}
})(this, function(_, moment, BigNumber) {
var Odysseus;
_.templateSettings.interpolate = /@\{([\s\S]+?)\}@/g;
_.templateSettings.escape = /\{\{([\s\S]+?)\}\}/g;
_.templateSettings.evaluate = /\$\{([\s\S]+?)\}\$/g;
_.templateSettings.variable = 'od';
_.templateSettings.imports = {
'_': _,
'moment': moment,
'ZERO': new BigNumber(0)
};
Odysseus = (function() {
/**
* A map of the default markup tags to be inserted into the rendered HTML
* in-case no object is supplied in the constructor
* @type {Object}
*/
Odysseus.default_markup = {
content: "od-content",
image: "od-image",
actor: "od-actor",
target: "od-target",
object: "od-object",
role_list: "od-role-list",
role: "od-role",
lane: "od-lane",
timestamp: "od-ts"
};
/**
* A list of all the available templates
* @type {Object}
*/
Odysseus.stored_templates = {
/**
* Activity Templates
*/
"create": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} created the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> created the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"delete": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} deleted the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> deleted the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }$ as <ul class='@{od.markup.role_list}@'>${ if (od.ctx.isTeam) { }$${ _.forEach(od.story.roles, function(enabled, role) { }$<li><span class='@{od.markup.role}@'>{{role}}</span></li>${ }) }$${ } else if (od.ctx.isProcess) { }$${ _.forEach(od.story.roles, function(role, lane) { }$<li><span class='@{od.markup.role}@'>{{role}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ })}$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: "${ if (od.ctx.isDummy) { }$<i class='@{od.markup.dummy_icon}@'></i>${ } else { }$<img src='{{od.ext.base_url}}/{{od.ctx.amActor ? od.ext.profile.id : od.story.actor.id}}'>${ } }$"
},
"leave": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} left {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> left " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"kick": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} kicked {{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}} from {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> kicked " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}}" + "</span> from " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} accepted {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> accepted " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} rejected {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> rejected " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:change": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - ${ if (od.story.admin) { }$[Admin Event] {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}${ } else { }${{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>${ if (od.story.admin) { }$<span class='@{od.markup.target}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}</span>${ } else { }$<span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'><li class='@{od.markup.list_header}@'>Changes</li>${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{role}}</span></li>${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$<li class='@{od.markup.diff_change}@'><span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from <span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane}}</span> lane</li>${ } else { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ } }$${ }); }$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"role:assign": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ have been changed${ if (!od.story.admin) { }$ by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}${ } }$.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ have been changed" + "${ if (!od.story.admin) { }$" + " by <span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : " + "od.story.actor.alias||od.story.actor.id}}" + "</span>" + "${ } }$." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to join ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amMetaActor ? 'you' : od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amMetaActor ? 'you' : od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to join " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"invite": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your invitation to {{od.story.invitee.alias||od.story.invitee.id}} to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} invited you to join ${ } }$the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.story.actor.alias||od.story.actor.id}} withdrew the invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'.${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$[{{moment(od.story.accepted_at||od.story.rejected_at).format('llll')}}] - {{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}} {{od.story.accepted_at ? 'accepted' : 'rejected'}} {{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}} invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> invitation to " + "<span class='@{od.markup.target}@'>{{od.story.invitee.alias||od.story.invitee.id}}</span>" + " to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>{{od.story.actor.alias||od.story.actor.id}}</span> " + "invited <span class='@{od.markup.target}@'>you</span> to join " + "${ } }$" + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span>" + " withdrew the invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}}" + "</span> {{od.story.accepted_at ? 'accepted' : 'rejected'}} " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}" + "</span>" + " invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at||od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"role:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request for change of roles in ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to change roles in ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.\n New Roles:${ if (od.ctx.isTeam) { }$\n [*] {{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) {_.forEach(od.story.roles, function(role, lane) { }$\n [*] {{role}} in {{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}} {{lane === '*' || lane === '~' ? 'lanes' : 'lane'}}${ });} }$${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request for change of roles in " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to change roles in " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "<ul class='@{od.markup.role_list}@'>" + "<li class='@{od.markup.list_header}@'>New Roles</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ })" + "} else if (od.ctx.isProcess) {" + "_.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ });" + "} }$" + "</ul>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"progress": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$.${ if (od.story.changes) { }$\n Changes:${ } }$${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString(); }$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span>.${ if(od.story.changes) { }$<table class='@{od.markup.score_table}@'>${ }_.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old'] || '--'}}</span></td></tr></tbody>${ }});if(od.story.changes) { }$</table>${ }if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"resolution": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$ and credited {{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}} for completing '{{od.story.deferred.activity.name}}'.\n Changes:${ _.forEach(od.story.deferred.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span> and credited <span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}}</span> for completing <span class='@{od.markup.score_activity}@'>{{od.story.deferred.activity.name}}</span>.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.deferred.changes, function(change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span></td></tr></tbody>${ }}); }$</table>${ if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"level": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} ${ change = od.story.changes[0]; }$'{{change.metric.name}}' level changed to '{{change.delta['new']}}'${ if (change.delta['old']) { }$ from '{{change.delta['old']}}'${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}</span> ${ change = od.story.changes[0]; }$<span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span> level changed to <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span>${ if (change.delta['old']) { }$ from <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span>${ } }$.</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"achievement": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Congratulations! You' : od.story.actor.alias||od.story.actor.id}} unlocked an achievement.\n" + " Changes:" + "${ _.forEach(od.story.changes, function(change) { }$" + "\n [>] {{change.metric.name}}" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']);" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "\n [*] {{diff}} {{item}}" + "${ }); }$" + "${ }); }$",
html: "<div class='@{od.markup.content}@'>" + "{{od.ctx.amActor ? 'Congratulations! ' : ''}}<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " unlocked an achievement." + "<table class='@{od.markup.score_table}@ @{od.markup.achievement_table}@'>" + "${ _.forEach(od.story.changes, function(change) { }$" + "<tbody class='@{od.markup.score_table_header}@'>" + "<tr>" + "<td colspan='2'>" + "<span class='@{od.markup.score_metric}@'>" + "{{change.metric.name}}" + "</span>" + "</td>" + "</tr>" + "</tbody>" + "<tbody class='@{od.markup.score_table_body}@'>" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']);" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "<tr>" + "<td>" + "<span class='@{od.markup.score_delta_item}@'>" + "{{item}}" + "</span>" + "</td>" + "<td>" + "<span class='@{od.markup.score_delta_value}@'>" + "{{diff}}" + "</span>" + "</td>" + "</tr>" + "${ }); }$" + "</tbody>" + "${ }); }$" + "</table>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"score": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} scores were changed.\n New Scores:${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') { }$\n [*] {{change.delta['new']}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) { }$\n [*] {{delta['new']}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [*] {{change.metric.name}} - {{change.delta['new']}}${ }}); }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}</span> scores were changed.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) { }$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{delta['new']}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ }}); }$</table>${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"escalation": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.story.message}}${ if (!!od.story.completed) { var completed = od.story.completed; }$ [*] {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}}\n [{{moment(od.story.timestamp).format('llll')}}]${ } }$",
html: "<div class='@{od.markup.content}@@{!!od.story.completed?' '+od.markup.escalation_inactive:''}@'>{{od.story.message}}</div>${ if (!!od.story.completed) { var completed = od.story.completed; }$<footer class='@{od.markup.footer}@ @{od.markup.escalation_footer}@'><span class='@{od.markup.escalation_player}@'> {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}} </span><time class='@{od.markup.escalation_timestamp}@ @{od.markup.timestamp}@' title='Completed on {{(ts = moment(completed.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time> </footer>${ } }$<time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
}
};
function Odysseus(options) {
options = options || {};
this.options = _.defaults(options, {
markup: Odysseus.default_markup,
external: {}
});
}
Odysseus.prototype.buildContext = function(story, ext) {
var ctx, _ref, _ref1, _ref10, _ref11, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
ctx = {};
ctx.isDummy = ext.env === 'debug';
ctx.isItem = (_ref = ext.context) === 'team' || _ref === 'process';
if ((story.team != null) || ext.context === 'team') {
ctx.isTeam = true;
} else if ((story.process != null) || ext.context === 'process') {
ctx.isProcess = true;
}
if ((_ref1 = story.event) === 'create' || _ref1 === 'delete' || _ref1 === 'join' || _ref1 === 'leave' || _ref1 === 'kick' || _ref1 === 'join:request' || _ref1 === 'join:request:accept' || _ref1 === 'join:request:reject' || _ref1 === 'invite' || _ref1 === 'invite:accept' || _ref1 === 'invite:reject' || _ref1 === 'role:change' || _ref1 === 'role:request' || _ref1 === 'role:request:accept' || _ref1 === 'role:request:reject' || _ref1 === 'role:assign' || _ref1 === 'progress' || _ref1 === 'level' || _ref1 === 'achievement' || _ref1 === 'resolution') {
if (!((story.actor != null) && ((_ref2 = ext.profile) != null ? _ref2.id : void 0) !== story.actor.id)) {
ctx.amActor = true;
}
}
if ((_ref3 = story.event) === 'kick' || _ref3 === 'join:request:accept' || _ref3 === 'join:request:reject' || _ref3 === 'role:request:accept' || _ref3 === 'role:request:reject' || _ref3 === 'role:assign' || _ref3 === 'score') {
if (!((story.player != null) && ((_ref4 = ext.profile) != null ? _ref4.id : void 0) !== story.player.id)) {
ctx.amPlayer = true;
}
} else if (story.event === 'resolution') {
if (!((story.deferred.actor != null) && ((_ref5 = ext.profile) != null ? _ref5.id : void 0) !== story.deferred.actor.id)) {
ctx.amPlayer = true;
}
} else if ((_ref6 = story.event) === 'invite:accept' || _ref6 === 'invite:reject') {
if (!((story.inviter != null) && ((_ref7 = ext.profile) != null ? _ref7.id : void 0) !== story.inviter.id)) {
ctx.amInviter = true;
}
} else if (story.event === 'invite') {
if (!((story.invitee != null) && ((_ref8 = ext.profile) != null ? _ref8.id : void 0) !== story.invitee.id)) {
ctx.amInvitee = true;
}
} else if (story.event === 'join:request') {
if (story.state === 'ACCEPTED' && ((_ref9 = ext.profile) != null ? _ref9.id : void 0) === story.accepted_by.id || story.state === 'REJECTED' && ((_ref10 = ext.profile) != null ? _ref10.id : void 0) === story.rejected_by.id) {
ctx.amMetaActor = true;
}
} else if (story.event === 'escalation') {
if ((story.completed != null) && ((_ref11 = ext.profile) != null ? _ref11.id : void 0) === story.completed.player.id) {
ctx.amPlayer = true;
}
}
return ctx;
};
Odysseus.prototype.compile = function(evt, type) {
var tpl, tpl_collection;
if ((tpl_collection = Odysseus.stored_templates[evt]) == null) {
throw "The " + evt + " event is not supported";
}
if ((tpl = tpl_collection[type]) == null) {
throw "The " + type + " template for " + evt + " event cannot be found";
}
return _.template(tpl);
};
Odysseus.prototype.toString = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'text');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context
});
};
Odysseus.prototype.toHTML = function(story, external_data, config) {
var context, html, image, template;
if (external_data == null) {
external_data = {};
}
if (config == null) {
config = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'html');
context = this.buildContext(story, external_data);
html = template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
if (story.event === 'escalation') {
html = _.unescape(html);
}
if (config.image === true) {
image = "<div class='" + this.options.markup.image + "'>" + (this.getImage(story, external_data)) + "</div>";
html = image + html;
}
return html;
};
Odysseus.prototype.getImage = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
if (external_data.base_url == null) {
throw 'The base source url is not specified';
}
template = this.compile(story.event, 'image');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
};
return Odysseus;
})();
return Odysseus;
});
File diff suppressed because one or more lines are too long
@@ -0,0 +1,302 @@
/**
* playlyfe-odysseus - Parse and build stories out of Playlyfe Events.
* version: 0.5.0
* repository: http://github.com/playlyfe/odysseus
* license: MIT
* author: Kumar Harsh (khs@playlyfe.com)
**/
(function(global, factory) {
if (typeof define === 'function' && define.amd) {
return define(['lodash', 'moment', 'bignumber'], factory);
} else if (typeof exports === 'object') {
return module.exports = factory(require('lodash'), require('moment'), require('bignumber.js'));
} else {
return global['Odysseus'] = factory(global['_'], global['moment'], global['BigNumber']);
}
})(this, function(_, moment, BigNumber) {
var Odysseus;
_.templateSettings.interpolate = /@\{([\s\S]+?)\}@/g;
_.templateSettings.escape = /\{\{([\s\S]+?)\}\}/g;
_.templateSettings.evaluate = /\$\{([\s\S]+?)\}\$/g;
_.templateSettings.variable = 'od';
_.templateSettings.imports = {
'_': _,
'moment': moment,
'ZERO': new BigNumber(0)
};
Odysseus = (function() {
/**
* A map of the default markup tags to be inserted into the rendered HTML
* in-case no object is supplied in the constructor
* @type {Object}
*/
Odysseus.default_markup = {
content: "od-content",
image: "od-image",
actor: "od-actor",
target: "od-target",
object: "od-object",
role_list: "od-role-list",
role: "od-role",
lane: "od-lane",
timestamp: "od-ts"
};
/**
* A list of all the available templates
* @type {Object}
*/
Odysseus.stored_templates = {
/**
* Activity Templates
*/
"create": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} created the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> created the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"delete": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} deleted the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> deleted the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }$ as <ul class='@{od.markup.role_list}@'>${ if (od.ctx.isTeam) { }$${ _.forEach(od.story.roles, function(enabled, role) { }$<li><span class='@{od.markup.role}@'>{{role}}</span></li>${ }) }$${ } else if (od.ctx.isProcess) { }$${ _.forEach(od.story.roles, function(role, lane) { }$<li><span class='@{od.markup.role}@'>{{role}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ })}$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: "${ if (od.ctx.isDummy) { }$<i class='@{od.markup.dummy_icon}@'></i>${ } else { }$<img src='{{od.ext.base_url}}/{{od.ctx.amActor ? od.ext.profile.id : od.story.actor.id}}'>${ } }$"
},
"leave": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} left {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> left " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"kick": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} kicked {{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}} from {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> kicked " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}}" + "</span> from " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} accepted {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> accepted " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} rejected {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> rejected " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:change": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - ${ if (od.story.admin) { }$[Admin Event] {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}${ } else { }${{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>${ if (od.story.admin) { }$<span class='@{od.markup.target}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}</span>${ } else { }$<span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'><li class='@{od.markup.list_header}@'>Changes</li>${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{role}}</span></li>${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$<li class='@{od.markup.diff_change}@'><span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from <span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane}}</span> lane</li>${ } else { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ } }$${ }); }$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"role:assign": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ have been changed${ if (!od.story.admin) { }$ by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}${ } }$.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ have been changed" + "${ if (!od.story.admin) { }$" + " by <span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : " + "od.story.actor.alias||od.story.actor.id}}" + "</span>" + "${ } }$." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to join ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amMetaActor ? 'you' : od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amMetaActor ? 'you' : od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to join " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"invite": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your invitation to {{od.story.invitee.alias||od.story.invitee.id}} to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} invited you to join ${ } }$the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.story.actor.alias||od.story.actor.id}} withdrew the invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'.${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$[{{moment(od.story.accepted_at||od.story.rejected_at).format('llll')}}] - {{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}} {{od.story.accepted_at ? 'accepted' : 'rejected'}} {{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}} invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> invitation to " + "<span class='@{od.markup.target}@'>{{od.story.invitee.alias||od.story.invitee.id}}</span>" + " to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>{{od.story.actor.alias||od.story.actor.id}}</span> " + "invited <span class='@{od.markup.target}@'>you</span> to join " + "${ } }$" + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span>" + " withdrew the invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}}" + "</span> {{od.story.accepted_at ? 'accepted' : 'rejected'}} " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}" + "</span>" + " invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at||od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"role:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request for change of roles in ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to change roles in ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.\n New Roles:${ if (od.ctx.isTeam) { }$\n [*] {{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) {_.forEach(od.story.roles, function(role, lane) { }$\n [*] {{role}} in {{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}} {{lane === '*' || lane === '~' ? 'lanes' : 'lane'}}${ });} }$${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request for change of roles in " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to change roles in " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "<ul class='@{od.markup.role_list}@'>" + "<li class='@{od.markup.list_header}@'>New Roles</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ })" + "} else if (od.ctx.isProcess) {" + "_.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ });" + "} }$" + "</ul>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"progress": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$.${ if (od.story.changes) { }$\n Changes:${ } }$${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString(); }$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span>.${ if(od.story.changes) { }$<table class='@{od.markup.score_table}@'>${ }_.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old'] || '--'}}</span></td></tr></tbody>${ }});if(od.story.changes) { }$</table>${ }if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"resolution": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$ and credited {{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}} for completing '{{od.story.deferred.activity.name}}'.\n Changes:${ _.forEach(od.story.deferred.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span> and credited <span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}}</span> for completing <span class='@{od.markup.score_activity}@'>{{od.story.deferred.activity.name}}</span>.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.deferred.changes, function(change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span></td></tr></tbody>${ }}); }$</table>${ if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"level": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} ${ change = od.story.changes[0]; }$'{{change.metric.name}}' level changed to '{{change.delta['new']}}'${ if (change.delta['old']) { }$ from '{{change.delta['old']}}'${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}</span> ${ change = od.story.changes[0]; }$<span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span> level changed to <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span>${ if (change.delta['old']) { }$ from <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span>${ } }$.</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"achievement": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Congratulations! You' : od.story.actor.alias||od.story.actor.id}} unlocked an achievement.\n" + " Changes:" + "${ _.forEach(od.story.changes, function(change) { }$" + "\n [>] {{change.metric.name}}" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "\n [*] {{diff}} {{item}}" + "${ }); }$" + "${ }); }$",
html: "<div class='@{od.markup.content}@'>" + "{{od.ctx.amActor ? 'Congratulations! ' : ''}}<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " unlocked an achievement." + "<table class='@{od.markup.score_table}@ @{od.markup.achievement_table}@'>" + "${ _.forEach(od.story.changes, function(change) { }$" + "<tbody class='@{od.markup.score_table_header}@'>" + "<tr>" + "<td colspan='2'>" + "<span class='@{od.markup.score_metric}@'>" + "{{change.metric.name}}" + "</span>" + "</td>" + "</tr>" + "</tbody>" + "<tbody class='@{od.markup.score_table_body}@'>" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "<tr>" + "<td>" + "<span class='@{od.markup.score_delta_item}@'>" + "{{item}}" + "</span>" + "</td>" + "<td>" + "<span class='@{od.markup.score_delta_value}@'>" + "{{diff}}" + "</span>" + "</td>" + "</tr>" + "${ }); }$" + "</tbody>" + "${ }); }$" + "</table>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"score": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} scores were changed.\n New Scores:${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') { }$\n [*] {{change.delta['new']}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) { }$\n [*] {{delta['new']}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [*] {{change.metric.name}} - {{change.delta['new']}}${ }}); }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}</span> scores were changed.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) { }$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{delta['new']}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ }}); }$</table>${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"escalation": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.story.message}}${ if (!!od.story.completed) { var completed = od.story.completed; }$ [*] {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}}\n [{{moment(od.story.timestamp).format('llll')}}]${ } }$",
html: "<div class='@{od.markup.content}@@{!!od.story.completed?' '+od.markup.escalation_inactive:''}@'>{{od.story.message}}</div>${ if (!!od.story.completed) { var completed = od.story.completed; }$<footer class='@{od.markup.footer}@ @{od.markup.escalation_footer}@'><span class='@{od.markup.escalation_player}@'> {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}} </span><time class='@{od.markup.escalation_timestamp}@ @{od.markup.timestamp}@' title='Completed on {{(ts = moment(completed.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time> </footer>${ } }$<time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
}
};
function Odysseus(options) {
options = options || {};
this.options = _.defaults(options, {
markup: Odysseus.default_markup,
external: {}
});
}
Odysseus.prototype.buildContext = function(story, ext) {
var ctx, _ref, _ref1, _ref10, _ref11, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
ctx = {};
ctx.isDummy = ext.env === 'debug';
ctx.isItem = (_ref = ext.context) === 'team' || _ref === 'process';
if ((story.team != null) || ext.context === 'team') {
ctx.isTeam = true;
} else if ((story.process != null) || ext.context === 'process') {
ctx.isProcess = true;
}
if ((_ref1 = story.event) === 'create' || _ref1 === 'delete' || _ref1 === 'join' || _ref1 === 'leave' || _ref1 === 'kick' || _ref1 === 'join:request' || _ref1 === 'join:request:accept' || _ref1 === 'join:request:reject' || _ref1 === 'invite' || _ref1 === 'invite:accept' || _ref1 === 'invite:reject' || _ref1 === 'role:change' || _ref1 === 'role:request' || _ref1 === 'role:request:accept' || _ref1 === 'role:request:reject' || _ref1 === 'role:assign' || _ref1 === 'progress' || _ref1 === 'level' || _ref1 === 'achievement' || _ref1 === 'resolution') {
if (!((story.actor != null) && ((_ref2 = ext.profile) != null ? _ref2.id : void 0) !== story.actor.id)) {
ctx.amActor = true;
}
}
if ((_ref3 = story.event) === 'kick' || _ref3 === 'join:request:accept' || _ref3 === 'join:request:reject' || _ref3 === 'role:request:accept' || _ref3 === 'role:request:reject' || _ref3 === 'role:assign' || _ref3 === 'score') {
if (!((story.player != null) && ((_ref4 = ext.profile) != null ? _ref4.id : void 0) !== story.player.id)) {
ctx.amPlayer = true;
}
} else if (story.event === 'resolution') {
if (!((story.deferred.actor != null) && ((_ref5 = ext.profile) != null ? _ref5.id : void 0) !== story.deferred.actor.id)) {
ctx.amPlayer = true;
}
} else if ((_ref6 = story.event) === 'invite:accept' || _ref6 === 'invite:reject') {
if (!((story.inviter != null) && ((_ref7 = ext.profile) != null ? _ref7.id : void 0) !== story.inviter.id)) {
ctx.amInviter = true;
}
} else if (story.event === 'invite') {
if (!((story.invitee != null) && ((_ref8 = ext.profile) != null ? _ref8.id : void 0) !== story.invitee.id)) {
ctx.amInvitee = true;
}
} else if (story.event === 'join:request') {
if (story.state === 'ACCEPTED' && ((_ref9 = ext.profile) != null ? _ref9.id : void 0) === story.accepted_by.id || story.state === 'REJECTED' && ((_ref10 = ext.profile) != null ? _ref10.id : void 0) === story.rejected_by.id) {
ctx.amMetaActor = true;
}
} else if (story.event === 'escalation') {
if ((story.completed != null) && ((_ref11 = ext.profile) != null ? _ref11.id : void 0) === story.completed.player.id) {
ctx.amPlayer = true;
}
}
return ctx;
};
Odysseus.prototype.compile = function(evt, type) {
var tpl, tpl_collection;
if ((tpl_collection = Odysseus.stored_templates[evt]) == null) {
throw "The " + evt + " event is not supported";
}
if ((tpl = tpl_collection[type]) == null) {
throw "The " + type + " template for " + evt + " event cannot be found";
}
return _.template(tpl);
};
Odysseus.prototype.toString = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'text');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context
});
};
Odysseus.prototype.toHTML = function(story, external_data, config) {
var context, html, image, template;
if (external_data == null) {
external_data = {};
}
if (config == null) {
config = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'html');
context = this.buildContext(story, external_data);
html = template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
if (story.event === 'escalation') {
html = _.unescape(html);
}
if (config.image === true) {
image = "<div class='" + this.options.markup.image + "'>" + (this.getImage(story, external_data)) + "</div>";
html = image + html;
}
return html;
};
Odysseus.prototype.getImage = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
if (external_data.base_url == null) {
throw 'The base source url is not specified';
}
template = this.compile(story.event, 'image');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
};
return Odysseus;
})();
return Odysseus;
});
File diff suppressed because one or more lines are too long
@@ -0,0 +1,302 @@
/**
* playlyfe-odysseus - Parse and build stories out of Playlyfe Events.
* version: 0.5.1
* repository: http://github.com/playlyfe/odysseus
* license: MIT
* author: Kumar Harsh (khs@playlyfe.com)
**/
(function(global, factory) {
if (typeof define === 'function' && define.amd) {
return define(['lodash', 'moment', 'bignumber'], factory);
} else if (typeof exports === 'object') {
return module.exports = factory(require('lodash'), require('moment'), require('bignumber.js'));
} else {
return global['Odysseus'] = factory(global['_'], global['moment'], global['BigNumber']);
}
})(this, function(_, moment, BigNumber) {
var Odysseus;
_.templateSettings.interpolate = /@\{([\s\S]+?)\}@/g;
_.templateSettings.escape = /\{\{([\s\S]+?)\}\}/g;
_.templateSettings.evaluate = /\$\{([\s\S]+?)\}\$/g;
_.templateSettings.variable = 'od';
_.templateSettings.imports = {
'_': _,
'moment': moment,
'ZERO': new BigNumber(0)
};
Odysseus = (function() {
/**
* A map of the default markup tags to be inserted into the rendered HTML
* in-case no object is supplied in the constructor
* @type {Object}
*/
Odysseus.default_markup = {
content: "od-content",
image: "od-image",
actor: "od-actor",
target: "od-target",
object: "od-object",
role_list: "od-role-list",
role: "od-role",
lane: "od-lane",
timestamp: "od-ts"
};
/**
* A list of all the available templates
* @type {Object}
*/
Odysseus.stored_templates = {
/**
* Activity Templates
*/
"create": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} created the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> created the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"delete": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} deleted the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> deleted the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }$ as <ul class='@{od.markup.role_list}@'>${ if (od.ctx.isTeam) { }$${ _.forEach(od.story.roles, function(enabled, role) { }$<li><span class='@{od.markup.role}@'>{{role}}</span></li>${ }) }$${ } else if (od.ctx.isProcess) { }$${ _.forEach(od.story.roles, function(role, lane) { }$<li><span class='@{od.markup.role}@'>{{role}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ })}$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: "${ if (od.ctx.isDummy) { }$<i class='@{od.markup.dummy_icon}@'></i>${ } else { }$<img src='{{od.ext.base_url}}/{{od.ctx.amActor ? od.ext.profile.id : od.story.actor.id}}'>${ } }$"
},
"leave": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} left {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> left " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"kick": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} kicked {{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}} from {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> kicked " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}}" + "</span> from " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} accepted {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> accepted " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} rejected {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> rejected " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:change": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - ${ if (od.story.admin) { }$[Admin Event] {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}${ } else { }${{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>${ if (od.story.admin) { }$<span class='@{od.markup.target}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}</span>${ } else { }$<span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'><li class='@{od.markup.list_header}@'>Changes</li>${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{role}}</span></li>${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$<li class='@{od.markup.diff_change}@'><span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from <span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane}}</span> lane</li>${ } else { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ } }$${ }); }$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"role:assign": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ have been changed${ if (!od.story.admin) { }$ by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}${ } }$.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ have been changed" + "${ if (!od.story.admin) { }$" + " by <span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : " + "od.story.actor.alias||od.story.actor.id}}" + "</span>" + "${ } }$." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to join ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amMetaActor ? 'you' : od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amMetaActor ? 'you' : od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to join " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"invite": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your invitation to {{od.story.invitee.alias||od.story.invitee.id}} to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} invited you to join ${ } }$the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.story.actor.alias||od.story.actor.id}} withdrew the invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'.${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$[{{moment(od.story.accepted_at||od.story.rejected_at).format('llll')}}] - {{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}} {{od.story.accepted_at ? 'accepted' : 'rejected'}} {{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}} invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> invitation to " + "<span class='@{od.markup.target}@'>{{od.story.invitee.alias||od.story.invitee.id}}</span>" + " to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>{{od.story.actor.alias||od.story.actor.id}}</span> " + "invited <span class='@{od.markup.target}@'>you</span> to join " + "${ } }$" + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span>" + " withdrew the invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}}" + "</span> {{od.story.accepted_at ? 'accepted' : 'rejected'}} " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}" + "</span>" + " invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at||od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"role:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request for change of roles in ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to change roles in ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.\n New Roles:${ if (od.ctx.isTeam) { }$\n [*] {{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) {_.forEach(od.story.roles, function(role, lane) { }$\n [*] {{role}} in {{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}} {{lane === '*' || lane === '~' ? 'lanes' : 'lane'}}${ });} }$${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request for change of roles in " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to change roles in " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "<ul class='@{od.markup.role_list}@'>" + "<li class='@{od.markup.list_header}@'>New Roles</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ })" + "} else if (od.ctx.isProcess) {" + "_.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ });" + "} }$" + "</ul>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"progress": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$.${ if (od.story.changes) { }$\n Changes:${ } }$${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString(); }$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span>.${ if(od.story.changes) { }$<table class='@{od.markup.score_table}@'>${ }_.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old'] || '--'}}</span></td></tr></tbody>${ }});if(od.story.changes) { }$</table>${ }if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"resolution": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$ and credited {{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}} for completing '{{od.story.deferred.activity.name}}'.\n Changes:${ _.forEach(od.story.deferred.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span> and credited <span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}}</span> for completing <span class='@{od.markup.score_activity}@'>{{od.story.deferred.activity.name}}</span>.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.deferred.changes, function(change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span></td></tr></tbody>${ }}); }$</table>${ if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"level": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} ${ change = od.story.changes[0]; }$'{{change.metric.name}}' level changed ${ if (change.delta['old']) { }$from '{{change.delta['old']}}' ${ } }$to '{{change.delta['new']}}'.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}</span> ${ change = od.story.changes[0]; }$<span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span> level changed${ if (change.delta['old']) { }$ from <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span>${ } }$ to <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span>.</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"achievement": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Congratulations! You' : od.story.actor.alias||od.story.actor.id}} unlocked an achievement.\n" + " Changes:" + "${ _.forEach(od.story.changes, function(change) { }$" + "\n [>] {{change.metric.name}}" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "\n [*] {{diff}} {{item}}" + "${ }); }$" + "${ }); }$",
html: "<div class='@{od.markup.content}@'>" + "{{od.ctx.amActor ? 'Congratulations! ' : ''}}<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " unlocked an achievement." + "<table class='@{od.markup.score_table}@ @{od.markup.achievement_table}@'>" + "${ _.forEach(od.story.changes, function(change) { }$" + "<tbody class='@{od.markup.score_table_header}@'>" + "<tr>" + "<td colspan='2'>" + "<span class='@{od.markup.score_metric}@'>" + "{{change.metric.name}}" + "</span>" + "</td>" + "</tr>" + "</tbody>" + "<tbody class='@{od.markup.score_table_body}@'>" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "<tr>" + "<td>" + "<span class='@{od.markup.score_delta_item}@'>" + "{{item}}" + "</span>" + "</td>" + "<td>" + "<span class='@{od.markup.score_delta_value}@'>" + "{{diff}}" + "</span>" + "</td>" + "</tr>" + "${ }); }$" + "</tbody>" + "${ }); }$" + "</table>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"score": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} scores were changed.\n New Scores:${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') { }$\n [*] {{change.delta['new']}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) { }$\n [*] {{delta['new']}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [*] {{change.metric.name}} - {{change.delta['new']}}${ }}); }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}</span> scores were changed.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) { }$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{delta['new']}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ }}); }$</table>${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"escalation": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.story.message}}${ if (!!od.story.completed) { var completed = od.story.completed; }$ [*] {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}}\n [{{moment(od.story.timestamp).format('llll')}}]${ } }$",
html: "<div class='@{od.markup.content}@@{!!od.story.completed?' '+od.markup.escalation_inactive:''}@'>{{od.story.message}}</div>${ if (!!od.story.completed) { var completed = od.story.completed; }$<footer class='@{od.markup.footer}@ @{od.markup.escalation_footer}@'><span class='@{od.markup.escalation_player}@'> {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}} </span><time class='@{od.markup.escalation_timestamp}@ @{od.markup.timestamp}@' title='Completed on {{(ts = moment(completed.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time> </footer>${ } }$<time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
}
};
function Odysseus(options) {
options = options || {};
this.options = _.defaults(options, {
markup: Odysseus.default_markup,
external: {}
});
}
Odysseus.prototype.buildContext = function(story, ext) {
var ctx, _ref, _ref1, _ref10, _ref11, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
ctx = {};
ctx.isDummy = ext.env === 'debug';
ctx.isItem = (_ref = ext.context) === 'team' || _ref === 'process';
if ((story.team != null) || ext.context === 'team') {
ctx.isTeam = true;
} else if ((story.process != null) || ext.context === 'process') {
ctx.isProcess = true;
}
if ((_ref1 = story.event) === 'create' || _ref1 === 'delete' || _ref1 === 'join' || _ref1 === 'leave' || _ref1 === 'kick' || _ref1 === 'join:request' || _ref1 === 'join:request:accept' || _ref1 === 'join:request:reject' || _ref1 === 'invite' || _ref1 === 'invite:accept' || _ref1 === 'invite:reject' || _ref1 === 'role:change' || _ref1 === 'role:request' || _ref1 === 'role:request:accept' || _ref1 === 'role:request:reject' || _ref1 === 'role:assign' || _ref1 === 'progress' || _ref1 === 'level' || _ref1 === 'achievement' || _ref1 === 'resolution') {
if (!((story.actor != null) && ((_ref2 = ext.profile) != null ? _ref2.id : void 0) !== story.actor.id)) {
ctx.amActor = true;
}
}
if ((_ref3 = story.event) === 'kick' || _ref3 === 'join:request:accept' || _ref3 === 'join:request:reject' || _ref3 === 'role:request:accept' || _ref3 === 'role:request:reject' || _ref3 === 'role:assign' || _ref3 === 'score') {
if (!((story.player != null) && ((_ref4 = ext.profile) != null ? _ref4.id : void 0) !== story.player.id)) {
ctx.amPlayer = true;
}
} else if (story.event === 'resolution') {
if (!((story.deferred.actor != null) && ((_ref5 = ext.profile) != null ? _ref5.id : void 0) !== story.deferred.actor.id)) {
ctx.amPlayer = true;
}
} else if ((_ref6 = story.event) === 'invite:accept' || _ref6 === 'invite:reject') {
if (!((story.inviter != null) && ((_ref7 = ext.profile) != null ? _ref7.id : void 0) !== story.inviter.id)) {
ctx.amInviter = true;
}
} else if (story.event === 'invite') {
if (!((story.invitee != null) && ((_ref8 = ext.profile) != null ? _ref8.id : void 0) !== story.invitee.id)) {
ctx.amInvitee = true;
}
} else if (story.event === 'join:request') {
if (story.state === 'ACCEPTED' && ((_ref9 = ext.profile) != null ? _ref9.id : void 0) === story.accepted_by.id || story.state === 'REJECTED' && ((_ref10 = ext.profile) != null ? _ref10.id : void 0) === story.rejected_by.id) {
ctx.amMetaActor = true;
}
} else if (story.event === 'escalation') {
if ((story.completed != null) && ((_ref11 = ext.profile) != null ? _ref11.id : void 0) === story.completed.player.id) {
ctx.amPlayer = true;
}
}
return ctx;
};
Odysseus.prototype.compile = function(evt, type) {
var tpl, tpl_collection;
if ((tpl_collection = Odysseus.stored_templates[evt]) == null) {
throw "The " + evt + " event is not supported";
}
if ((tpl = tpl_collection[type]) == null) {
throw "The " + type + " template for " + evt + " event cannot be found";
}
return _.template(tpl);
};
Odysseus.prototype.toString = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'text');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context
});
};
Odysseus.prototype.toHTML = function(story, external_data, config) {
var context, html, image, template;
if (external_data == null) {
external_data = {};
}
if (config == null) {
config = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'html');
context = this.buildContext(story, external_data);
html = template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
if (story.event === 'escalation') {
html = _.unescape(html);
}
if (config.image === true) {
image = "<div class='" + this.options.markup.image + "'>" + (this.getImage(story, external_data)) + "</div>";
html = image + html;
}
return html;
};
Odysseus.prototype.getImage = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
if (external_data.base_url == null) {
throw 'The base source url is not specified';
}
template = this.compile(story.event, 'image');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
};
return Odysseus;
})();
return Odysseus;
});
File diff suppressed because one or more lines are too long
@@ -0,0 +1,302 @@
/**
* playlyfe-odysseus - Parse and build stories out of Playlyfe Events.
* version: 0.5.3
* repository: http://github.com/playlyfe/odysseus
* license: MIT
* author: Kumar Harsh (khs@playlyfe.com)
**/
(function(global, factory) {
if (typeof define === 'function' && define.amd) {
return define(['lodash', 'moment', 'bignumber'], factory);
} else if (typeof exports === 'object') {
return module.exports = factory(require('lodash'), require('moment'), require('bignumber.js'));
} else {
return global['Odysseus'] = factory(global['_'], global['moment'], global['BigNumber']);
}
})(this, function(_, moment, BigNumber) {
var Odysseus;
_.templateSettings.interpolate = /@\{([\s\S]+?)\}@/g;
_.templateSettings.escape = /\{\{([\s\S]+?)\}\}/g;
_.templateSettings.evaluate = /\$\{([\s\S]+?)\}\$/g;
_.templateSettings.variable = 'od';
_.templateSettings.imports = {
'_': _,
'moment': moment,
'ZERO': new BigNumber(0)
};
Odysseus = (function() {
/**
* A map of the default markup tags to be inserted into the rendered HTML
* in-case no object is supplied in the constructor
* @type {Object}
*/
Odysseus.default_markup = {
content: "od-content",
image: "od-image",
actor: "od-actor",
target: "od-target",
object: "od-object",
role_list: "od-role-list",
role: "od-role",
lane: "od-lane",
timestamp: "od-ts"
};
/**
* A list of all the available templates
* @type {Object}
*/
Odysseus.stored_templates = {
/**
* Activity Templates
*/
"create": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} created the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> created the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"delete": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} deleted the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> deleted the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }$ as <ul class='@{od.markup.role_list}@'>${ if (od.ctx.isTeam) { }$${ _.forEach(od.story.roles, function(enabled, role) { }$<li><span class='@{od.markup.role}@'>{{role}}</span></li>${ }) }$${ } else if (od.ctx.isProcess) { }$${ _.forEach(od.story.roles, function(role, lane) { }$<li><span class='@{od.markup.role}@'>{{role}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ })}$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: "${ if (od.ctx.isDummy) { }$<i class='@{od.markup.dummy_icon}@'></i>${ } else { }$<img src='{{od.ext.base_url}}/{{od.ctx.amActor ? od.ext.profile.id : od.story.actor.id}}'>${ } }$"
},
"leave": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} left {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> left " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"kick": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} kicked {{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}} from {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> kicked " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}}" + "</span> from " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} accepted {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> accepted " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} rejected {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> rejected " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:change": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - ${ if (od.story.admin) { }$[Admin Event] {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}${ } else { }${{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>${ if (od.story.admin) { }$<span class='@{od.markup.target}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}</span>${ } else { }$<span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'><li class='@{od.markup.list_header}@'>Changes</li>${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{role}}</span></li>${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$<li class='@{od.markup.diff_change}@'><span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from <span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane}}</span> lane</li>${ } else { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ } }$${ }); }$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"role:assign": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ have been changed${ if (!od.story.admin) { }$ by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}${ } }$.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ have been changed" + "${ if (!od.story.admin) { }$" + " by <span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : " + "od.story.actor.alias||od.story.actor.id}}" + "</span>" + "${ } }$." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to join ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amMetaActor ? 'you' : od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amMetaActor ? 'you' : od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to join " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"invite": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your invitation to {{od.story.invitee.alias||od.story.invitee.id}} to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} invited you to join ${ } }$the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.story.actor.alias||od.story.actor.id}} withdrew the invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'.${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$[{{moment(od.story.accepted_at||od.story.rejected_at).format('llll')}}] - {{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}} {{od.story.accepted_at ? 'accepted' : 'rejected'}} {{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}} invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> invitation to " + "<span class='@{od.markup.target}@'>{{od.story.invitee.alias||od.story.invitee.id}}</span>" + " to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>{{od.story.actor.alias||od.story.actor.id}}</span> " + "invited <span class='@{od.markup.target}@'>you</span> to join " + "${ } }$" + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span>" + " withdrew the invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}}" + "</span> {{od.story.accepted_at ? 'accepted' : 'rejected'}} " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}" + "</span>" + " invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at||od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"role:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request for change of roles in ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to change roles in ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.\n New Roles:${ if (od.ctx.isTeam) { }$\n [*] {{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) {_.forEach(od.story.roles, function(role, lane) { }$\n [*] {{role}} in {{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}} {{lane === '*' || lane === '~' ? 'lanes' : 'lane'}}${ });} }$${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request for change of roles in " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to change roles in " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "<ul class='@{od.markup.role_list}@'>" + "<li class='@{od.markup.list_header}@'>New Roles</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ })" + "} else if (od.ctx.isProcess) {" + "_.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ });" + "} }$" + "</ul>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"progress": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$.${ if (od.story.changes) { }$\n Changes:${ } }$${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString(); }$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span>.${ if(od.story.changes) { }$<table class='@{od.markup.score_table}@'>${ }_.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old'] || '--'}}</span></td></tr></tbody>${ }});if(od.story.changes) { }$</table>${ }if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"resolution": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$ and credited {{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}} for completing '{{od.story.deferred.activity.name}}'.\n Changes:${ _.forEach(od.story.deferred.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span> and credited <span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}}</span> for completing <span class='@{od.markup.score_activity}@'>{{od.story.deferred.activity.name}}</span>.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.deferred.changes, function(change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span></td></tr></tbody>${ }}); }$</table>${ if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"level": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} ${ change = od.story.changes[0]; }$'{{change.metric.name}}' level changed ${ if (change.delta['old']) { }$from '{{change.delta['old']}}' ${ } }$to '{{change.delta['new']}}'.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}</span> ${ change = od.story.changes[0]; }$<span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span> level changed${ if (change.delta['old']) { }$ from <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span>${ } }$ to <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span>.</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"achievement": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Congratulations! You' : od.story.actor.alias||od.story.actor.id}} unlocked an achievement.\n" + " Changes:" + "${ _.forEach(od.story.changes, function(change) { }$" + "\n [>] {{change.metric.name}}" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "\n [*] {{diff}} {{item}}" + "${ }); }$" + "${ }); }$",
html: "<div class='@{od.markup.content}@'>" + "{{od.ctx.amActor ? 'Congratulations! ' : ''}}<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " unlocked an achievement." + "<table class='@{od.markup.score_table}@ @{od.markup.achievement_table}@'>" + "${ _.forEach(od.story.changes, function(change) { }$" + "<tbody class='@{od.markup.score_table_header}@'>" + "<tr>" + "<td colspan='2'>" + "<span class='@{od.markup.score_metric}@'>" + "{{change.metric.name}}" + "</span>" + "</td>" + "</tr>" + "</tbody>" + "<tbody class='@{od.markup.score_table_body}@'>" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "<tr>" + "<td>" + "<span class='@{od.markup.score_delta_item}@'>" + "{{item}}" + "</span>" + "</td>" + "<td>" + "<span class='@{od.markup.score_delta_value}@'>" + "{{diff}}" + "</span>" + "</td>" + "</tr>" + "${ }); }$" + "</tbody>" + "${ }); }$" + "</table>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"score": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} scores were changed.\n New Scores:${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') { }$\n [*] {{change.delta['new']}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) { }$\n [*] {{delta['new']}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [*] {{change.metric.name}} - {{change.delta['new']}}${ }}); }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}</span> scores were changed.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) { }$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{delta['new']}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ }}); }$</table>${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"escalation": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.story.message}}${ if (!!od.story.completed) { var completed = od.story.completed; }$ [*] {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}}\n [{{moment(od.story.timestamp).format('llll')}}]${ } }$",
html: "<div class='@{od.markup.content}@@{!!od.story.completed?' '+od.markup.escalation_inactive:''}@'>{{od.story.message}}</div>${ if (!!od.story.completed) { var completed = od.story.completed; }$<footer class='@{od.markup.footer}@ @{od.markup.escalation_footer}@'><span class='@{od.markup.escalation_player}@'> {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}} </span><time class='@{od.markup.escalation_timestamp}@ @{od.markup.timestamp}@' title='Completed on {{(ts = moment(completed.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time> </footer>${ } }$<time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
}
};
function Odysseus(options) {
options = options || {};
this.options = _.defaults(options, {
markup: Odysseus.default_markup,
external: {}
});
}
Odysseus.prototype.buildContext = function(story, ext) {
var ctx, _ref, _ref1, _ref10, _ref11, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
ctx = {};
ctx.isDummy = ext.env === 'debug';
ctx.isItem = (_ref = ext.context) === 'team' || _ref === 'process';
if ((story.team != null) || ext.context === 'team') {
ctx.isTeam = true;
} else if ((story.process != null) || ext.context === 'process') {
ctx.isProcess = true;
}
if ((_ref1 = story.event) === 'create' || _ref1 === 'delete' || _ref1 === 'join' || _ref1 === 'leave' || _ref1 === 'kick' || _ref1 === 'join:request' || _ref1 === 'join:request:accept' || _ref1 === 'join:request:reject' || _ref1 === 'invite' || _ref1 === 'invite:accept' || _ref1 === 'invite:reject' || _ref1 === 'role:change' || _ref1 === 'role:request' || _ref1 === 'role:request:accept' || _ref1 === 'role:request:reject' || _ref1 === 'role:assign' || _ref1 === 'progress' || _ref1 === 'level' || _ref1 === 'achievement' || _ref1 === 'resolution') {
if (!((story.actor != null) && ((_ref2 = ext.profile) != null ? _ref2.id : void 0) !== story.actor.id)) {
ctx.amActor = true;
}
}
if ((_ref3 = story.event) === 'kick' || _ref3 === 'join:request:accept' || _ref3 === 'join:request:reject' || _ref3 === 'role:request:accept' || _ref3 === 'role:request:reject' || _ref3 === 'role:assign' || _ref3 === 'score') {
if (!((story.player != null) && ((_ref4 = ext.profile) != null ? _ref4.id : void 0) !== story.player.id)) {
ctx.amPlayer = true;
}
} else if (story.event === 'resolution') {
if (!((story.deferred.actor != null) && ((_ref5 = ext.profile) != null ? _ref5.id : void 0) !== story.deferred.actor.id)) {
ctx.amPlayer = true;
}
} else if ((_ref6 = story.event) === 'invite:accept' || _ref6 === 'invite:reject') {
if (!((story.inviter != null) && ((_ref7 = ext.profile) != null ? _ref7.id : void 0) !== story.inviter.id)) {
ctx.amInviter = true;
}
} else if (story.event === 'invite') {
if (!((story.invitee != null) && ((_ref8 = ext.profile) != null ? _ref8.id : void 0) !== story.invitee.id)) {
ctx.amInvitee = true;
}
} else if (story.event === 'join:request') {
if (story.state === 'ACCEPTED' && ((_ref9 = ext.profile) != null ? _ref9.id : void 0) === story.accepted_by.id || story.state === 'REJECTED' && ((_ref10 = ext.profile) != null ? _ref10.id : void 0) === story.rejected_by.id) {
ctx.amMetaActor = true;
}
} else if (story.event === 'escalation') {
if ((story.completed != null) && ((_ref11 = ext.profile) != null ? _ref11.id : void 0) === story.completed.player.id) {
ctx.amPlayer = true;
}
}
return ctx;
};
Odysseus.prototype.compile = function(evt, type) {
var tpl, tpl_collection;
if ((tpl_collection = Odysseus.stored_templates[evt]) == null) {
throw "The " + evt + " event is not supported";
}
if ((tpl = tpl_collection[type]) == null) {
throw "The " + type + " template for " + evt + " event cannot be found";
}
return _.template(tpl);
};
Odysseus.prototype.toString = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'text');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context
});
};
Odysseus.prototype.toHTML = function(story, external_data, config) {
var context, html, image, template;
if (external_data == null) {
external_data = {};
}
if (config == null) {
config = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'html');
context = this.buildContext(story, external_data);
html = template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
if (story.event === 'escalation') {
html = _.unescape(html);
}
if (config.image === true) {
image = "<div class='" + this.options.markup.image + "'>" + (this.getImage(story, external_data)) + "</div>";
html = image + html;
}
return html;
};
Odysseus.prototype.getImage = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
if (external_data.base_url == null) {
throw 'The base source url is not specified';
}
template = this.compile(story.event, 'image');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
};
return Odysseus;
})();
return Odysseus;
});
File diff suppressed because one or more lines are too long
@@ -0,0 +1,307 @@
/**
* playlyfe-odysseus - Parse and build stories out of Playlyfe Events.
* version: 0.5.4
* repository: http://github.com/playlyfe/odysseus
* license: MIT
* author: Kumar Harsh (khs@playlyfe.com)
**/
(function(global, factory) {
if (typeof define === 'function' && define.amd) {
return define(['lodash', 'moment', 'bignumber'], factory);
} else if (typeof exports === 'object') {
return module.exports = factory(require('lodash'), require('moment'), require('bignumber.js'));
} else {
return global['Odysseus'] = factory(global['_'], global['moment'], global['BigNumber']);
}
})(this, function(_, moment, BigNumber) {
var Odysseus;
_.templateSettings.interpolate = /@\{([\s\S]+?)\}@/g;
_.templateSettings.escape = /\{\{([\s\S]+?)\}\}/g;
_.templateSettings.evaluate = /\$\{([\s\S]+?)\}\$/g;
_.templateSettings.variable = 'od';
_.templateSettings.imports = {
'_': _,
'moment': moment,
'ZERO': new BigNumber(0)
};
Odysseus = (function() {
/**
* A map of the default markup tags to be inserted into the rendered HTML
* in-case no object is supplied in the constructor
* @type {Object}
*/
Odysseus.default_markup = {
content: "od-content",
image: "od-image",
actor: "od-actor",
target: "od-target",
object: "od-object",
role_list: "od-role-list",
role: "od-role",
lane: "od-lane",
timestamp: "od-ts"
};
/**
* A list of all the available templates
* @type {Object}
*/
Odysseus.stored_templates = {
/**
* Activity Templates
*/
"create": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}The '{{ od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id }}' {{ od.ctx.isTeam ? 'team' : 'process' }} was created${ if (!od.story.admin) { }$ by {{ od.ctx.amActor ? 'you' : od.story.actor.alias || od.story.actor.id}}${ } }$.",
html: "<div class='@{od.markup.content}@'>The <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}</span> {{od.ctx.isTeam ? 'team' : 'process'}} was created${ if (!od.story.admin) { }$ by <span class='@{od.markup.actor}@'>{{ od.ctx.amActor ? 'you' : od.story.actor.alias || od.story.actor.id }}</span>${ } }$.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"delete": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} deleted the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> deleted the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }$ as <ul class='@{od.markup.role_list}@'>${ if (od.ctx.isTeam) { }$${ _.forEach(od.story.roles, function(enabled, role) { }$<li><span class='@{od.markup.role}@'>{{role}}</span></li>${ }) }$${ } else if (od.ctx.isProcess) { }$${ _.forEach(od.story.roles, function(role, lane) { }$<li><span class='@{od.markup.role}@'>{{role}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ })}$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: "${ if (od.ctx.isDummy) { }$<i class='@{od.markup.dummy_icon}@'></i>${ } else { }$<img src='{{od.ext.base_url}}/{{od.ctx.amActor ? od.ext.profile.id : od.story.actor.id}}'>${ } }$"
},
"leave": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} left {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> left " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"kick": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} kicked {{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}} from {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> kicked " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}}" + "</span> from " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} accepted {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> accepted " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} rejected {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> rejected " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:change": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - ${ if (od.story.admin) { }$[Admin Event] {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}${ } else { }${{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>${ if (od.story.admin) { }$<span class='@{od.markup.target}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}</span>${ } else { }$<span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'><li class='@{od.markup.list_header}@'>Changes</li>${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{role}}</span></li>${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$<li class='@{od.markup.diff_change}@'><span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from <span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane}}</span> lane</li>${ } else { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ } }$${ }); }$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"role:assign": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ have been changed${ if (!od.story.admin) { }$ by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}${ } }$.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ have been changed" + "${ if (!od.story.admin) { }$" + " by <span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : " + "od.story.actor.alias||od.story.actor.id}}" + "</span>" + "${ } }$." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to join ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amMetaActor ? 'you' : od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amMetaActor ? 'you' : od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to join " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"invite": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your invitation to {{od.story.invitee.alias||od.story.invitee.id}} to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} invited you to join ${ } }$the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.story.actor.alias||od.story.actor.id}} withdrew the invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'.${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$[{{moment(od.story.accepted_at||od.story.rejected_at).format('llll')}}] - {{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}} {{od.story.accepted_at ? 'accepted' : 'rejected'}} {{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}} invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> invitation to " + "<span class='@{od.markup.target}@'>{{od.story.invitee.alias||od.story.invitee.id}}</span>" + " to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>{{od.story.actor.alias||od.story.actor.id}}</span> " + "invited <span class='@{od.markup.target}@'>you</span> to join " + "${ } }$" + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span>" + " withdrew the invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}}" + "</span> {{od.story.accepted_at ? 'accepted' : 'rejected'}} " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}" + "</span>" + " invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at||od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"role:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request for change of roles in ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to change roles in ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.\n New Roles:${ if (od.ctx.isTeam) { }$\n [*] {{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) {_.forEach(od.story.roles, function(role, lane) { }$\n [*] {{role}} in {{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}} {{lane === '*' || lane === '~' ? 'lanes' : 'lane'}}${ });} }$${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request for change of roles in " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to change roles in " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "<ul class='@{od.markup.role_list}@'>" + "<li class='@{od.markup.list_header}@'>New Roles</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ })" + "} else if (od.ctx.isProcess) {" + "_.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ });" + "} }$" + "</ul>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"progress": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$.${ if (od.story.changes) { }$\n Changes:${ } }$${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString(); }$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span>.${ if(od.story.changes) { }$<table class='@{od.markup.score_table}@'>${ }_.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old'] || '--'}}</span></td></tr></tbody>${ }});if(od.story.changes) { }$</table>${ }if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"resolution": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$ and credited {{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}} for completing '{{od.story.deferred.activity.name}}'.\n Changes:${ _.forEach(od.story.deferred.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span> and credited <span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}}</span> for completing <span class='@{od.markup.score_activity}@'>{{od.story.deferred.activity.name}}</span>.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.deferred.changes, function(change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span></td></tr></tbody>${ }}); }$</table>${ if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"level": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} ${ change = od.story.changes[0]; }$'{{change.metric.name}}' level changed ${ if (change.delta['old']) { }$from '{{change.delta['old']}}' ${ } }$to '{{change.delta['new']}}'.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}</span> ${ change = od.story.changes[0]; }$<span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span> level changed${ if (change.delta['old']) { }$ from <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span>${ } }$ to <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span>.</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"achievement": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Congratulations! You' : od.story.actor.alias||od.story.actor.id}} unlocked an achievement.\n" + " Changes:" + "${ _.forEach(od.story.changes, function(change) { }$" + "\n [>] {{change.metric.name}}" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "\n [*] {{diff}} {{item}}" + "${ }); }$" + "${ }); }$",
html: "<div class='@{od.markup.content}@'>" + "{{od.ctx.amActor ? 'Congratulations! ' : ''}}<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " unlocked an achievement." + "<table class='@{od.markup.score_table}@ @{od.markup.achievement_table}@'>" + "${ _.forEach(od.story.changes, function(change) { }$" + "<tbody class='@{od.markup.score_table_header}@'>" + "<tr>" + "<td colspan='2'>" + "<span class='@{od.markup.score_metric}@'>" + "{{change.metric.name}}" + "</span>" + "</td>" + "</tr>" + "</tbody>" + "<tbody class='@{od.markup.score_table_body}@'>" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "<tr>" + "<td>" + "<span class='@{od.markup.score_delta_item}@'>" + "{{item}}" + "</span>" + "</td>" + "<td>" + "<span class='@{od.markup.score_delta_value}@'>" + "{{diff}}" + "</span>" + "</td>" + "</tr>" + "${ }); }$" + "</tbody>" + "${ }); }$" + "</table>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"score": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} scores were changed.\n New Scores:${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') { }$\n [*] {{change.delta['new']}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) { }$\n [*] {{delta['new']}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [*] {{change.metric.name}} - {{change.delta['new']}}${ }}); }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}</span> scores were changed.<table class='@{od.markup.score_table}@'>${ _.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) { }$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{delta['new']}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ }}); }$</table>${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"escalation": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.story.message}}${ if (!!od.story.completed) { var completed = od.story.completed; }$ [*] {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}}\n [{{moment(od.story.timestamp).format('llll')}}]${ } }$",
html: "<div class='@{od.markup.content}@@{!!od.story.completed?' '+od.markup.escalation_inactive:''}@'>{{od.story.message}}</div>${ if (!!od.story.completed) { var completed = od.story.completed; }$<footer class='@{od.markup.footer}@ @{od.markup.escalation_footer}@'><span class='@{od.markup.escalation_player}@'> {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}} </span><time class='@{od.markup.escalation_timestamp}@ @{od.markup.timestamp}@' title='Completed on {{(ts = moment(completed.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time> </footer>${ } }$<time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"action": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.action.name}}'.${ if (od.story.changes) { }$\n Changes:${ } }$${ _.forEach(od.story.changes, function (change) {if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString(); }$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }}) }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.action.name}}</span>.${ if(od.story.changes) { }$<table class='@{od.markup.score_table}@'>${ }_.forEach(od.story.changes, function(change) {if (change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old']);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old'] || '--'}}</span></td></tr></tbody>${ }});if(od.story.changes) { }$</table>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
}
};
function Odysseus(options) {
options = options || {};
this.options = _.defaults(options, {
markup: Odysseus.default_markup,
external: {}
});
}
Odysseus.prototype.buildContext = function(story, ext) {
var ctx, _ref, _ref1, _ref10, _ref11, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
ctx = {};
ctx.isDummy = ext.env === 'debug';
ctx.isItem = (_ref = ext.context) === 'team' || _ref === 'process';
if ((story.team != null) || ext.context === 'team') {
ctx.isTeam = true;
} else if ((story.process != null) || ext.context === 'process') {
ctx.isProcess = true;
}
if ((_ref1 = story.event) === 'create' || _ref1 === 'delete' || _ref1 === 'join' || _ref1 === 'leave' || _ref1 === 'kick' || _ref1 === 'join:request' || _ref1 === 'join:request:accept' || _ref1 === 'join:request:reject' || _ref1 === 'invite' || _ref1 === 'invite:accept' || _ref1 === 'invite:reject' || _ref1 === 'role:change' || _ref1 === 'role:request' || _ref1 === 'role:request:accept' || _ref1 === 'role:request:reject' || _ref1 === 'role:assign' || _ref1 === 'progress' || _ref1 === 'level' || _ref1 === 'achievement' || _ref1 === 'resolution' || _ref1 === 'action') {
if (!((story.actor != null) && ((_ref2 = ext.profile) != null ? _ref2.id : void 0) !== story.actor.id)) {
ctx.amActor = true;
}
}
if ((_ref3 = story.event) === 'kick' || _ref3 === 'join:request:accept' || _ref3 === 'join:request:reject' || _ref3 === 'role:request:accept' || _ref3 === 'role:request:reject' || _ref3 === 'role:assign' || _ref3 === 'score') {
if (!((story.player != null) && ((_ref4 = ext.profile) != null ? _ref4.id : void 0) !== story.player.id)) {
ctx.amPlayer = true;
}
} else if (story.event === 'resolution') {
if (!((story.deferred.actor != null) && ((_ref5 = ext.profile) != null ? _ref5.id : void 0) !== story.deferred.actor.id)) {
ctx.amPlayer = true;
}
} else if ((_ref6 = story.event) === 'invite:accept' || _ref6 === 'invite:reject') {
if (!((story.inviter != null) && ((_ref7 = ext.profile) != null ? _ref7.id : void 0) !== story.inviter.id)) {
ctx.amInviter = true;
}
} else if (story.event === 'invite') {
if (!((story.invitee != null) && ((_ref8 = ext.profile) != null ? _ref8.id : void 0) !== story.invitee.id)) {
ctx.amInvitee = true;
}
} else if (story.event === 'join:request') {
if (story.state === 'ACCEPTED' && ((_ref9 = ext.profile) != null ? _ref9.id : void 0) === story.accepted_by.id || story.state === 'REJECTED' && ((_ref10 = ext.profile) != null ? _ref10.id : void 0) === story.rejected_by.id) {
ctx.amMetaActor = true;
}
} else if (story.event === 'escalation') {
if ((story.completed != null) && ((_ref11 = ext.profile) != null ? _ref11.id : void 0) === story.completed.player.id) {
ctx.amPlayer = true;
}
}
return ctx;
};
Odysseus.prototype.compile = function(evt, type) {
var tpl, tpl_collection;
if ((tpl_collection = Odysseus.stored_templates[evt]) == null) {
throw "The " + evt + " event is not supported";
}
if ((tpl = tpl_collection[type]) == null) {
throw "The " + type + " template for " + evt + " event cannot be found";
}
return _.template(tpl);
};
Odysseus.prototype.toString = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'text');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context
});
};
Odysseus.prototype.toHTML = function(story, external_data, config) {
var context, html, image, template;
if (external_data == null) {
external_data = {};
}
if (config == null) {
config = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'html');
context = this.buildContext(story, external_data);
html = template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
if (story.event === 'escalation') {
html = _.unescape(html);
}
if (config.image === true) {
image = "<div class='" + this.options.markup.image + "'>" + (this.getImage(story, external_data)) + "</div>";
html = image + html;
}
return html;
};
Odysseus.prototype.getImage = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
if (external_data.base_url == null) {
throw 'The base source url is not specified';
}
template = this.compile(story.event, 'image');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
};
return Odysseus;
})();
return Odysseus;
});
File diff suppressed because one or more lines are too long
@@ -0,0 +1,307 @@
/**
* playlyfe-odysseus - Parse and build stories out of Playlyfe Events.
* version: 0.5.5
* repository: http://github.com/playlyfe/odysseus
* license: MIT
* author: Kumar Harsh (khs@playlyfe.com)
**/
(function(global, factory) {
if (typeof define === 'function' && define.amd) {
return define(['lodash', 'moment', 'bignumber'], factory);
} else if (typeof exports === 'object') {
return module.exports = factory(require('lodash'), require('moment'), require('bignumber.js'));
} else {
return global['Odysseus'] = factory(global['_'], global['moment'], global['BigNumber']);
}
})(this, function(_, moment, BigNumber) {
var Odysseus;
_.templateSettings.interpolate = /@\{([\s\S]+?)\}@/g;
_.templateSettings.escape = /\{\{([\s\S]+?)\}\}/g;
_.templateSettings.evaluate = /\$\{([\s\S]+?)\}\$/g;
_.templateSettings.variable = 'od';
_.templateSettings.imports = {
'_': _,
'moment': moment,
'ZERO': new BigNumber(0)
};
Odysseus = (function() {
/**
* A map of the default markup tags to be inserted into the rendered HTML
* in-case no object is supplied in the constructor
* @type {Object}
*/
Odysseus.default_markup = {
content: "od-content",
image: "od-image",
actor: "od-actor",
target: "od-target",
object: "od-object",
role_list: "od-role-list",
role: "od-role",
lane: "od-lane",
timestamp: "od-ts"
};
/**
* A list of all the available templates
* @type {Object}
*/
Odysseus.stored_templates = {
/**
* Activity Templates
*/
"create": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}The '{{ od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id }}' {{ od.ctx.isTeam ? 'team' : 'process' }} was created${ if (!od.story.admin) { }$ by {{ od.ctx.amActor ? 'you' : od.story.actor.alias || od.story.actor.id}}${ } }$.",
html: "<div class='@{od.markup.content}@'>The <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}</span> {{od.ctx.isTeam ? 'team' : 'process'}} was created${ if (!od.story.admin) { }$ by <span class='@{od.markup.actor}@'>{{ od.ctx.amActor ? 'you' : od.story.actor.alias || od.story.actor.id }}</span>${ } }$.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"delete": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} deleted the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> deleted the {{od.ctx.isTeam ? 'team' : 'process'}} " + "<span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> joined {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }$ as <ul class='@{od.markup.role_list}@'>${ if (od.ctx.isTeam) { }$${ _.forEach(od.story.roles, function(enabled, role) { }$<li><span class='@{od.markup.role}@'>{{role}}</span></li>${ }) }$${ } else if (od.ctx.isProcess) { }$${ _.forEach(od.story.roles, function(role, lane) { }$<li><span class='@{od.markup.role}@'>{{role}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ })}$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: "${ if (od.ctx.isDummy) { }$<i class='@{od.markup.dummy_icon}@'></i>${ } else { }$<img src='{{od.ext.base_url}}/{{od.ctx.amActor ? od.ext.profile.id : od.story.actor.id}}'>${ } }$"
},
"leave": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} left {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> left " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"kick": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} kicked {{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}} from {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> kicked " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'you' : od.story.player.alias||od.story.player.id}}" + "</span> from " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} accepted {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> accepted " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"invite:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} rejected {{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}} invitation to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span> rejected " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInviter ? 'your' : (od.story.inviter.alias||od.story.inviter.id) + '\u2019s'}}" + "</span> invitation to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:accept": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:request:reject": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} request for a change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}.",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> request for a change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"role:change": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - ${ if (od.story.admin) { }$[Admin Event] {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}${ } else { }${{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>${ if (od.story.admin) { }$<span class='@{od.markup.target}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}</span>${ } else { }$<span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> {{od.ctx.amActor ? 'have' : 'has'}} changed${ } }$ roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ <span class='@{od.markup.object}@'>{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}</span>${ } }${{ !!od.story.admin ? ' have been changed' : ''}}.<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'><li class='@{od.markup.list_header}@'>Changes</li>${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{role}}</span></li>${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$<li class='@{od.markup.diff_change}@'><span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from <span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane}}</span> lane</li>${ } else { }$<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'><span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in <span class='@{od.markup.lane}@'>{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}</li>${ } }$${ }); }$${ } }$</ul>.${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"role:assign": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ have been changed${ if (!od.story.admin) { }$ by {{od.ctx.amActor ? 'you' : od.story.actor.alias||od.story.actor.id}}${ } }$.\n Changes:${ if (od.ctx.isTeam) {_.forEach(od.story.changes, function(diff, role) { }$\n [{{ !diff.old ? '+' : '-'}}] {{role}}${ }); }$${ } else if (od.ctx.isProcess) {_.forEach(od.story.changes, function(diff, lane) {if(!!diff['old'] && !!diff['new']) { }$\n [+] {{diff['new']}} in {{lane}} lane\n [-] {{diff['old']}} in {{lane}} lane${ } else { }$\n [{{ !diff.old ? '+' : '-'}}] {{diff['new'] || diff['old']}} in {{lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane')}}${ }});} }$",
html: "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}" + "</span> roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ have been changed" + "${ if (!od.story.admin) { }$" + " by <span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'you' : " + "od.story.actor.alias||od.story.actor.id}}" + "</span>" + "${ } }$." + "<ul class='@{od.markup.role_list}@ @{od.markup.diff_list}@'>" + "<li class='@{od.markup.list_header}@'>Changes</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.changes, function(diff, role) { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{role}}</span>" + "</li>" + "${ }); }$" + "${ } else if (od.ctx.isProcess) {" + "_.forEach(od.story.changes, function(diff, lane) {" + "if(!!diff['old'] && !!diff['new']) { }$" + "<li class='@{od.markup.diff_change}@'>" + "<span class='@{od.markup.role}@ @{od.markup.diff_add}@'>{{diff['new']}}</span> from " + "<span class='@{od.markup.role}@ @{od.markup.diff_rem}@'>{{diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>{{lane}}</span> lane" + "</li>" + "${ } else { }$" + "<li class='@{od.markup[!diff.old ? 'diff_add' : 'diff_rem']}@'>" + "<span class='@{od.markup.role}@'>{{diff['new'] || diff['old']}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ } }$" + "${ }); }$" + "${ } }$" + "</ul>." + "${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"join:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to join ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.ctx.amMetaActor ? 'you' : od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request to join {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.ctx.amMetaActor ? 'you' : od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to join " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request to join " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amMetaActor ? 'you' : " + "od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"invite": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your invitation to {{od.story.invitee.alias||od.story.invitee.id}} to join ${ } else { }${{od.story.actor.alias||od.story.actor.id}} invited you to join ${ } }$the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.story.actor.alias||od.story.actor.id}} withdrew the invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'.${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$[{{moment(od.story.accepted_at||od.story.rejected_at).format('llll')}}] - {{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}} {{od.story.accepted_at ? 'accepted' : 'rejected'}} {{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}} invitation to join the {{od.ctx.isTeam ? 'team' : 'process'}} '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}' as ${ if (od.ctx.isTeam) { }${{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) { }${{_.reduce(od.story.roles, function(list, role, lane) {list.push([role + ' in ' + (lane === '*' ? 'All lanes' : lane === '~' ? 'No lanes' : (lane + ' lane'))]);return list;}, []).join(', ')}}${ } }$.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> invitation to " + "<span class='@{od.markup.target}@'>{{od.story.invitee.alias||od.story.invitee.id}}</span>" + " to join " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>{{od.story.actor.alias||od.story.actor.id}}</span> " + "invited <span class='@{od.markup.target}@'>you</span> to join " + "${ } }$" + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span>" + " withdrew the invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED' || od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.target}@'>" + "{{od.ctx.amInvitee ? 'You' : od.story.invitee.alias||od.story.invitee.id}}" + "</span> {{od.story.accepted_at ? 'accepted' : 'rejected'}} " + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'your' : (od.story.actor.alias||od.story.actor.id)+'\u2019s'}}" + "</span>" + " invitation to join " + "the {{od.ctx.isTeam ? 'team' : 'process'}}" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + " as " + "<ul class='@{od.markup.role_list}@'>" + "${ if (od.ctx.isTeam) { }$" + "${ _.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ }) }$" + "${ } else if (od.ctx.isProcess) { }$" + "${ _.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ })}$" + "${ } }$</ul>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at||od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"role:request": {
text: "${ if(od.story.state === 'PENDING') { }$[{{moment(od.story.timestamp).format('llll')}}] - ${ if(od.ctx.amActor) { }$Your request for change of roles in ${ } else { }${{od.story.actor.alias||od.story.actor.id}} wants to change roles in ${ } }${{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id : od.story.process.name || od.story.process.id}}'${ } }${{ od.ctx.amActor ? ' is pending' : '' }}.\n New Roles:${ if (od.ctx.isTeam) { }$\n [*] {{_.keys(od.story.roles).join(', ')}}${ } else if (od.ctx.isProcess) {_.forEach(od.story.roles, function(role, lane) { }$\n [*] {{role}} in {{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}} {{lane === '*' || lane === '~' ? 'lanes' : 'lane'}}${ });} }$${ } else if(od.story.state === 'CANCELLED') { }$[{{moment(od.story.cancelled_at).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} cancelled the request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$.${ } else if(od.story.state === 'ACCEPTED') { }$[{{moment(od.story.accepted_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been accepted by {{od.story.accepted_by.alias||od.story.accepted_by.id}}.${ } else if(od.story.state === 'REJECTED') { }$[{{moment(od.story.rejected_at).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} request for change of roles in {{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}${ if (!od.ctx.isItem) { }$ '{{od.story.team ? od.story.team.name || od.story.team.id :od.story.process.name || od.story.process.id}}'${ } }$ has been rejected by {{od.story.rejected_by.alias||od.story.rejected_by.id}}.${ } }$",
html: "${ if(od.story.state === 'PENDING') { }$" + "<div class='@{od.markup.content}@'>" + "${ if(od.ctx.amActor) { }$" + "<span class='@{od.markup.actor}@'>Your</span> request for change of roles in " + "${ } else { }$" + "<span class='@{od.markup.actor}@'>" + "{{od.story.actor.alias||od.story.actor.id}}" + "</span> wants to change roles in " + "${ } }$" + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$" + "{{ od.ctx.amActor ? ' is pending' : '' }}." + "<ul class='@{od.markup.role_list}@'>" + "<li class='@{od.markup.list_header}@'>New Roles</li>" + "${ if (od.ctx.isTeam) {" + "_.forEach(od.story.roles, function(enabled, role) { }$" + "<li><span class='@{od.markup.role}@'>{{role}}</span></li>" + "${ })" + "} else if (od.ctx.isProcess) {" + "_.forEach(od.story.roles, function(role, lane) { }$" + "<li>" + "<span class='@{od.markup.role}@'>{{role}}</span> in " + "<span class='@{od.markup.lane}@'>" + "{{lane === '*' ? 'All' : lane === '~' ? 'No' : lane}}" + "</span> {{lane === '*'||lane === '~' ? 'lanes' : 'lane' }}" + "</li>" + "${ });" + "} }$" + "</ul>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'CANCELLED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " cancelled the request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.cancelled_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'ACCEPTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been accepted by " + "<span class='@{od.markup.target}@'>" + "{{od.story.accepted_by.alias||od.story.accepted_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.accepted_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } else if(od.story.state === 'REJECTED') { }$" + "<div class='@{od.markup.content}@'>" + "<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}" + "</span> request for change of roles in " + "{{od.ctx.isItem ? 'this' : 'the'}} {{od.ctx.isTeam ? 'team' : 'process'}}" + "${ if (!od.ctx.isItem) { }$" + " <span class='@{od.markup.object}@'>" + "{{od.story.team ? od.story.team.name || od.story.team.id :" + "od.story.process.name || od.story.process.id}}" + "</span>" + "${ } }$ has been rejected by " + "<span class='@{od.markup.target}@'>" + "{{od.story.rejected_by.alias||od.story.rejected_by.id}}" + "</span>." + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.rejected_at)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>" + "${ } }$",
image: ''
},
"progress": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$.${ if (od.story.changes) { }$\n Changes:${ } }$${ for (i = 0, _ref = (od.story.changes || []), len = _ref.length; i < _ref.length; i++) { change = _ref[i];if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old'] || 0);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString(); }$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }} }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span>.${ if(od.story.changes) { }$<table class='@{od.markup.score_table}@'>${ }for (i = 0,\n _ref = (od.story.changes || []),\n len = _ref.length; i < _ref.length; i++) {\n change = _ref[i];if (change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old'] || 0);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old'] || '--'}}</span></td></tr></tbody>${ }}if(od.story.changes) { }$</table>${ }if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"resolution": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.activity.name}}' in {{od.ctx.isItem ? 'this' : 'the'}} process${ if(!od.ctx.isItem) { }$ '{{od.story.process.name || od.story.process.id}}'${ } }$ and credited {{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}} for completing '{{od.story.deferred.activity.name}}'.\n Changes:${ for (i = 0, _ref = (od.story.deferred.changes || []), len = _ref.length; i < _ref.length; i++) { change = _ref[i];if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old'] || 0);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString()}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }} }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.activity.name}}</span> and credited <span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? (od.ctx.amActor ? 'yourself' : 'you') : od.story.deferred.actor.alias||od.story.deferred.actor.id}}</span> for completing <span class='@{od.markup.score_activity}@'>{{od.story.deferred.activity.name}}</span>.<table class='@{od.markup.score_table}@'>${ for (i = 0, _ref = (od.story.deferred.changes || []), len = _ref.length; i < _ref.length; i++) { change = _ref[i];if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old'] || 0);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span></td></tr></tbody>${ }} }$</table>${ if(!od.ctx.isItem) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.object}@'>{{od.story.process.name||od.story.process.id}}</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"level": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}} ${ change = od.story.changes[0]; }$'{{change.metric.name}}' level changed ${ if (change.delta['old']) { }$from '{{change.delta['old']}}' ${ } }$to '{{change.delta['new']}}'.",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'Your' : (od.story.actor.alias||od.story.actor.id) + '\u2019s'}}</span> ${ change = od.story.changes[0]; }$<span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span> level changed${ if (change.delta['old']) { }$ from <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old']}}</span>${ } }$ to <span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span>.</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"achievement": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'Congratulations! You' : od.story.actor.alias||od.story.actor.id}} unlocked an achievement.\n" + " Changes:" + "${ for (i = 0, _ref = (od.story.changes || []), len = _ref.length; i < _ref.length; i++) { change = _ref[i]; }$" + "\n [>] {{change.metric.name}}" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "\n [*] {{diff}} {{item}}" + "${ }); }$" + "${ } }$",
html: "<div class='@{od.markup.content}@'>" + "{{od.ctx.amActor ? 'Congratulations! ' : ''}}<span class='@{od.markup.actor}@'>" + "{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}" + "</span>" + " unlocked an achievement." + "<table class='@{od.markup.score_table}@ @{od.markup.achievement_table}@'>" + "${ for (i = 0, _ref = (od.story.changes || []), len = _ref.length; i < _ref.length; i++) { change = _ref[i]; }$" + "<tbody class='@{od.markup.score_table_header}@'>" + "<tr>" + "<td colspan='2'>" + "<span class='@{od.markup.score_metric}@'>" + "{{change.metric.name}}" + "</span>" + "</td>" + "</tr>" + "</tbody>" + "<tbody class='@{od.markup.score_table_body}@'>" + "${ _.forEach(change.delta, function(delta, item) {" + "diff = ZERO.plus(delta['new']).minus(delta['old']||'0');" + "diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();" + "}$" + "<tr>" + "<td>" + "<span class='@{od.markup.score_delta_item}@'>" + "{{item}}" + "</span>" + "</td>" + "<td>" + "<span class='@{od.markup.score_delta_value}@'>" + "{{diff}}" + "</span>" + "</td>" + "</tr>" + "${ }); }$" + "</tbody>" + "${ } }$" + "</table>" + "</div>" + "<time class='@{od.markup.timestamp}@' title='On " + "{{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>" + "{{ts.fromNow()}}</time>",
image: ''
},
"score": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{ od.story.admin ? '[Admin Event] ' : '' }}{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}} scores were changed.\n New Scores:${ for (i = 0, _ref = (od.story.changes || []), len = _ref.length; i < _ref.length; i++) { change = _ref[i];if(change.metric.type === 'point') { }$\n [*] {{change.delta['new']}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) { }$\n [*] {{delta['new']}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [*] {{change.metric.name}} - {{change.delta['new']}}${ }} }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.target}@'>{{od.ctx.amPlayer ? 'Your' : (od.story.player.alias||od.story.player.id) + '\u2019s'}}</span> scores were changed.<table class='@{od.markup.score_table}@'>${ for (i = 0, _ref = (od.story.changes || []), len = _ref.length; i < _ref.length; i++) { change = _ref[i];if (change.metric.type === 'point') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) { }$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{delta['new']}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{change.delta['new']}}</span></td></tr></tbody>${ }} }$</table>${ if (!!od.story.admin) { }$<footer class='@{od.markup.footer}@'><span class='@{od.markup.admin}@'>Admin Event</span></footer>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"escalation": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.story.message}}${ if (!!od.story.completed) { var completed = od.story.completed; }$ [*] {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}}\n [{{moment(od.story.timestamp).format('llll')}}]${ } }$",
html: "<div class='@{od.markup.content}@@{!!od.story.completed?' '+od.markup.escalation_inactive:''}@'>{{od.story.message}}</div>${ if (!!od.story.completed) { var completed = od.story.completed; }$<footer class='@{od.markup.footer}@ @{od.markup.escalation_footer}@'><span class='@{od.markup.escalation_player}@'> {{od.ctx.amPlayer ? 'You' : completed.player.alias||completed.player.id}} completed {{completed.trigger.name||completed.trigger.id}} </span><time class='@{od.markup.escalation_timestamp}@ @{od.markup.timestamp}@' title='Completed on {{(ts = moment(completed.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time> </footer>${ } }$<time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
},
"action": {
text: "[{{moment(od.story.timestamp).format('llll')}}] - {{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}} completed '{{od.story.action.name}}'.${ if (od.story.changes) { }$\n Changes:${ } }$${ for (i = 0, _ref = (od.story.changes || []), len = _ref.length; i < _ref.length; i++) { change = _ref[i];if(change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old'] || 0);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString(); }$\n [*] {{diff}} {{change.metric.name}}${ } else if(change.metric.type === 'set') { }$\n [>] {{change.metric.name}}${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$\n [*] {{diff}} {{item}}${ }); }$${ } else if(change.metric.type === 'state') { }$\n [>] {{change.metric.name}}\n [+] {{change.delta['new']}}\n [-] {{change.delta['old']}}${ }} }$",
html: "<div class='@{od.markup.content}@'><span class='@{od.markup.actor}@'>{{od.ctx.amActor ? 'You' : od.story.actor.alias||od.story.actor.id}}</span> completed <span class='@{od.markup.score_activity}@'>{{od.story.action.name}}</span>.${ if(od.story.changes) { }$<table class='@{od.markup.score_table}@'>${ } }$${ for (i = 0,\n _ref = (od.story.changes || []),\n len = _ref.length; i < _ref.length; i++) {\n change = _ref[i];if (change.metric.type === 'point') {diff = ZERO.plus(change.delta['new']).minus(change.delta['old'] || 0);diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tbody class='@{od.markup.score_table_header}@'><tr><td><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr></tbody>${ } else if(change.metric.type === 'set') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'>${ _.forEach(change.delta, function(delta, item) {diff = ZERO.plus(delta['new']).minus(delta['old']||'0');diff = (diff.gt(ZERO) ? '+' : '') + diff.toString();}$<tr><td><span class='@{od.markup.score_delta_item}@'>{{item}}</span></td><td><span class='@{od.markup.score_delta_value}@'>{{diff}}</span></td></tr>${ }); }$</tbody>${ } else if(change.metric.type === 'state') { }$<tbody class='@{od.markup.score_table_header}@'><tr><td colspan='2'><span class='@{od.markup.score_metric}@'>{{change.metric.name}}</span></td></tr></tbody><tbody class='@{od.markup.score_table_body}@'><tr><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_add}@'>{{change.delta['new']}}</span></td><td><span class='@{od.markup.score_delta_value}@ @{od.markup.diff_rem}@'>{{change.delta['old'] || '--'}}</span></td></tr></tbody>${ }}if(od.story.changes) { }$</table>${ } }$</div><time class='@{od.markup.timestamp}@' title='On {{(ts = moment(od.story.timestamp)).format(\'llll\')}}'>{{ts.fromNow()}}</time>",
image: ''
}
};
function Odysseus(options) {
options = options || {};
this.options = _.defaults(options, {
markup: Odysseus.default_markup,
external: {}
});
}
Odysseus.prototype.buildContext = function(story, ext) {
var ctx, _ref, _ref1, _ref10, _ref11, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
ctx = {};
ctx.isDummy = ext.env === 'debug';
ctx.isItem = (_ref = ext.context) === 'team' || _ref === 'process';
if ((story.team != null) || ext.context === 'team') {
ctx.isTeam = true;
} else if ((story.process != null) || ext.context === 'process') {
ctx.isProcess = true;
}
if ((_ref1 = story.event) === 'create' || _ref1 === 'delete' || _ref1 === 'join' || _ref1 === 'leave' || _ref1 === 'kick' || _ref1 === 'join:request' || _ref1 === 'join:request:accept' || _ref1 === 'join:request:reject' || _ref1 === 'invite' || _ref1 === 'invite:accept' || _ref1 === 'invite:reject' || _ref1 === 'role:change' || _ref1 === 'role:request' || _ref1 === 'role:request:accept' || _ref1 === 'role:request:reject' || _ref1 === 'role:assign' || _ref1 === 'progress' || _ref1 === 'level' || _ref1 === 'achievement' || _ref1 === 'resolution' || _ref1 === 'action') {
if (!((story.actor != null) && ((_ref2 = ext.profile) != null ? _ref2.id : void 0) !== story.actor.id)) {
ctx.amActor = true;
}
}
if ((_ref3 = story.event) === 'kick' || _ref3 === 'join:request:accept' || _ref3 === 'join:request:reject' || _ref3 === 'role:request:accept' || _ref3 === 'role:request:reject' || _ref3 === 'role:assign' || _ref3 === 'score') {
if (!((story.player != null) && ((_ref4 = ext.profile) != null ? _ref4.id : void 0) !== story.player.id)) {
ctx.amPlayer = true;
}
} else if (story.event === 'resolution') {
if (!((story.deferred.actor != null) && ((_ref5 = ext.profile) != null ? _ref5.id : void 0) !== story.deferred.actor.id)) {
ctx.amPlayer = true;
}
} else if ((_ref6 = story.event) === 'invite:accept' || _ref6 === 'invite:reject') {
if (!((story.inviter != null) && ((_ref7 = ext.profile) != null ? _ref7.id : void 0) !== story.inviter.id)) {
ctx.amInviter = true;
}
} else if (story.event === 'invite') {
if (!((story.invitee != null) && ((_ref8 = ext.profile) != null ? _ref8.id : void 0) !== story.invitee.id)) {
ctx.amInvitee = true;
}
} else if (story.event === 'join:request') {
if (story.state === 'ACCEPTED' && ((_ref9 = ext.profile) != null ? _ref9.id : void 0) === story.accepted_by.id || story.state === 'REJECTED' && ((_ref10 = ext.profile) != null ? _ref10.id : void 0) === story.rejected_by.id) {
ctx.amMetaActor = true;
}
} else if (story.event === 'escalation') {
if ((story.completed != null) && ((_ref11 = ext.profile) != null ? _ref11.id : void 0) === story.completed.player.id) {
ctx.amPlayer = true;
}
}
return ctx;
};
Odysseus.prototype.compile = function(evt, type) {
var tpl, tpl_collection;
if ((tpl_collection = Odysseus.stored_templates[evt]) == null) {
throw "The " + evt + " event is not supported";
}
if ((tpl = tpl_collection[type]) == null) {
throw "The " + type + " template for " + evt + " event cannot be found";
}
return _.template(tpl);
};
Odysseus.prototype.toString = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'text');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context
});
};
Odysseus.prototype.toHTML = function(story, external_data, config) {
var context, html, image, template;
if (external_data == null) {
external_data = {};
}
if (config == null) {
config = {};
}
if (story == null) {
throw 'The story is not available';
}
template = this.compile(story.event, 'html');
context = this.buildContext(story, external_data);
html = template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
if (story.event === 'escalation') {
html = _.unescape(html);
}
if (config.image === true) {
image = "<div class='" + this.options.markup.image + "'>" + (this.getImage(story, external_data)) + "</div>";
html = image + html;
}
return html;
};
Odysseus.prototype.getImage = function(story, external_data) {
var context, template;
if (external_data == null) {
external_data = {};
}
if (story == null) {
throw 'The story is not available';
}
if (external_data.base_url == null) {
throw 'The base source url is not specified';
}
template = this.compile(story.event, 'image');
context = this.buildContext(story, external_data);
return template({
story: story,
ext: external_data,
ctx: context,
markup: this.options.markup
});
};
return Odysseus;
})();
return Odysseus;
});
File diff suppressed because one or more lines are too long