javascript library first commit.

it's really ugly code but it works well. Could do with some non-manual
tests.