diff --git a/src/components/SceneryView/SceneryTimetable.vue b/src/components/SceneryView/SceneryTimetable.vue
index ce20156..03a6ab5 100644
--- a/src/components/SceneryView/SceneryTimetable.vue
+++ b/src/components/SceneryView/SceneryTimetable.vue
@@ -95,9 +95,12 @@
{{ timestampToString(scheduledTrain.stopInfo.arrivalTimestamp) }}
-
{{
- timestampToString(scheduledTrain.stopInfo.arrivalTimestamp)
- }}
+
+ {{
+ timestampToString(scheduledTrain.stopInfo.arrivalTimestamp)
+ }}
+
+
{{ timestampToString(scheduledTrain.stopInfo.arrivalRealTimestamp) }}
({{ scheduledTrain.stopInfo.arrivalDelay > 0 ? '+' : ''
@@ -108,11 +111,22 @@
-
- {{ scheduledTrain.stopInfo.stopTime }}
- {{ scheduledTrain.stopInfo.stopType || 'pt' }}
+
+
+ {{ scheduledTrain.stopInfo.stopTime }}
+ {{ scheduledTrain.stopInfo.stopType || 'pt' }}
+
+
+
+
+
+
+
+
+ {{ scheduledTrain.arrivingLine }}
+ {{ scheduledTrain.arrivingLine && scheduledTrain.departureLine && '>' }}
+ {{ scheduledTrain.departureLine }}
-
@@ -125,9 +139,11 @@
{{ timestampToString(scheduledTrain.stopInfo.departureTimestamp) }}
-
{{
- timestampToString(scheduledTrain.stopInfo.departureTimestamp)
- }}
+
+ {{
+ timestampToString(scheduledTrain.stopInfo.departureTimestamp)
+ }}
+
{{ timestampToString(scheduledTrain.stopInfo.departureRealTimestamp) }}
@@ -201,13 +217,15 @@ export default defineComponent({
station.onlineInfo?.scheduledTrains ||
[];
+ if (!scheduledTrains) return [];
+
return (
- scheduledTrains?.sort((a, b) => {
+ scheduledTrains.sort((a, b) => {
if (a.stopStatusID > b.stopStatusID) return 1;
- else if (a.stopStatusID < b.stopStatusID) return -1;
+ if (a.stopStatusID < b.stopStatusID) return -1;
if (a.stopInfo.arrivalTimestamp > b.stopInfo.arrivalTimestamp) return 1;
- else if (a.stopInfo.arrivalTimestamp < b.stopInfo.arrivalTimestamp) return -1;
+ if (a.stopInfo.arrivalTimestamp < b.stopInfo.arrivalTimestamp) return -1;
return a.stopInfo.departureTimestamp > b.stopInfo.departureTimestamp ? 1 : -1;
}) || []
@@ -459,10 +477,15 @@ h3.timetable-header {
position: relative;
display: flex;
flex-direction: column;
+ font-size: 0.85em;
+
+ padding: 0.3em 0;
+
+ .stop-line {
+ margin-top: 0.25em;
+ }
.stop-time {
- font-size: 0.85em;
- // position: absolute;
transform: translateY(-0.25em);
}
}
diff --git a/src/scripts/interfaces/ScheduledTrain.ts b/src/scripts/interfaces/ScheduledTrain.ts
index 079a42a..f138d8c 100644
--- a/src/scripts/interfaces/ScheduledTrain.ts
+++ b/src/scripts/interfaces/ScheduledTrain.ts
@@ -15,6 +15,9 @@ export default interface ScheduledTrain {
prevStationName: string;
nextStationName: string;
+ arrivingLine: string | null;
+ departureLine: string | null;
+
stopLabel: string;
stopStatus: string;
stopStatusID: number;
diff --git a/src/scripts/utils/storeUtils.ts b/src/scripts/utils/storeUtils.ts
index 8c9182b..e65ff3b 100644
--- a/src/scripts/utils/storeUtils.ts
+++ b/src/scripts/utils/storeUtils.ts
@@ -1,37 +1,38 @@
-import ScheduledTrain from "../interfaces/ScheduledTrain";
-import Train from "../interfaces/Train";
-import TrainStop from "../interfaces/TrainStop";
+import ScheduledTrain from '../interfaces/ScheduledTrain';
+import Train from '../interfaces/Train';
+import TrainStop from '../interfaces/TrainStop';
-export const getLocoURL = (locoType: string): string => (`https://rj.td2.info.pl/dist/img/thumbnails/${locoType.includes("EN") ? locoType + "rb" : locoType}.png`)
+export const getLocoURL = (locoType: string): string =>
+ `https://rj.td2.info.pl/dist/img/thumbnails/${locoType.includes('EN') ? locoType + 'rb' : locoType}.png`;
export const getStatusID = (stationStatus: any): string => {
- if (!stationStatus) return "unknown";
- if (stationStatus == -1) return "not-signed";
+ if (!stationStatus) return 'unknown';
+ if (stationStatus == -1) return 'not-signed';
const statusCode = stationStatus[2];
const statusTimestamp = stationStatus[3];
switch (statusCode) {
case 0:
- if (statusTimestamp - Date.now() > 21000000) return "no-limit";
+ if (statusTimestamp - Date.now() > 21000000) return 'no-limit';
- return "online";
+ return 'online';
case 1:
- return "brb";
+ return 'brb';
case 2:
- if (statusTimestamp == 0) return "ending";
+ if (statusTimestamp == 0) return 'ending';
break;
case 3:
- return "no-space";
+ return 'no-space';
default:
break;
}
- return "unavailable";
+ return 'unavailable';
};
export const getStatusTimestamp = (stationStatus: any): number => {
@@ -59,10 +60,10 @@ export const getStatusTimestamp = (stationStatus: any): number => {
export const parseSpawns = (spawnString: string) => {
if (!spawnString) return [];
- if (spawnString === "NO_SPAWN") return [];
+ if (spawnString === 'NO_SPAWN') return [];
- return spawnString.split(";").map(spawn => {
- const spawnArray = spawn.split(",");
+ return spawnString.split(';').map((spawn) => {
+ const spawnArray = spawn.split(',');
const spawnName = spawnArray[6] ? spawnArray[6] : spawnArray[0];
const spawnLength = parseInt(spawnArray[2]);
@@ -73,40 +74,39 @@ export const parseSpawns = (spawnString: string) => {
export const getTimestamp = (date: string | null): number => (date ? new Date(date).getTime() : 0);
export const getTrainStopStatus = (stopInfo: TrainStop, currentStationName: string, stationName: string) => {
- let stopStatus = "",
- stopLabel = "",
+ let stopStatus = '',
+ stopLabel = '',
stopStatusID = -1;
if (stopInfo.terminatesHere && stopInfo.confirmed) {
- stopStatus = "terminated";
- stopLabel = "Skończył bieg";
+ stopStatus = 'terminated';
+ stopLabel = 'Skończył bieg';
stopStatusID = 5;
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName == stationName) {
- stopStatus = "departed";
- stopLabel = "Odprawiony";
+ stopStatus = 'departed';
+ stopLabel = 'Odprawiony';
stopStatusID = 2;
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName != stationName) {
- stopStatus = "departed-away";
- stopLabel = "Odjechał";
+ stopStatus = 'departed-away';
+ stopLabel = 'Odjechał';
stopStatusID = 4;
} else if (currentStationName == stationName && !stopInfo.stopped) {
- stopStatus = "online";
- stopLabel = "Na stacji";
+ stopStatus = 'online';
+ stopLabel = 'Na stacji';
stopStatusID = 0;
} else if (currentStationName == stationName && stopInfo.stopped) {
- stopStatus = "stopped";
- stopLabel = "Postój";
+ stopStatus = 'stopped';
+ stopLabel = 'Postój';
stopStatusID = 1;
} else if (currentStationName != stationName) {
- stopStatus = "arriving";
- stopLabel = "W drodze";
+ stopStatus = 'arriving';
+ stopLabel = 'W drodze';
stopStatusID = 3;
}
return { stopStatus, stopLabel, stopStatusID };
};
-
export function getScheduledTrain(train: Train, trainStopIndex: number, stationName: string): ScheduledTrain {
const timetable = train.timetableData!;
const followingStops = timetable.followingStops;
@@ -114,22 +114,48 @@ export function getScheduledTrain(train: Train, trainStopIndex: number, stationN
const trainStopStatus = getTrainStopStatus(trainStop, train.currentStationName, stationName);
- let prevStationName = "", nextStationName = "";
+ let prevStationName = '',
+ nextStationName = '';
for (let i = trainStopIndex - 1; i >= 0; i--) {
- if (followingStops[i].stopName.startsWith("")) {
+ if (followingStops[i].stopName.startsWith('')) {
prevStationName = followingStops[i].stopNameRAW;
break;
}
}
for (let i = trainStopIndex + 1; i < followingStops.length; i++) {
- if (followingStops[i].stopName.startsWith("")) {
+ if (followingStops[i].stopName.startsWith('')) {
nextStationName = followingStops[i].stopNameRAW;
break;
}
}
+ let departureLine: string | null = trainStop.departureLine;
+ let arrivingLine: string | null = trainStop.arrivalLine;
+
+ for (let i = trainStopIndex; i < followingStops.length; i++) {
+ const currentStop = followingStops[i];
+
+ if (currentStop.departureLine == null) break;
+
+ if (!/-|_|it|sbl/gi.test(currentStop.departureLine)) {
+ departureLine = currentStop.departureLine;
+ break;
+ }
+ }
+
+ for (let i = trainStopIndex; i >= 0; i--) {
+ const currentStop = followingStops[i];
+
+ if (currentStop.arrivalLine == null) break;
+
+ if (!/-|_|it|sbl/gi.test(currentStop.arrivalLine)) {
+ arrivingLine = currentStop.arrivalLine;
+ break;
+ }
+ }
+
return {
trainNo: train.trainNo,
driverName: train.driverName,
@@ -139,13 +165,16 @@ export function getScheduledTrain(train: Train, trainStopIndex: number, stationN
category: timetable.category,
beginsAt: timetable.followingStops[0].stopNameRAW,
terminatesAt: timetable.followingStops[timetable.followingStops.length - 1].stopNameRAW,
-
+
nextStationName,
prevStationName,
stopInfo: trainStop,
stopLabel: trainStopStatus.stopLabel,
stopStatus: trainStopStatus.stopStatus,
- stopStatusID: trainStopStatus.stopStatusID
- }
-}
\ No newline at end of file
+ stopStatusID: trainStopStatus.stopStatusID,
+
+ arrivingLine,
+ departureLine,
+ };
+}
diff --git a/src/store/store.ts b/src/store/store.ts
index 32b606d..1b8c439 100644
--- a/src/store/store.ts
+++ b/src/store/store.ts
@@ -56,7 +56,7 @@ export const useStore = defineStore('store', {
setTrainsOnlineData() {
const { trains } = this.apiData;
- if (!trains) return [];
+ if (!trains) return [];
this.trainList = trains
.filter(
@@ -377,10 +377,11 @@ export const useStore = defineStore('store', {
return;
}
+
this.dataStatuses.sceneries = DataStatus.Loaded;
this.dataStatuses.trains = !this.apiData.trains ? DataStatus.Warning : DataStatus.Loaded;
this.dataStatuses.dispatchers = !this.apiData.dispatchers ? DataStatus.Warning : DataStatus.Loaded;
-
+
this.setTrainsOnlineData();
this.setStationsOnlineInfo();
},