More work on staff version
This commit is contained in:
parent
31f6113292
commit
039b57efe7
@ -1,6 +1,11 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['eslint:recommended', 'plugin:svelte/recommended', 'prettier'],
|
||||
overrides: [
|
||||
{
|
||||
"files": ["**/*.svelte"]
|
||||
}
|
||||
],
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 2020,
|
||||
@ -10,5 +15,8 @@ module.exports = {
|
||||
browser: true,
|
||||
es2017: true,
|
||||
node: true
|
||||
},
|
||||
rules: {
|
||||
indent: ['error', 2, {SwitchCase: 2}],
|
||||
}
|
||||
};
|
||||
|
@ -72,7 +72,7 @@
|
||||
from: await parseLocation(service.origin),
|
||||
to: await parseLocation(service.destination),
|
||||
length: await getTrainLength(service),
|
||||
platform: await parsePlatform(service?.platform),
|
||||
platform: await parsePlatform(service?.platform || "undefined"),
|
||||
platformHidden: service?.platformIsHidden === "true",
|
||||
schArr: timeDetails.schArr,
|
||||
expArr: timeDetails.expArr,
|
||||
@ -115,12 +115,14 @@
|
||||
}
|
||||
|
||||
async function parsePlatform(platform) {
|
||||
if (platform === "TBC") {
|
||||
if (!platform) {
|
||||
return '-'
|
||||
}
|
||||
if (platform === "TBC" || platform == "undefined") {
|
||||
return '-'
|
||||
}
|
||||
return {
|
||||
number: platform,
|
||||
isHidden: false // Not Implemented
|
||||
number: platform
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,23 +131,50 @@
|
||||
let expArr = new Date(service?.eta || service?.ata);
|
||||
let schDep = new Date(service?.std);
|
||||
let expDep = new Date(service?.etd || service?.atd);
|
||||
let isEarlyArr = false, isDelayedArr = false
|
||||
let isEarlyDep = false, isDelayedDep = false
|
||||
if (expArr < schArr) {
|
||||
let isEarlyArr = false, isDelayedArr = false, isArr = false
|
||||
let isEarlyDep = false, isDelayedDep = false, isDep = false
|
||||
const timeDifferenceThreshold = 60 * 1000; // 60 seconds in milliseconds
|
||||
if (expArr - schArr < -timeDifferenceThreshold) {
|
||||
isEarlyArr = true;
|
||||
} else if (expArr > schArr) {
|
||||
isDelayedArr = true; // Only if the delay is more than 60 seconds.
|
||||
isArr = true;
|
||||
} else if (expArr - schArr > timeDifferenceThreshold) {
|
||||
isDelayedArr = true;
|
||||
isArr = true;
|
||||
}
|
||||
if (expDep < schDep) {
|
||||
isEarlyDep = true; // Only if the delay is more than 60 seconds.
|
||||
} else if (expDep > schDep) {
|
||||
|
||||
if (expDep - schDep < -timeDifferenceThreshold) {
|
||||
isEarlyDep = true;
|
||||
isDep = true;
|
||||
} else if (expDep - schDep > timeDifferenceThreshold) {
|
||||
isDelayedDep = true;
|
||||
isDep = true;
|
||||
}
|
||||
let parsedExpArr;
|
||||
if (expArr instanceof Date && !isNaN(expArr)) {
|
||||
if (!isEarlyArr && !isDelayedArr) {
|
||||
parsedExpArr = 'RT';
|
||||
} else {
|
||||
parsedExpArr = parseIndividualTime(expArr);
|
||||
}
|
||||
} else {
|
||||
parsedExpArr = '-';
|
||||
}
|
||||
|
||||
let parsedExpDep;
|
||||
if (expDep instanceof Date && !isNaN(expDep)) {
|
||||
if (!isEarlyDep && !isDelayedDep) {
|
||||
parsedExpDep = 'RT';
|
||||
} else {
|
||||
parsedExpDep = parseIndividualTime(expDep);
|
||||
}
|
||||
} else {
|
||||
parsedExpDep = '-';
|
||||
}
|
||||
return {
|
||||
schArr: parseIndividualTime(schArr),
|
||||
expArr: parseIndividualTime(expArr),
|
||||
expArr: parsedExpArr,
|
||||
schDep: parseIndividualTime(schDep),
|
||||
expDep: parseIndividualTime(expDep),
|
||||
expDep: parsedExpDep,
|
||||
earArr: isEarlyArr,
|
||||
delArr: isDelayedArr,
|
||||
earDep: isEarlyDep,
|
||||
@ -216,7 +245,7 @@
|
||||
<td class="id id-data data">{service.trainid}</td>
|
||||
<td class="from from-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.from}</td>
|
||||
<td class="to to-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.to}</td>
|
||||
<td class="plat plat-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.platformHidden && 'hidden'}">{serviceStats.platform.number}</td>
|
||||
<td class="plat plat-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.platformHidden && 'hidden'}">{serviceStats.platform.number || '-'}</td>
|
||||
<td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schArr}</td>
|
||||
<td class="time time-data data {serviceStats.isArrDelayed && 'late'} {serviceStats.isEarlyArr && 'early'} {serviceStats.isLateArr && 'late'}">{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}</td>
|
||||
<td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schDep}</td>
|
||||
|
Loading…
Reference in New Issue
Block a user