complete generate grid via pure javascript