~ubuntu-branches/ubuntu/trusty/grantlee/trusty

« back to all changes in this revision

Viewing changes to examples/contacts/themes/linguist/dopey/grantlee/0.1/ratio_calculator.qs

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-07 08:09:15 UTC
  • Revision ID: james.westby@ubuntu.com-20101207080915-ee6wcs8nv625su4b
Tags: 0.1.7-0ubuntu2
* Backport upstream commits 128272d4f65d7f02372cb606c148817c2f15a78d and
  5a71ed118f6fae67a4a26ab867ab7575e5a3e34c to moderate test requirements so
  it will build on armel
* Include missing grantlee_i18ntags.so and grantlee_mutabletags.so in
  libgrantlee-core0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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");