| 1 |
|
| 2 |
function GetRatioNode(dob, salary, contextName) |
| 3 |
{ |
| 4 |
this.dob = dob; |
| 5 |
this.salary = salary; |
| 6 |
this.contextName = contextName; |
| 7 |
|
| 8 |
this.render = function( context ) |
| 9 |
{ |
| 10 |
var dob = this.dob.resolve(context); |
| 11 |
var salary = this.salary.resolve(context); |
| 12 |
var today = new Date(); |
| 13 |
var ageMS = today - dob; |
| 14 |
var ageYears = ageMS / (1000 * 60 * 60 * 24 * 365); |
| 15 |
var ratio = salary / ageYears; |
| 16 |
context.insert(this.contextName, ratio); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
function GetRatioNodeFactory( tagContent, parser ) |
| 21 |
{ |
| 22 |
var tagArgs = AbstractNodeFactory.smartSplit(tagContent); |
| 23 |
var node = new Node("GetRatioNode", FilterExpression(tagArgs[1]), FilterExpression(tagArgs[2]), tagArgs[4]); |
| 24 |
return node; |
| 25 |
} |
| 26 |
Library.addFactory("GetRatioNodeFactory", "get_ratio"); |