various code styling changes and revert to javascript

Reverted code back to original (uses javascript to count instead of
angular)