Skip to content

Commit 803422c

Browse files
committed
Make leg numbers more prominent on LRR page
Include in map leg popover Clean up formatting in segment calculator
1 parent b1f849b commit 803422c

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

js/LegCalculator.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,19 @@ export class LegCalculator extends HTMLElement {
111111

112112
// "values" has the "to" function from "format" applied
113113
// "unencoded" contains the raw numerical slider values
114+
let segmentLegDesc = ""
115+
if (rightValue - leftValue === 1) {
116+
segmentLegDesc = `<div class="text-secondary">Leg ${leftValue + 1}</div>`
117+
} else {
118+
segmentLegDesc = `<div class="text-secondary">${rightValue - leftValue} legs (${leftValue + 1} through
119+
${rightValue})</div>`
120+
}
114121
let segmentDesc = `
115122
<div class="d-flex flex-column flex-lg-row justify-content-between align-items-baseline">
116123
<h5>${segmentName}</h5>
117124
<div class="d-flex flex-column text-lg-end flex-shrink-0 mb-1">
118125
<h6 class="mb-0">${distance.toFixed(2)}mi ↑${ascent.toFixed(0)}ft ↓${descent.toFixed(0)}ft</h6>
119-
<div class="text-secondary">${rightValue - leftValue} legs (${leftValue + 1} through ${rightValue})</div>
126+
${segmentLegDesc}
120127
</div>
121128
</div>`
122129
container.querySelector("#leg-calculator-description").innerHTML = segmentDesc

js/RelayMap.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,11 @@ export class RelayMap extends LitElement {
432432
return bounds.extend(coord);
433433
}, new maplibregl.LngLatBounds(coordinates[0], coordinates[0]));
434434

435-
console.log("Clicked leg", leg.properties.id, "at coordinates", coordinates);
435+
const legDetails = {
436+
...leg.properties
437+
}
438+
legDetails.id += 1; // Convert to 1-based index for display
439+
legDetails.coordinates = coordinates; // Store the coordinates for elevation profile
436440
this.currentLegPopup = new maplibregl.Popup({
437441
anchor: "bottom-left",
438442
offset: [16, 0],
@@ -444,10 +448,7 @@ export class RelayMap extends LitElement {
444448
.setHTML(formatLegDescription(
445449
this.exchangeNames[leg.properties.start_exchange],
446450
this.exchangeNames[leg.properties.end_exchange],
447-
leg.properties,
448-
false,
449-
false,
450-
coordinates
451+
legDetails
451452
))
452453
.addTo(this.map);
453454

js/common.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,17 @@ export function durationToSeconds(duration) {
5555
return hours * 3600 + minutes * 60 + seconds
5656
}
5757

58-
export function formatLegDescription(startStation, endStation, leg, includeLegNumber=false, linkStations=false, coords=null){
58+
export function formatLegDescription(startStation, endStation, leg){
5959
let legNumber = ""
60-
if (includeLegNumber) legNumber = `<span class="leg-number">${leg.id}:</span> `
60+
let { id, coordinates, notes, distance_mi, ascent_ft, descent_ft } = leg
61+
if (id) legNumber = `<span class="leg-number">${id}:</span> `
62+
let profileSummary = ""
63+
if (ascent_ft && descent_ft) {
64+
profileSummary =<h6>${distance_mi.toFixed(2)}mi ↑${ascent_ft.toFixed(0)}ft ↓${descent_ft.toFixed(0)}ft</h6>
65+
}
6166
let profile = ""
62-
if (coords) profile = "<elevation-profile></elevation-profile>"
63-
return `<h5 class="mb-1">${legNumber}${startStation} to ${endStation}</h5><h6>${leg.distance_mi.toFixed(2)}mi ↑${leg.ascent_ft.toFixed(0)}ft ↓${leg.descent_ft.toFixed(0)}ft</h6>${profile}<p class="mb-0">${leg.notes}</p>`
67+
if (coordinates && coordinates.length > 0) profile = "<elevation-profile></elevation-profile>"
68+
return `<h5 class="mb-1">${legNumber}${startStation} to ${endStation}</h5>${profileSummary}${profile}<p class="mb-0">${notes}</p>`
6469
}
6570

6671
export function download(content, mimeType, filename) {

0 commit comments

Comments
 (0)