Fixes #111 - componentizes JavaScript

Uses module pattern to componentize JavaScript scripts.