Grid map modularization

Completed modularizing the grid javascript functions.