Skip to content

Commit

Permalink
Update exchange landmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
nickswalker committed Sep 30, 2023
1 parent b002cde commit 706f7d4
Show file tree
Hide file tree
Showing 3 changed files with 536 additions and 10 deletions.
9 changes: 4 additions & 5 deletions js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,17 @@ export function createLegDetailsTable(container, legsGeojson, exchangesGeoJson)
let data = []
let legDescriptions = ""

function formatLegDescription(startExchange, endExchange, leg, includeLegNumber=false, linkStations=false){
let legNumber = ""
if (includeLegNumber) legNumber = `<span class="leg-number">${leg.id}:</span> `
function formatLegDescription(startExchange, endExchange, leg){
let legNumber = `<span class="leg-number">${leg.id}:</span> `
let legName = `${legNumber}<a href="${startExchange.stationInfo}" target="_new">${startExchange.name}</a> to <a href="${endExchange.stationInfo}" target="_new">${endExchange.name}</a>`

return `<div class="d-flex flex-column flex-lg-row justify-content-between align-items-baseline"><h5>${legName}</h5><h6>${leg.distance_mi.toFixed(2)}mi ↑${leg.ascent_ft.toFixed(0)}ft ↓${leg.descent_ft.toFixed(0)}ft</h6></div><p class="mb-0">${leg.notes}</p>`
return `<div class="d-flex flex-column flex-lg-row justify-content-between align-items-baseline"><h5>${legName}</h5><h6>${leg.distance_mi.toFixed(2)}mi ↑${leg.ascent_ft.toFixed(0)}ft ↓${leg.descent_ft.toFixed(0)}ft</h6></div><i>Landmark: ${startExchange.landmark}</i><p class="mb-0">${leg.notes}</p>`
}
for (let leg of legsGeojson) {
let legData = leg.properties
legData.id = legData.start_exchange + 1
data.push(legData)
legDescriptions += `<div class="mb-4">${formatLegDescription(exchangesGeoJson[legData.start_exchange].properties, exchangesGeoJson[legData.end_exchange].properties, legData, true)}</div>`
legDescriptions += `<div class="mb-4">${formatLegDescription(exchangesGeoJson[legData.start_exchange].properties, exchangesGeoJson[legData.end_exchange].properties, legData)}</div>`
}
container.innerHTML = legDescriptions

Expand Down
Loading

0 comments on commit 706f7d4

Please sign in to comment.