Simple A* pathfindind in javascript