|
|
|
@ -7,6 +7,16 @@ var showKm = false
|
|
|
|
|
var trainData = null |
|
|
|
|
var lastSuccessfulFetch = null |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @typedef group |
|
|
|
|
* @property {{from: string; to: string}} route |
|
|
|
|
* @property {{delay: number; station: string; state: "passing" | "arrival" | "departure"} | undefined} status |
|
|
|
|
* @property {any[]} stations |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param {{ rank: string; number: string; operator: string; date: string; groups: group[]; }} data |
|
|
|
|
*/ |
|
|
|
|
function onTrainData(data) { |
|
|
|
|
var title = document.getElementById('title') |
|
|
|
|
title.textContent = '' |
|
|
|
@ -20,10 +30,26 @@ function onTrainData(data) {
|
|
|
|
|
document.getElementsByTagName('title')[0].textContent = `Train ${data.rank} ${data.number}` |
|
|
|
|
|
|
|
|
|
document.getElementById('company').textContent = data.operator |
|
|
|
|
document.getElementById('date').textContent = data.date |
|
|
|
|
var dateHref = document.createElement('a') |
|
|
|
|
var dateP = document.getElementById('date') |
|
|
|
|
while (dateP.childNodes.length > 0) { |
|
|
|
|
dateP.childNodes[0].remove() |
|
|
|
|
} |
|
|
|
|
dateP.appendChild(dateHref) |
|
|
|
|
dateHref.textContent = data.date |
|
|
|
|
dateHref.href = '#' |
|
|
|
|
dateHref.classList.add('no-a-custom') |
|
|
|
|
// dateHref.classList.add('items', 'no-a-custom')
|
|
|
|
|
dateHref.addEventListener('click', function (e) { |
|
|
|
|
e.preventDefault() |
|
|
|
|
// Implement date switcher
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
document.getElementById('loading').classList.add('hidden') |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @type {group | null} |
|
|
|
|
*/ |
|
|
|
|
var group = null; |
|
|
|
|
if (data.groups.length > 1 && groupIndex == null) { |
|
|
|
|
document.getElementById('group-choice').classList.remove('hidden') |
|
|
|
@ -194,8 +220,15 @@ function onTrainData(data) {
|
|
|
|
|
|
|
|
|
|
var stationName = document.createElement('p') |
|
|
|
|
stationItem.appendChild(stationName) |
|
|
|
|
stationName.textContent = station.name |
|
|
|
|
stationName.classList.add('pri', 'name') |
|
|
|
|
var stationNameHref = document.createElement('a') |
|
|
|
|
stationName.appendChild(stationNameHref) |
|
|
|
|
stationNameHref.textContent = station.name |
|
|
|
|
stationNameHref.classList.add('items', 'no-a-custom') |
|
|
|
|
var stationUrl = new URL('/view-station.html', window.location.origin) |
|
|
|
|
stationUrl.searchParams.append('station', station.name) |
|
|
|
|
stationUrl.searchParams.append('date', (station.arrival || station.departure).scheduleTime) |
|
|
|
|
stationNameHref.href = stationUrl.toString() |
|
|
|
|
|
|
|
|
|
if (station.arrival) { |
|
|
|
|
var stationArrival = document.createElement('div') |
|
|
|
@ -379,12 +412,12 @@ window.addEventListener('load', function (e) {
|
|
|
|
|
content.focus() |
|
|
|
|
content.addEventListener('keydown', function (e) { |
|
|
|
|
switch (e.key) { |
|
|
|
|
case 'ArrowUp': |
|
|
|
|
content.scrollBy(0, -50) |
|
|
|
|
break |
|
|
|
|
case 'ArrowDown': |
|
|
|
|
content.scrollBy(0, 50) |
|
|
|
|
break |
|
|
|
|
// case 'ArrowUp':
|
|
|
|
|
// content.scrollBy(0, -50)
|
|
|
|
|
// break
|
|
|
|
|
// case 'ArrowDown':
|
|
|
|
|
// content.scrollBy(0, 50)
|
|
|
|
|
// break
|
|
|
|
|
case 'SoftRight': |
|
|
|
|
rsk() |
|
|
|
|
break |
|
|
|
|