js: fix indentation, provide hooks and cast optoins
fix code conventions
fix incorrect define
fix options defaults and add template option