mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Zmiana wyglądu widoków i rozłożenia elementów na stronie (1.6.0a)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import ScheduledTrain from "../interfaces/ScheduledTrain";
|
||||
import Train from "../interfaces/Train";
|
||||
import TrainStop from "../interfaces/TrainStop";
|
||||
|
||||
@@ -106,10 +107,29 @@ export const getTrainStopStatus = (stopInfo: TrainStop, currentStationName: stri
|
||||
};
|
||||
|
||||
|
||||
export function getScheduledTrain(train: Train, trainStop: TrainStop, stationName: string) {
|
||||
export function getScheduledTrain(train: Train, trainStopIndex: number, stationName: string): ScheduledTrain {
|
||||
const timetable = train.timetableData!;
|
||||
const followingStops = timetable.followingStops;
|
||||
const trainStop = followingStops[trainStopIndex];
|
||||
|
||||
const trainStopStatus = getTrainStopStatus(trainStop, train.currentStationName, stationName);
|
||||
|
||||
let prevStationName = "", nextStationName = "";
|
||||
|
||||
for (let i = trainStopIndex - 1; i >= 0; i--) {
|
||||
if (followingStops[i].stopName.startsWith("<strong>")) {
|
||||
prevStationName = followingStops[i].stopNameRAW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = trainStopIndex + 1; i < followingStops.length; i++) {
|
||||
if (followingStops[i].stopName.startsWith("<strong>")) {
|
||||
nextStationName = followingStops[i].stopNameRAW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
trainNo: train.trainNo,
|
||||
driverName: train.driverName,
|
||||
@@ -119,7 +139,10 @@ export function getScheduledTrain(train: Train, trainStop: TrainStop, stationNam
|
||||
category: timetable.category,
|
||||
beginsAt: timetable.followingStops[0].stopNameRAW,
|
||||
terminatesAt: timetable.followingStops[timetable.followingStops.length - 1].stopNameRAW,
|
||||
nearestStop: "",
|
||||
|
||||
nextStationName,
|
||||
prevStationName,
|
||||
|
||||
stopInfo: trainStop,
|
||||
stopLabel: trainStopStatus.stopLabel,
|
||||
stopStatus: trainStopStatus.stopStatus,
|
||||
|
||||
Reference in New Issue
Block a user