Broke out javascript into separate file

Also started switching to vertex-, rather than tile-based neighbor
checking.