Add partially-functioning ternJS support

See issue #140
Merge pull request #149 from rrthomas/ternjs-support

Add partially-functioning ternJS support