A* Search / Pathfinding Algorithm in Javascript