|
1 | | -<div class="table-responsive"> |
| 1 | +<div class="table-responsive schedule-table-wrapper" data-unit="mi"> |
2 | 2 | <table class='schedule-table table'> |
3 | 3 | {% if include.show_header %} |
4 | 4 | <thead> |
5 | 5 | <tr> |
6 | 6 | <th>Date</th> |
7 | 7 | <th class="text-end">Time</th> |
8 | | - <th>Route (miles)</th> |
| 8 | + <th><div class="d-flex justify-content-between">Routes<span>Distance (<button class="dist-unit-toggle" title="For the enlightened..." style="background:none;border:none;padding:0;font:inherit;text-decoration:underline dotted;cursor:pointer;">mi</button>)</span></div></th> |
9 | 9 | </tr> |
10 | 10 | </thead> |
11 | 11 | {% endif %} |
|
15 | 15 | {% else %} |
16 | 16 | {% assign cancelled-class = "" %} |
17 | 17 | {% endif %} |
| 18 | + {% assign total_dist = 0.0 %} |
| 19 | + {% for _phase in run.plan %} |
| 20 | + {% unless _phase.cancelled %} |
| 21 | + {% if _phase.route_id %} |
| 22 | + {% assign _r = site.data.routes | where: 'id', _phase.route_id | first %} |
| 23 | + {% if _r.distance_mi %}{% assign total_dist = total_dist | plus: _r.distance_mi %}{% endif %} |
| 24 | + {% elsif _phase.route.distance_mi %} |
| 25 | + {% assign total_dist = total_dist | plus: _phase.route.distance_mi %} |
| 26 | + {% endif %} |
| 27 | + {% endunless %} |
| 28 | + {% endfor %} |
18 | 29 | <tbody class="run" data-date="{{ run.date }}"> |
19 | 30 | {% for plan in run.plan %} |
20 | 31 | {% if plan.cancelled %} |
|
44 | 55 | {% endunless %} |
45 | 56 | {% endif %} |
46 | 57 | <td class="{{part-cancelled-class}}"> |
47 | | - {% if plan.route_id %} |
48 | | - <a href="{{site.baseurl}}/routes/{{ plan.route_id }}/" |
49 | | - class="route-preview-map-link" |
50 | | - title="{{ plan.route_id }}" |
51 | | - popovertarget="map-popover-{{run.date | slugify}}-part-{{ forloop.index}}">{{route.name}}</a> |
52 | | - <div id="map-popover-{{run.date | slugify}}-part-{{ forloop.index}}" class="route-map-popover" popover> |
53 | | - <img src="{{ '/img/routes/' | append: plan.route_id | append: '.jpg' | relative_url }}" alt="{{ route.name }} map" class="route-image" loading="lazy"/> |
| 58 | + <div class="d-flex justify-content-between align-items-baseline gap-2"> |
| 59 | + <span> |
| 60 | + {% if plan.route_id %} |
| 61 | + <a href="{{site.baseurl}}/routes/{{ plan.route_id }}/" |
| 62 | + class="route-preview-map-link" |
| 63 | + title="{{ plan.route_id }}" |
| 64 | + popovertarget="map-popover-{{run.date | slugify}}-part-{{ forloop.index}}">{{route.name}}</a> |
| 65 | + <div id="map-popover-{{run.date | slugify}}-part-{{ forloop.index}}" class="route-map-popover" popover> |
| 66 | + <img src="{{ '/img/routes/' | append: plan.route_id | append: '.jpg' | relative_url }}" alt="{{ route.name }} map" class="route-image" loading="lazy"/> |
| 67 | + </div> |
| 68 | + {% elsif route.map %} |
| 69 | + <a target="_blank" href="{{ route.map }}">{{route.name}}</a> |
| 70 | + {% else %} |
| 71 | + {{route.name}} |
| 72 | + {% endif %} |
| 73 | + {% if route.gpx and include.link_gpx %} |
| 74 | + <a href="{{ route.gpx }}" class="gpx-link" title="Download GPX" data-goatcounter-click="download-{{ route.id }}">⌚</a> |
| 75 | + {% endif %} |
| 76 | + </span> |
| 77 | + {% if route.distance_mi %}<span class="dist-value text-end text-nowrap" data-mi="{{ route.distance_mi | round: 1 }}" data-km="{{ route.distance_mi | times: 1.609 | round: 1 }}">{{ route.distance_mi | round: 1 }}</span>{% endif %} |
54 | 78 | </div> |
55 | | - {% elsif route.map %} |
56 | | - <a target="_blank" href="{{ route.map }}">{{route.name}}</a> |
57 | | - {% else %} |
58 | | - {{route.name}} |
59 | | - {% endif %} |
60 | | - {% if route.distance_mi %} (<span title="{{ route.distance_mi | times: 1.609 | round: 1}}km" class="text-decoration-dashed">{{ route.distance_mi | round: 1}})</span>{% endif %} |
61 | | - {% if route.gpx and include.link_gpx %} |
62 | | - <a href="{{ route.gpx }}" class="gpx-link" title="Download GPX" data-goatcounter-click="download-{{ route.id }}">⌚</a> |
63 | | - {% endif %} |
64 | 79 | </td> |
65 | 80 | </tr> |
66 | 81 | {% if plan.notes %} |
|
90 | 105 | {% endif %} |
91 | 106 |
|
92 | 107 | {% endfor %} |
| 108 | + {% if total_dist > 0 and run.plan.size > 1 %} |
| 109 | + <tr class="total-dist-row"> |
| 110 | + <td></td><td></td> |
| 111 | + <td class="text-end fw-semibold"><hr class="my-1" style="border-top-width: 2px;"/><span class="dist-value" data-mi="{{ total_dist | round: 1 }}" data-km="{{ total_dist | times: 1.609 | round: 1 }}">{{ total_dist | round: 1 }}</span></td> |
| 112 | + </tr> |
| 113 | + {% endif %} |
93 | 114 | {% if run.cancelled and plan.cancelled != "" %} |
94 | 115 | <tr class="cancellation-note"> |
95 | 116 | <td></td> |
|
102 | 123 | <tfoot id="schedule-finished" style="display: none"><tr><td colspan="3">A new schedule is coming! <a href="https://github.com/raceconditionrunning/raceconditionrunning.github.io">Contribute on GitHub</a></td></tr></tfoot> |
103 | 124 | </table> |
104 | 125 | </div> |
| 126 | +<script> |
| 127 | +if (!window.__distToggleInit) { |
| 128 | + // For switching between miles and kilometers. |
| 129 | + window.__distToggleInit = true; |
| 130 | + document.addEventListener('click', (e) => { |
| 131 | + const btn = e.target.closest('.dist-unit-toggle'); |
| 132 | + if (!btn) { |
| 133 | + return; |
| 134 | + } |
| 135 | + const wrapper = btn.closest('.schedule-table-wrapper'); |
| 136 | + const newUnit = wrapper.dataset.unit === 'km' ? 'mi' : 'km'; |
| 137 | + wrapper.dataset.unit = newUnit; |
| 138 | + btn.textContent = newUnit; |
| 139 | + wrapper.querySelectorAll('.dist-value').forEach((span) => { |
| 140 | + span.textContent = span.dataset[newUnit]; |
| 141 | + }); |
| 142 | + }); |
| 143 | +} |
| 144 | +</script> |
0 commit comments