Re-abstracting javascript for arrivals.html