New: Javascript version using same Java source

some refactoring was required