Made some progress on javascript.

NOTE: doesnt quite work yet