Dodano szlaki zewnętrzne dla RJ scenerii

This commit is contained in:
2022-07-06 22:07:01 +02:00
parent aebcad662d
commit f91d08be79
4 changed files with 110 additions and 54 deletions
+38 -15
View File
@@ -95,9 +95,12 @@
<span>{{ timestampToString(scheduledTrain.stopInfo.arrivalTimestamp) }}</span> <span>{{ timestampToString(scheduledTrain.stopInfo.arrivalTimestamp) }}</span>
</div> </div>
<div v-else> <div v-else>
<s style="margin-right: 0.2em" class="text--grayed">{{ <div>
timestampToString(scheduledTrain.stopInfo.arrivalTimestamp) <s style="margin-right: 0.2em" class="text--grayed">{{
}}</s> timestampToString(scheduledTrain.stopInfo.arrivalTimestamp)
}}</s>
</div>
<span> <span>
{{ timestampToString(scheduledTrain.stopInfo.arrivalRealTimestamp) }} {{ timestampToString(scheduledTrain.stopInfo.arrivalRealTimestamp) }}
({{ scheduledTrain.stopInfo.arrivalDelay > 0 ? '+' : '' ({{ scheduledTrain.stopInfo.arrivalDelay > 0 ? '+' : ''
@@ -108,11 +111,22 @@
</span> </span>
<span class="schedule-stop"> <span class="schedule-stop">
<span class="stop-time" v-if="scheduledTrain.stopInfo.stopTime"> <span class="stop-time">
{{ scheduledTrain.stopInfo.stopTime }} <span v-if="scheduledTrain.stopInfo.stopTime">
{{ scheduledTrain.stopInfo.stopType || 'pt' }} {{ scheduledTrain.stopInfo.stopTime }}
{{ scheduledTrain.stopInfo.stopType || 'pt' }}
</span>
<span v-else>&nbsp;</span>
</span>
<span class="arrow"></span>
<span class="stop-line">
{{ scheduledTrain.arrivingLine }}
{{ scheduledTrain.arrivingLine && scheduledTrain.departureLine && '&gt;' }}
{{ scheduledTrain.departureLine }}
</span> </span>
<span class="stop-arrow arrow"></span>
</span> </span>
<span class="schedule-departure"> <span class="schedule-departure">
@@ -125,9 +139,11 @@
<span>{{ timestampToString(scheduledTrain.stopInfo.departureTimestamp) }}</span> <span>{{ timestampToString(scheduledTrain.stopInfo.departureTimestamp) }}</span>
</div> </div>
<div v-else> <div v-else>
<s style="margin-right: 0.2em" class="text--grayed">{{ <div>
timestampToString(scheduledTrain.stopInfo.departureTimestamp) <s style="margin-right: 0.2em" class="text--grayed">{{
}}</s> timestampToString(scheduledTrain.stopInfo.departureTimestamp)
}}</s>
</div>
<span> <span>
{{ timestampToString(scheduledTrain.stopInfo.departureRealTimestamp) }} {{ timestampToString(scheduledTrain.stopInfo.departureRealTimestamp) }}
@@ -201,13 +217,15 @@ export default defineComponent({
station.onlineInfo?.scheduledTrains || station.onlineInfo?.scheduledTrains ||
[]; [];
if (!scheduledTrains) return [];
return ( return (
scheduledTrains?.sort((a, b) => { scheduledTrains.sort((a, b) => {
if (a.stopStatusID > b.stopStatusID) return 1; 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; 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; return a.stopInfo.departureTimestamp > b.stopInfo.departureTimestamp ? 1 : -1;
}) || [] }) || []
@@ -459,10 +477,15 @@ h3.timetable-header {
position: relative; position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
font-size: 0.85em;
padding: 0.3em 0;
.stop-line {
margin-top: 0.25em;
}
.stop-time { .stop-time {
font-size: 0.85em;
// position: absolute;
transform: translateY(-0.25em); transform: translateY(-0.25em);
} }
} }
+3
View File
@@ -15,6 +15,9 @@ export default interface ScheduledTrain {
prevStationName: string; prevStationName: string;
nextStationName: string; nextStationName: string;
arrivingLine: string | null;
departureLine: string | null;
stopLabel: string; stopLabel: string;
stopStatus: string; stopStatus: string;
stopStatusID: number; stopStatusID: number;
+64 -35
View File
@@ -1,37 +1,38 @@
import ScheduledTrain from "../interfaces/ScheduledTrain"; import ScheduledTrain from '../interfaces/ScheduledTrain';
import Train from "../interfaces/Train"; import Train from '../interfaces/Train';
import TrainStop from "../interfaces/TrainStop"; 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 => { export const getStatusID = (stationStatus: any): string => {
if (!stationStatus) return "unknown"; if (!stationStatus) return 'unknown';
if (stationStatus == -1) return "not-signed"; if (stationStatus == -1) return 'not-signed';
const statusCode = stationStatus[2]; const statusCode = stationStatus[2];
const statusTimestamp = stationStatus[3]; const statusTimestamp = stationStatus[3];
switch (statusCode) { switch (statusCode) {
case 0: case 0:
if (statusTimestamp - Date.now() > 21000000) return "no-limit"; if (statusTimestamp - Date.now() > 21000000) return 'no-limit';
return "online"; return 'online';
case 1: case 1:
return "brb"; return 'brb';
case 2: case 2:
if (statusTimestamp == 0) return "ending"; if (statusTimestamp == 0) return 'ending';
break; break;
case 3: case 3:
return "no-space"; return 'no-space';
default: default:
break; break;
} }
return "unavailable"; return 'unavailable';
}; };
export const getStatusTimestamp = (stationStatus: any): number => { export const getStatusTimestamp = (stationStatus: any): number => {
@@ -59,10 +60,10 @@ export const getStatusTimestamp = (stationStatus: any): number => {
export const parseSpawns = (spawnString: string) => { export const parseSpawns = (spawnString: string) => {
if (!spawnString) return []; if (!spawnString) return [];
if (spawnString === "NO_SPAWN") return []; if (spawnString === 'NO_SPAWN') return [];
return spawnString.split(";").map(spawn => { return spawnString.split(';').map((spawn) => {
const spawnArray = spawn.split(","); const spawnArray = spawn.split(',');
const spawnName = spawnArray[6] ? spawnArray[6] : spawnArray[0]; const spawnName = spawnArray[6] ? spawnArray[6] : spawnArray[0];
const spawnLength = parseInt(spawnArray[2]); 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 getTimestamp = (date: string | null): number => (date ? new Date(date).getTime() : 0);
export const getTrainStopStatus = (stopInfo: TrainStop, currentStationName: string, stationName: string) => { export const getTrainStopStatus = (stopInfo: TrainStop, currentStationName: string, stationName: string) => {
let stopStatus = "", let stopStatus = '',
stopLabel = "", stopLabel = '',
stopStatusID = -1; stopStatusID = -1;
if (stopInfo.terminatesHere && stopInfo.confirmed) { if (stopInfo.terminatesHere && stopInfo.confirmed) {
stopStatus = "terminated"; stopStatus = 'terminated';
stopLabel = "Skończył bieg"; stopLabel = 'Skończył bieg';
stopStatusID = 5; stopStatusID = 5;
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName == stationName) { } else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName == stationName) {
stopStatus = "departed"; stopStatus = 'departed';
stopLabel = "Odprawiony"; stopLabel = 'Odprawiony';
stopStatusID = 2; stopStatusID = 2;
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName != stationName) { } else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName != stationName) {
stopStatus = "departed-away"; stopStatus = 'departed-away';
stopLabel = "Odjechał"; stopLabel = 'Odjechał';
stopStatusID = 4; stopStatusID = 4;
} else if (currentStationName == stationName && !stopInfo.stopped) { } else if (currentStationName == stationName && !stopInfo.stopped) {
stopStatus = "online"; stopStatus = 'online';
stopLabel = "Na stacji"; stopLabel = 'Na stacji';
stopStatusID = 0; stopStatusID = 0;
} else if (currentStationName == stationName && stopInfo.stopped) { } else if (currentStationName == stationName && stopInfo.stopped) {
stopStatus = "stopped"; stopStatus = 'stopped';
stopLabel = "Postój"; stopLabel = 'Postój';
stopStatusID = 1; stopStatusID = 1;
} else if (currentStationName != stationName) { } else if (currentStationName != stationName) {
stopStatus = "arriving"; stopStatus = 'arriving';
stopLabel = "W drodze"; stopLabel = 'W drodze';
stopStatusID = 3; stopStatusID = 3;
} }
return { stopStatus, stopLabel, stopStatusID }; return { stopStatus, stopLabel, stopStatusID };
}; };
export function getScheduledTrain(train: Train, trainStopIndex: number, stationName: string): ScheduledTrain { export function getScheduledTrain(train: Train, trainStopIndex: number, stationName: string): ScheduledTrain {
const timetable = train.timetableData!; const timetable = train.timetableData!;
const followingStops = timetable.followingStops; const followingStops = timetable.followingStops;
@@ -114,22 +114,48 @@ export function getScheduledTrain(train: Train, trainStopIndex: number, stationN
const trainStopStatus = getTrainStopStatus(trainStop, train.currentStationName, stationName); const trainStopStatus = getTrainStopStatus(trainStop, train.currentStationName, stationName);
let prevStationName = "", nextStationName = ""; let prevStationName = '',
nextStationName = '';
for (let i = trainStopIndex - 1; i >= 0; i--) { for (let i = trainStopIndex - 1; i >= 0; i--) {
if (followingStops[i].stopName.startsWith("<strong>")) { if (followingStops[i].stopName.startsWith('<strong>')) {
prevStationName = followingStops[i].stopNameRAW; prevStationName = followingStops[i].stopNameRAW;
break; break;
} }
} }
for (let i = trainStopIndex + 1; i < followingStops.length; i++) { for (let i = trainStopIndex + 1; i < followingStops.length; i++) {
if (followingStops[i].stopName.startsWith("<strong>")) { if (followingStops[i].stopName.startsWith('<strong>')) {
nextStationName = followingStops[i].stopNameRAW; nextStationName = followingStops[i].stopNameRAW;
break; 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 { return {
trainNo: train.trainNo, trainNo: train.trainNo,
driverName: train.driverName, driverName: train.driverName,
@@ -146,6 +172,9 @@ export function getScheduledTrain(train: Train, trainStopIndex: number, stationN
stopInfo: trainStop, stopInfo: trainStop,
stopLabel: trainStopStatus.stopLabel, stopLabel: trainStopStatus.stopLabel,
stopStatus: trainStopStatus.stopStatus, stopStatus: trainStopStatus.stopStatus,
stopStatusID: trainStopStatus.stopStatusID stopStatusID: trainStopStatus.stopStatusID,
}
arrivingLine,
departureLine,
};
} }
+1
View File
@@ -377,6 +377,7 @@ export const useStore = defineStore('store', {
return; return;
} }
this.dataStatuses.sceneries = DataStatus.Loaded; this.dataStatuses.sceneries = DataStatus.Loaded;
this.dataStatuses.trains = !this.apiData.trains ? DataStatus.Warning : DataStatus.Loaded; this.dataStatuses.trains = !this.apiData.trains ? DataStatus.Warning : DataStatus.Loaded;
this.dataStatuses.dispatchers = !this.apiData.dispatchers ? DataStatus.Warning : DataStatus.Loaded; this.dataStatuses.dispatchers = !this.apiData.dispatchers ? DataStatus.Warning : DataStatus.Loaded;