Fix js synatx
Refactor most JS out of index