JS: Reworked code and prepared for next version

Change-Id: I33d46af7db8b6b747c6cae0ff8318738dca0e624