mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
Zmiany w działaniu i wyglądzie klasycznej tablicy
This commit is contained in:
@@ -17,9 +17,7 @@
|
|||||||
v-if="
|
v-if="
|
||||||
i > 0 && followingStops[i - 1].departureLine != stop.arrivalLine
|
i > 0 && followingStops[i - 1].departureLine != stop.arrivalLine
|
||||||
"
|
"
|
||||||
>
|
>{{ stop.arrivalLine }}</div>
|
||||||
{{ stop.arrivalLine }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span class="stop-info">
|
<span class="stop-info">
|
||||||
<div class="info-indicator"></div>
|
<div class="info-indicator"></div>
|
||||||
@@ -33,18 +31,18 @@
|
|||||||
delayed: stop.arrivalDelay > 0,
|
delayed: stop.arrivalDelay > 0,
|
||||||
preponed: stop.arrivalDelay < 0,
|
preponed: stop.arrivalDelay < 0,
|
||||||
}"
|
}"
|
||||||
>p.
|
|
||||||
{{
|
|
||||||
stylizeTime(stop.arrivalRealTimeString, stop.arrivalDelay)
|
|
||||||
}}</span
|
|
||||||
>
|
>
|
||||||
|
p.
|
||||||
|
{{
|
||||||
|
stylizeTime(stop.arrivalRealTimeString, stop.arrivalDelay)
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
class="date-stop"
|
class="date-stop"
|
||||||
v-if="stop.stopTime"
|
v-if="stop.stopTime"
|
||||||
:class="stop.stopType.replace(', ', '-')"
|
:class="stop.stopType.replace(', ', '-')"
|
||||||
>{{ stop.stopTime }} {{ stop.stopType }}</span
|
>{{ stop.stopTime }} {{ stop.stopType }}</span>
|
||||||
>
|
|
||||||
|
|
||||||
<span
|
<span
|
||||||
class="date-departure"
|
class="date-departure"
|
||||||
@@ -53,11 +51,12 @@
|
|||||||
delayed: stop.departureDelay > 0,
|
delayed: stop.departureDelay > 0,
|
||||||
preponed: stop.departureDelay < 0,
|
preponed: stop.departureDelay < 0,
|
||||||
}"
|
}"
|
||||||
>o.
|
|
||||||
{{
|
|
||||||
stylizeTime(stop.departureRealTimeString, stop.departureDelay)
|
|
||||||
}}</span
|
|
||||||
>
|
>
|
||||||
|
o.
|
||||||
|
{{
|
||||||
|
stylizeTime(stop.departureRealTimeString, stop.departureDelay)
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@@ -79,13 +78,15 @@ export default class TrainSchedule extends Vue {
|
|||||||
@Prop() readonly currentStationName!: string;
|
@Prop() readonly currentStationName!: string;
|
||||||
|
|
||||||
stylizeTime(timeString: string, delay: number) {
|
stylizeTime(timeString: string, delay: number) {
|
||||||
return timeString + (delay != 0 ? " (" + (delay > 0 ? "+" : "") + delay.toString() + ")" : "");
|
return (
|
||||||
|
timeString +
|
||||||
|
(delay != 0 ? " (" + (delay > 0 ? "+" : "") + delay.toString() + ")" : "")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
click() {
|
click() {
|
||||||
this.$emit('click')
|
this.$emit("click");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+308
-165
@@ -4,6 +4,7 @@
|
|||||||
<div class="timetable-title">
|
<div class="timetable-title">
|
||||||
<b>ODJAZDY</b>
|
<b>ODJAZDY</b>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="timetable-header">
|
<div class="timetable-header">
|
||||||
<span>DO STACJI</span>
|
<span>DO STACJI</span>
|
||||||
<span>PRZEZ</span>
|
<span>PRZEZ</span>
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
<span>PLAN. ODJAZD</span>
|
<span>PLAN. ODJAZD</span>
|
||||||
<span>OPÓŹNIENIE</span>
|
<span>OPÓŹNIENIE</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="timetable-body">
|
<div class="timetable-body">
|
||||||
<div class="timetable-item" v-for="(timetable, i) in computedRows" :key="i">
|
<div class="timetable-item" v-for="(timetable, i) in computedRows" :key="i">
|
||||||
<div class="row-bar"></div>
|
<div class="row-bar"></div>
|
||||||
@@ -24,6 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="row-next" ref="next">
|
<span class="row-next" ref="next">
|
||||||
<div v-for="(letter, j) in timetable.nearestStopTable" :key="j" class="letter">
|
<div v-for="(letter, j) in timetable.nearestStopTable" :key="j" class="letter">
|
||||||
<transition name="roll-anim" mode="out-in">
|
<transition name="roll-anim" mode="out-in">
|
||||||
@@ -31,20 +34,28 @@
|
|||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="row-type">
|
<span class="row-type">
|
||||||
<transition name="roll-anim" mode="out-in">
|
<div class="letter-wrapper">
|
||||||
<span :key="timetable.number">
|
<span class="letter" v-for="(letter, j) in timetable.trainCategoryTable" :key="j">
|
||||||
{{
|
<transition name="roll-anim" mode="out-in">
|
||||||
timetable.number
|
<span :key="letter">{{ letter }}</span>
|
||||||
? `${timetable.category} ${timetable.number}`
|
</transition>
|
||||||
: ""
|
|
||||||
}}
|
|
||||||
</span>
|
</span>
|
||||||
</transition>
|
</div>
|
||||||
|
|
||||||
|
<div class="letter-wrapper">
|
||||||
|
<span class="letter" v-for="(num, j) in timetable.trainNumberTable" :key="j+3">
|
||||||
|
<transition name="roll-anim" mode="out-in">
|
||||||
|
<span :key="num">{{ num }}</span>
|
||||||
|
</transition>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="row-time">
|
<span class="row-time">
|
||||||
<div class="letter-wrapper">
|
<div class="letter-wrapper">
|
||||||
<span class="letter" v-for="(num, i) in timetable.departureHoursTable" :key="i">
|
<span class="letter" v-for="(num, h) in timetable.departureHoursTable" :key="h">
|
||||||
<transition name="roll-anim" mode="out-in">
|
<transition name="roll-anim" mode="out-in">
|
||||||
<span :key="num">{{ num }}</span>
|
<span :key="num">{{ num }}</span>
|
||||||
</transition>
|
</transition>
|
||||||
@@ -63,6 +74,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="row-delay">
|
<span class="row-delay">
|
||||||
<transition name="roll-anim" mode="out-in">
|
<transition name="roll-anim" mode="out-in">
|
||||||
<span
|
<span
|
||||||
@@ -83,18 +95,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue } from 'vue-property-decorator';
|
import { Component, Vue } from "vue-property-decorator";
|
||||||
import { Getter } from "vuex-class";
|
import { Getter } from "vuex-class";
|
||||||
import { Howl } from "howler";
|
import { Howl } from "howler";
|
||||||
|
|
||||||
import Station from "@/scripts/interfaces/Station";
|
import Station from "@/scripts/interfaces/Station";
|
||||||
import Timetable from "@/scripts/interfaces/Timetable";
|
import Timetable from "@/scripts/interfaces/Timetable";
|
||||||
|
|
||||||
|
|
||||||
const sound = new Howl({
|
const sound = new Howl({
|
||||||
src: require("@/assets/sound.wav"),
|
src: require("@/assets/sound.wav"),
|
||||||
loop: true,
|
loop: true,
|
||||||
autoplay: false
|
autoplay: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filteredNames = [
|
const filteredNames = [
|
||||||
@@ -107,44 +118,64 @@ const filteredNames = [
|
|||||||
["BUCZ WILEŃSKI", "BUCZ WIL."],
|
["BUCZ WILEŃSKI", "BUCZ WIL."],
|
||||||
["SZKLANA PORĘBA", "SZKLANA POR."],
|
["SZKLANA PORĘBA", "SZKLANA POR."],
|
||||||
["TARNOWO GÓRNE", "TARNOWO G."],
|
["TARNOWO GÓRNE", "TARNOWO G."],
|
||||||
]
|
["BARGOWICE ZACHÓD", "BARGOWICE Z."],
|
||||||
|
];
|
||||||
|
|
||||||
let soundPlaying = false;
|
let soundPlaying = false;
|
||||||
|
|
||||||
const letterSet: string[] = Array.from(" -.,/AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWXYZŹŻ");
|
const letterSet: string[] = Array.from(
|
||||||
|
" -.,/AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWXYZŹŻ"
|
||||||
|
);
|
||||||
|
|
||||||
const numberSet: string[] = Array.from(" 0123456789");
|
const numberSet: string[] = Array.from(" 0123456789");
|
||||||
|
|
||||||
|
const delaySet: string[] = [
|
||||||
|
"5 min",
|
||||||
|
"10 min",
|
||||||
|
"15 min",
|
||||||
|
"20 min",
|
||||||
|
"25 min",
|
||||||
|
"30 min",
|
||||||
|
"35 min",
|
||||||
|
"40 min",
|
||||||
|
"45 min",
|
||||||
|
"50 min",
|
||||||
|
"55 min",
|
||||||
|
"60 min",
|
||||||
|
">60 min",
|
||||||
|
];
|
||||||
|
|
||||||
|
let globalID = 0;
|
||||||
let letterSeekArray: {
|
let letterSeekArray: {
|
||||||
currentRowIndex: number;
|
currentRowIndex: number;
|
||||||
letterIndex: number;
|
letterIndex: number;
|
||||||
currentChar: string;
|
currentChar: string;
|
||||||
finalChar: string;
|
finalChar: string;
|
||||||
main: boolean;
|
arrayName: string;
|
||||||
numeric: boolean;
|
numeric: boolean;
|
||||||
id: number;
|
id: number;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
let globalID = 0;
|
let plateSeekArray: {
|
||||||
|
|
||||||
|
|
||||||
let numberSeekArray: {
|
|
||||||
currentRowIndex: number;
|
currentRowIndex: number;
|
||||||
letterIndex: number;
|
currentPlate: string;
|
||||||
currentChar: string;
|
wantedPlate: string;
|
||||||
finalChar: string;
|
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
|
|
||||||
let nextRefreshTime = 0;
|
let nextRefreshTime = 0;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class TimetableView extends Vue {
|
export default class TimetableView extends Vue {
|
||||||
@Getter('getStationList') stationList!: Station[];
|
@Getter("getStationList") stationList!: Station[];
|
||||||
|
|
||||||
get stationInfo(): Station | null {
|
get stationInfo(): Station | null {
|
||||||
if (!this.$route.query.station) return null;
|
if (!this.$route.query.station) return null;
|
||||||
|
|
||||||
const info = this.stationList.find(station => station.stationName === this.$route.query.station.toString().replaceAll("_", " "));
|
const info = this.stationList.find(
|
||||||
|
(station) =>
|
||||||
|
station.stationName ===
|
||||||
|
this.$route.query.station.toString().replaceAll("_", " ")
|
||||||
|
);
|
||||||
|
|
||||||
return info || null;
|
return info || null;
|
||||||
}
|
}
|
||||||
@@ -162,27 +193,42 @@ export default class TimetableView extends Vue {
|
|||||||
departureMinutesTable: string[];
|
departureMinutesTable: string[];
|
||||||
departureMinutesString: string;
|
departureMinutesString: string;
|
||||||
|
|
||||||
|
trainNumberTable: string[];
|
||||||
|
trainNumberString: string;
|
||||||
|
|
||||||
|
trainCategoryTable: string[];
|
||||||
|
trainCategoryString: string;
|
||||||
|
|
||||||
category: string;
|
category: string;
|
||||||
number: number;
|
number: number;
|
||||||
|
|
||||||
delay: number;
|
delay: number;
|
||||||
|
delayPlate: string;
|
||||||
|
|
||||||
departureTimestamp: number;
|
departureTimestamp: number;
|
||||||
arrivalTimestamp: number;
|
arrivalTimestamp: number;
|
||||||
|
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
deactivated() {
|
deactivated() {
|
||||||
for (let i = 0; i < this.timetableRows.length; i++) {
|
for (let i = 0; i < this.timetableRows.length; i++) {
|
||||||
const currentRow = this.timetableRows[i];
|
const currentRow = this.timetableRows[i];
|
||||||
|
|
||||||
currentRow.destinationTable = currentRow.destinationTable.map(v => " ");
|
currentRow.destinationTable = currentRow.destinationTable.map((v) => " ");
|
||||||
currentRow.nearestStopTable = currentRow.nearestStopTable.map(v => " ");
|
currentRow.nearestStopTable = currentRow.nearestStopTable.map((v) => " ");
|
||||||
currentRow.departureHoursTable = currentRow.departureHoursTable.map(v => "0");
|
currentRow.departureHoursTable = currentRow.departureHoursTable.map(
|
||||||
currentRow.departureMinutesTable = currentRow.departureMinutesTable.map(v => "0");
|
(v) => "0"
|
||||||
|
);
|
||||||
|
currentRow.departureMinutesTable = currentRow.departureMinutesTable.map(
|
||||||
|
(v) => "0"
|
||||||
|
);
|
||||||
|
|
||||||
|
currentRow.trainNumberTable = currentRow.trainNumberTable.map((v) => "");
|
||||||
|
|
||||||
currentRow.destinationString = "";
|
currentRow.destinationString = "";
|
||||||
currentRow.nearestStopString = "";
|
currentRow.nearestStopString = "";
|
||||||
currentRow.departureHoursString = "";
|
currentRow.departureHoursString = "";
|
||||||
currentRow.departureMinutesString = "";
|
currentRow.departureMinutesString = "";
|
||||||
|
currentRow.trainNumberString = "";
|
||||||
|
|
||||||
currentRow.category = "";
|
currentRow.category = "";
|
||||||
currentRow.number = 0;
|
currentRow.number = 0;
|
||||||
@@ -192,11 +238,10 @@ export default class TimetableView extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
letterSeekArray.length = 0;
|
letterSeekArray.length = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.timetableRows = new Array(8).fill(0).map(row => ({
|
this.timetableRows = new Array(7).fill(0).map((row) => ({
|
||||||
origin: new Array(13).fill(" "),
|
origin: new Array(13).fill(" "),
|
||||||
|
|
||||||
destinationTable: new Array(13).fill(" "),
|
destinationTable: new Array(13).fill(" "),
|
||||||
@@ -210,9 +255,19 @@ export default class TimetableView extends Vue {
|
|||||||
|
|
||||||
departureMinutesTable: new Array(2).fill("0"),
|
departureMinutesTable: new Array(2).fill("0"),
|
||||||
departureMinutesString: "",
|
departureMinutesString: "",
|
||||||
|
|
||||||
|
trainNumberTable: new Array(6).fill(" "),
|
||||||
|
trainNumberString: "",
|
||||||
|
|
||||||
|
trainCategoryTable: new Array(3).fill(" "),
|
||||||
|
trainCategoryString: "",
|
||||||
|
|
||||||
category: "",
|
category: "",
|
||||||
number: 0,
|
number: 0,
|
||||||
|
|
||||||
delay: 0,
|
delay: 0,
|
||||||
|
delayPlate: "",
|
||||||
|
|
||||||
departureTimestamp: 0,
|
departureTimestamp: 0,
|
||||||
arrivalTimestamp: 0,
|
arrivalTimestamp: 0,
|
||||||
}));
|
}));
|
||||||
@@ -220,14 +275,37 @@ export default class TimetableView extends Vue {
|
|||||||
window.requestAnimationFrame(this.findNextLetters);
|
window.requestAnimationFrame(this.findNextLetters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addToSeek(
|
||||||
|
currentRowIndex: number,
|
||||||
|
letterIndex: number,
|
||||||
|
currentChar: string,
|
||||||
|
finalChar: string,
|
||||||
|
arrayName: string,
|
||||||
|
numeric: boolean
|
||||||
|
) {
|
||||||
|
globalID++;
|
||||||
|
|
||||||
|
letterSeekArray.push({
|
||||||
|
currentRowIndex,
|
||||||
|
letterIndex,
|
||||||
|
currentChar,
|
||||||
|
finalChar,
|
||||||
|
arrayName,
|
||||||
|
numeric,
|
||||||
|
id: globalID,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
get computedRows(): any[] {
|
get computedRows(): any[] {
|
||||||
if (!this.stationInfo) return this.timetableRows;
|
if (!this.stationInfo) return this.timetableRows;
|
||||||
|
|
||||||
const scheduledTrains = this.stationInfo.scheduledTrains.filter(train => train.stopInfo.departureTimestamp !== 0).sort((a, b) => {
|
const scheduledTrains = this.stationInfo.scheduledTrains
|
||||||
if (a.stopInfo.departureTimestamp >= b.stopInfo.departureTimestamp) return 1;
|
.filter((train) => train.stopInfo.departureTimestamp !== 0)
|
||||||
else return -1;
|
.sort((a, b) => {
|
||||||
});
|
if (a.stopInfo.departureTimestamp >= b.stopInfo.departureTimestamp)
|
||||||
|
return 1;
|
||||||
|
else return -1;
|
||||||
|
});
|
||||||
|
|
||||||
let currentRowIndex = 0;
|
let currentRowIndex = 0;
|
||||||
for (let train of scheduledTrains) {
|
for (let train of scheduledTrains) {
|
||||||
@@ -236,106 +314,128 @@ export default class TimetableView extends Vue {
|
|||||||
|
|
||||||
const currentRow = this.timetableRows[currentRowIndex];
|
const currentRow = this.timetableRows[currentRowIndex];
|
||||||
|
|
||||||
const departureHours = new Array(2).fill("0").map((num, i) => train.stopInfo.departureTimeString[i]);
|
const departureHours = new Array(2)
|
||||||
const departureMinutes = new Array(2).fill("0").map((num, i) => train.stopInfo.departureTimeString[i + 3]);
|
.fill("0")
|
||||||
|
.map((num, i) => train.stopInfo.departureTimeString[i]);
|
||||||
|
|
||||||
|
const departureMinutes = new Array(2)
|
||||||
|
.fill("0")
|
||||||
|
.map((num, i) => train.stopInfo.departureTimeString[i + 3]);
|
||||||
|
|
||||||
|
const trainNumberString = train.trainNo.toString();
|
||||||
|
|
||||||
let destination = train.terminatesAt.toUpperCase();
|
let destination = train.terminatesAt.toUpperCase();
|
||||||
let nearestStop = train.nearestStop.toUpperCase();
|
let nearestStop = train.nearestStop.toUpperCase();
|
||||||
|
|
||||||
|
|
||||||
for (let name of filteredNames) {
|
for (let name of filteredNames) {
|
||||||
if (name[0] === destination)
|
if (name[0] === destination) destination = name[1];
|
||||||
destination = name[1];
|
|
||||||
|
|
||||||
if (name[0] === nearestStop)
|
if (name[0] === nearestStop) nearestStop = name[1];
|
||||||
nearestStop = name[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRow.destinationString !== destination) {
|
if (currentRow.destinationString !== destination) {
|
||||||
currentRow.destinationTable.forEach((letter, i) => {
|
currentRow.destinationTable.forEach((letter, i) => {
|
||||||
letterSeekArray.push({
|
this.addToSeek(
|
||||||
currentRowIndex,
|
currentRowIndex,
|
||||||
letterIndex: i,
|
i,
|
||||||
currentChar: (currentRow.destinationString.length == 0 && letter != " ") ? letterSet[Math.floor(Math.random() * letterSet.length)] : letter,
|
letter,
|
||||||
finalChar: destination[i] ? destination[i].toUpperCase() : " ",
|
destination[i] ? destination[i].toUpperCase() : " ",
|
||||||
main: true,
|
"destinationTable",
|
||||||
numeric: false,
|
false
|
||||||
id: globalID
|
);
|
||||||
})
|
});
|
||||||
|
|
||||||
globalID++;
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRow.nearestStopString !== nearestStop) {
|
if (currentRow.nearestStopString !== nearestStop) {
|
||||||
|
|
||||||
currentRow.nearestStopTable.forEach((letter, i) => {
|
currentRow.nearestStopTable.forEach((letter, i) => {
|
||||||
letterSeekArray.push({
|
this.addToSeek(
|
||||||
currentRowIndex,
|
currentRowIndex,
|
||||||
letterIndex: i,
|
i,
|
||||||
currentChar: (currentRow.nearestStopString.length == 0 && letter != " ") ? letterSet[Math.random() * letterSet.length] : letter,
|
letter,
|
||||||
finalChar: nearestStop[i] ? nearestStop[i].toUpperCase() : " ",
|
nearestStop[i] ? nearestStop[i].toUpperCase() : " ",
|
||||||
main: false,
|
"nearestStopTable",
|
||||||
numeric: false,
|
false
|
||||||
id: globalID
|
);
|
||||||
})
|
});
|
||||||
|
|
||||||
globalID++;
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRow.departureHoursTable.toString() != departureHours.toString()) {
|
if (currentRow.departureHoursString != departureHours.toString()) {
|
||||||
currentRow.departureHoursTable.forEach((num, i) => {
|
currentRow.departureHoursTable.forEach((num, i) => {
|
||||||
letterSeekArray.push({
|
this.addToSeek(
|
||||||
currentRowIndex,
|
currentRowIndex,
|
||||||
letterIndex: i,
|
i,
|
||||||
currentChar: num,
|
num,
|
||||||
finalChar: departureHours[i] ? departureHours[i] : "0",
|
departureHours[i] ? departureHours[i] : "0",
|
||||||
main: true,
|
"departureHoursTable",
|
||||||
numeric: true,
|
true
|
||||||
id: globalID
|
);
|
||||||
})
|
});
|
||||||
|
|
||||||
globalID++;
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRow.departureMinutesString != departureMinutes.toString()) {
|
if (currentRow.departureMinutesString != departureMinutes.toString()) {
|
||||||
currentRow.departureMinutesTable.forEach((num, i) => {
|
currentRow.departureMinutesTable.forEach((num, i) => {
|
||||||
letterSeekArray.push({
|
this.addToSeek(
|
||||||
currentRowIndex,
|
currentRowIndex,
|
||||||
letterIndex: i,
|
i,
|
||||||
currentChar: num,
|
num,
|
||||||
finalChar: departureMinutes[i] ? departureMinutes[i] : "0",
|
departureMinutes[i] ? departureMinutes[i] : "0",
|
||||||
main: false,
|
"departureMinutesTable",
|
||||||
numeric: true,
|
true
|
||||||
id: globalID
|
);
|
||||||
})
|
});
|
||||||
|
|
||||||
globalID++;
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentRow.trainNumberString != train.trainNo.toString()) {
|
||||||
|
currentRow.trainNumberTable.forEach((num, i) => {
|
||||||
|
this.addToSeek(
|
||||||
|
currentRowIndex,
|
||||||
|
i,
|
||||||
|
num,
|
||||||
|
trainNumberString[i] ? trainNumberString[i] : " ",
|
||||||
|
"trainNumberTable",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentRow.trainCategoryString != train.category) {
|
||||||
|
currentRow.trainCategoryTable.forEach((letter, i) => {
|
||||||
|
this.addToSeek(
|
||||||
|
currentRowIndex,
|
||||||
|
i,
|
||||||
|
letter,
|
||||||
|
train.category[i] ? train.category[i] : " ",
|
||||||
|
"trainCategoryTable",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentRow.delayPlate != currentRow.delay.toString()) {
|
||||||
|
plateSeekArray.push({
|
||||||
|
currentRowIndex,
|
||||||
|
currentPlate: currentRow.delayPlate,
|
||||||
|
wantedPlate: currentRow.delay > 0 ? currentRow.delay.toString() : "",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
currentRow.destinationString = destination;
|
currentRow.destinationString = destination;
|
||||||
currentRow.nearestStopString = nearestStop;
|
currentRow.nearestStopString = nearestStop;
|
||||||
|
|
||||||
// currentRow.nearestStop = currentRow.nearestStop.map((letter, i) => train.nearestStop[i] ? train.nearestStop[i].toUpperCase() : " ");
|
|
||||||
currentRow.category = train.category;
|
currentRow.category = train.category;
|
||||||
currentRow.number = train.trainNo;
|
currentRow.number = train.trainNo;
|
||||||
|
|
||||||
currentRow.departureMinutesString = departureMinutes.toString();
|
currentRow.departureMinutesString = departureMinutes.toString();
|
||||||
currentRow.departureMinutesString = departureMinutes.toString();
|
currentRow.departureMinutesString = departureMinutes.toString();
|
||||||
|
|
||||||
// currentRow.departureHours = departureHours;
|
currentRow.trainNumberString = trainNumberString;
|
||||||
// currentRow.departureMinutes = departureMinutes;
|
currentRow.trainCategoryString = train.category;
|
||||||
|
|
||||||
currentRow.arrivalTimestamp = train.stopInfo.arrivalTimestamp;
|
currentRow.arrivalTimestamp = train.stopInfo.arrivalTimestamp;
|
||||||
currentRow.departureTimestamp = train.stopInfo.departureTimestamp;
|
currentRow.departureTimestamp = train.stopInfo.departureTimestamp;
|
||||||
currentRow.delay = train.stopInfo.arrivalDelay >= 0 ? train.stopInfo.arrivalDelay : 0;
|
|
||||||
|
currentRow.delay =
|
||||||
|
train.stopInfo.arrivalDelay >= 0 ? train.stopInfo.arrivalDelay : 0;
|
||||||
|
|
||||||
currentRowIndex++;
|
currentRowIndex++;
|
||||||
}
|
}
|
||||||
@@ -343,87 +443,121 @@ export default class TimetableView extends Vue {
|
|||||||
for (let i = currentRowIndex; i < this.timetableRows.length; i++) {
|
for (let i = currentRowIndex; i < this.timetableRows.length; i++) {
|
||||||
const currentRow = this.timetableRows[i];
|
const currentRow = this.timetableRows[i];
|
||||||
|
|
||||||
currentRow.destinationTable = currentRow.destinationTable.map(v => " ");
|
for (let propName in currentRow) {
|
||||||
currentRow.nearestStopTable = currentRow.nearestStopTable.map(v => " ");
|
let currentProp = currentRow[propName];
|
||||||
currentRow.departureHoursTable = currentRow.departureHoursTable.map(v => "0");
|
|
||||||
currentRow.departureMinutesTable = currentRow.departureMinutesTable.map(v => "0");
|
|
||||||
|
|
||||||
currentRow.destinationString = "";
|
switch (typeof currentProp) {
|
||||||
currentRow.nearestStopString = "";
|
case "object":
|
||||||
currentRow.departureHoursString = "";
|
currentProp = currentProp.map((v) => " ");
|
||||||
currentRow.departureMinutesString = "";
|
break;
|
||||||
|
|
||||||
currentRow.category = "";
|
case "string":
|
||||||
currentRow.number = 0;
|
currentProp = "";
|
||||||
currentRow.arrivalTimestamp = 0;
|
break;
|
||||||
currentRow.departureTimestamp = 0;
|
|
||||||
currentRow.delay = 0;
|
case "number":
|
||||||
|
currentProp = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.timetableRows;
|
return this.timetableRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
seekMainLetters(time) {
|
seekMainLetters() {
|
||||||
if (time > nextRefreshTime) {
|
for (let i = 0; i < letterSeekArray.length; i++) {
|
||||||
for (let i = 0; i < letterSeekArray.length; i++) {
|
const wanted = letterSeekArray[i];
|
||||||
const wanted = letterSeekArray[i];
|
const currentSet = wanted.numeric ? numberSet : letterSet;
|
||||||
const currentSet = wanted.numeric ? numberSet : letterSet;
|
|
||||||
|
|
||||||
if (wanted.currentChar === wanted.finalChar) {
|
if (wanted.currentChar === wanted.finalChar) {
|
||||||
letterSeekArray = letterSeekArray.filter(letter => letter.id !== wanted.id);
|
letterSeekArray = letterSeekArray.filter(
|
||||||
continue;
|
(letter) => letter.id !== wanted.id
|
||||||
}
|
);
|
||||||
|
|
||||||
const currentIndex = currentSet.findIndex(char => char === wanted.currentChar);
|
continue;
|
||||||
const nextIndex = currentIndex == currentSet.length - 1 ? 0 : currentIndex + 1;
|
|
||||||
const nextChar = currentSet[nextIndex];
|
|
||||||
|
|
||||||
if (!wanted.numeric) {
|
|
||||||
this.$set(
|
|
||||||
wanted.main ? this.timetableRows[wanted.currentRowIndex].destinationTable : this.timetableRows[wanted.currentRowIndex].nearestStopTable,
|
|
||||||
wanted.letterIndex,
|
|
||||||
currentSet[nextIndex]);
|
|
||||||
} else {
|
|
||||||
this.$set(wanted.main ? this.timetableRows[wanted.currentRowIndex].departureHoursTable : this.timetableRows[wanted.currentRowIndex].departureMinutesTable,
|
|
||||||
wanted.letterIndex,
|
|
||||||
nextChar);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
// this.timetableRows[wanted.currentRowIndex].departureMinutes[wanted.letterIndex] = currentSet[nextIndex];
|
|
||||||
|
|
||||||
if (nextChar === wanted.finalChar) {
|
|
||||||
letterSeekArray = letterSeekArray.filter(letter => letter.id !== wanted.id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
letterSeekArray[i].currentChar = nextChar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentIndex = currentSet.findIndex(
|
||||||
|
(char) => char === wanted.currentChar
|
||||||
|
);
|
||||||
|
const nextIndex =
|
||||||
|
currentIndex == currentSet.length - 1 ? 0 : currentIndex + 1;
|
||||||
|
const nextChar = currentSet[nextIndex];
|
||||||
|
|
||||||
|
this.$set(
|
||||||
|
this.timetableRows[wanted.currentRowIndex][wanted.arrayName],
|
||||||
|
wanted.letterIndex,
|
||||||
|
currentSet[nextIndex]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (nextChar === wanted.finalChar) {
|
||||||
|
letterSeekArray = letterSeekArray.filter(
|
||||||
|
(letter) => letter.id !== wanted.id
|
||||||
|
);
|
||||||
|
|
||||||
|
// console.log("Found!", letterSeekArray.length);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
letterSeekArray[i].currentChar = nextChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
seekDelayPlate() {
|
||||||
|
for (let i = 0; i < plateSeekArray.length; i++) {
|
||||||
|
const plate = plateSeekArray[i];
|
||||||
|
|
||||||
|
if (plate.currentPlate === plate.wantedPlate) {
|
||||||
|
plateSeekArray = plateSeekArray.filter(
|
||||||
|
(p) => plate.currentRowIndex === p.currentRowIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentIndex = delaySet.findIndex((p) => p === plate.currentPlate);
|
||||||
|
|
||||||
|
const nextIndex =
|
||||||
|
currentIndex == delaySet.length - 1 ? 0 : currentIndex + 1;
|
||||||
|
|
||||||
|
const nextPlate = delaySet[nextIndex];
|
||||||
|
|
||||||
|
this.timetableRows[plate.currentRowIndex].delayPlate =
|
||||||
|
delaySet[nextIndex];
|
||||||
|
|
||||||
|
if (nextPlate === plate.wantedPlate) {
|
||||||
|
plateSeekArray = plateSeekArray.filter(
|
||||||
|
(p) => plate.currentRowIndex === p.currentRowIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
findNextLetters(time) {
|
findNextLetters(time) {
|
||||||
if (time > nextRefreshTime) {
|
if (time > nextRefreshTime) {
|
||||||
this.seekMainLetters(time);
|
this.seekMainLetters();
|
||||||
|
this.seekDelayPlate();
|
||||||
// this.seekSideLetters(time);
|
// this.seekSideLetters(time);
|
||||||
|
|
||||||
nextRefreshTime = time + 100;
|
nextRefreshTime = time + 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (letterSeekArray.length > 0 && !soundPlaying) {
|
||||||
if (letterSeekArray.length > 0 && !soundPlaying) { sound.play(); soundPlaying = true; }
|
sound.play();
|
||||||
else if (letterSeekArray.length == 0) {
|
soundPlaying = true;
|
||||||
|
} else if (letterSeekArray.length == 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
sound.stop(); soundPlaying = false;
|
sound.stop();
|
||||||
|
soundPlaying = false;
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestAnimationFrame(this.findNextLetters);
|
requestAnimationFrame(this.findNextLetters);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -459,7 +593,7 @@ $bg: #111;
|
|||||||
&-header,
|
&-header,
|
||||||
&-row {
|
&-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 4fr 4fr 2fr 1fr 1fr;
|
grid-template-columns: 4fr 4fr 3fr 1fr 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-header {
|
&-header {
|
||||||
@@ -468,6 +602,7 @@ $bg: #111;
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 0.35em;
|
font-size: 0.35em;
|
||||||
|
|
||||||
@@ -506,26 +641,28 @@ $bg: #111;
|
|||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row-bar {
|
|
||||||
width: 100%;
|
|
||||||
height: 3px;
|
|
||||||
background: white;
|
|
||||||
|
|
||||||
margin-top: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
|
&-bar {
|
||||||
|
width: 100%;
|
||||||
|
height: 3px;
|
||||||
|
background: white;
|
||||||
|
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
&-type {
|
&-type {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
span {
|
div {
|
||||||
display: inline-block;
|
margin: 0 0.5em;
|
||||||
width: 60%;
|
|
||||||
min-height: 40px;
|
|
||||||
line-height: 40px;
|
|
||||||
|
|
||||||
background: firebrick;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// span {
|
||||||
|
// display: inline-block;
|
||||||
|
// width: 60%;
|
||||||
|
// min-height: 40px;
|
||||||
|
// line-height: 40px;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
&-delay {
|
&-delay {
|
||||||
@@ -542,6 +679,12 @@ $bg: #111;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.type {
|
||||||
|
&-category {
|
||||||
|
background: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.roll-anim-enter-active,
|
.roll-anim-enter-active,
|
||||||
.roll-anim-leave-active {
|
.roll-anim-leave-active {
|
||||||
transition: all 75ms;
|
transition: all 75ms;
|
||||||
|
|||||||
Reference in New Issue
Block a user