BlinkTagInc / gtfs-to-html

Build human readable transit timetables as HTML or PDF from GTFS.
https://gtfstohtml.com
MIT License
184 stars 56 forks source link

Force overview to open route_urls in new tab #143

Closed brodyFlannigan closed 2 years ago

brodyFlannigan commented 2 years ago

Hi!

This will sound counter-productive UX-wise but I am looking to get the overview map to make the route_url open in a new tab when the route is clicked and the link selected on the map.

All that would need to happen is that the following attributes would need to be added to the anchor (<a>): target="_blank" rel="noreferrer noopener" I was trying to modify system-map.js but could not for the life of me figure out how to get those extra attributes appended to the anchor in the HTML for the map.

Could you please enlighten me on how I could get those attributes added to the links on the system map?

Thanks!

brendannee commented 2 years ago

You can add attributes to the tag using jQuery here:

https://github.com/BlinkTagInc/gtfs-to-html/blob/master/public/js/system-map.js#L8 (for the system map)

https://github.com/BlinkTagInc/gtfs-to-html/blob/master/public/js/timetable-map.js#L8 (for individual route maps)

  const html = route.route_url
    ? $('<a>')
      .attr('href', route.route_url)
      .attr('target', '_blank')
      .attr('rel', 'noreferrer noopener')
    : $('<div>');
brodyFlannigan commented 2 years ago

That's exactly what I was looking for. Thanks Brendan!

Closing issue!