mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
parse: refactor applyRemarks
This commit is contained in:
parent
018fc84bf5
commit
f02fe301c7
1 changed files with 9 additions and 14 deletions
|
@ -14,24 +14,19 @@ const applyRemarks = (leg, refs) => {
|
|||
for (let [remark, ref] of findRemarks(refs)) {
|
||||
const {fromLocation, toLocation} = ref
|
||||
|
||||
if (ref.fromLocation && ref.toLocation) {
|
||||
const fromI = leg.stopovers.findIndex(s => s.stop === fromLocation)
|
||||
const toI = leg.stopovers.findIndex(s => s.stop === toLocation)
|
||||
if (fromI < 0 || toI < 0) continue
|
||||
const fromI = fromLocation ? leg.stopovers.findIndex(s => s.stop === fromLocation) : -1
|
||||
const toI = toLocation ? leg.stopovers.findIndex(s => s.stop === toLocation) : -1
|
||||
if (fromI < 0 || toI < 0) continue
|
||||
|
||||
const wholeLeg = fromI === 0 && toI === (leg.stopovers.length - 1)
|
||||
if (!wholeLeg) {
|
||||
for (let i = fromI; i <= toI; i++) {
|
||||
const stopover = leg.stopovers[i]
|
||||
if (!stopover) continue
|
||||
addRemark(stopover, remark)
|
||||
}
|
||||
|
||||
continue
|
||||
const wholeLeg = fromI === 0 && toI === (leg.stopovers.length - 1)
|
||||
if (wholeLeg) addRemark(leg, remark)
|
||||
else {
|
||||
for (let i = fromI; i <= toI; i++) {
|
||||
const stopover = leg.stopovers[i]
|
||||
if (stopover) addRemark(stopover, remark)
|
||||
}
|
||||
}
|
||||
|
||||
addRemark(leg, remark)
|
||||
// todo: `ref.tagL`
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue