Add train notes
This commit is contained in:
parent
ccc3d8e127
commit
c60c20a736
4 changed files with 55 additions and 13 deletions
2
items.js
2
items.js
|
@ -15,6 +15,7 @@ function nav(offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleKeyDown(e) {
|
function handleKeyDown(e) {
|
||||||
|
if (e.target.classList.contains('items')) {
|
||||||
switch (e.key) {
|
switch (e.key) {
|
||||||
case 'ArrowUp':
|
case 'ArrowUp':
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
@ -28,6 +29,7 @@ function handleKeyDown(e) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener('load', function (e) {
|
window.addEventListener('load', function (e) {
|
||||||
// Select first item
|
// Select first item
|
||||||
|
|
2
sw.js
2
sw.js
|
@ -1,4 +1,4 @@
|
||||||
const VERSION = 'v5'
|
const VERSION = 'v6'
|
||||||
const API_ORIGIN = 'https://scraper.infotren.dcdev.ro/'
|
const API_ORIGIN = 'https://scraper.infotren.dcdev.ro/'
|
||||||
const API_TRAINS = `${API_ORIGIN}v3/trains`
|
const API_TRAINS = `${API_ORIGIN}v3/trains`
|
||||||
const API_STATIONS = `${API_ORIGIN}v2/stations`
|
const API_STATIONS = `${API_ORIGIN}v2/stations`
|
||||||
|
|
|
@ -38,7 +38,8 @@
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"arr name dep"
|
"arr name dep"
|
||||||
"arr km dep"
|
"arr km dep"
|
||||||
"arr platform dep";
|
"arr platform dep"
|
||||||
|
"arr notes dep";
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +88,14 @@
|
||||||
grid-area: platform;
|
grid-area: platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.stationItem .notes {
|
||||||
|
grid-area: notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stationItem .note {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.last-refreshed {
|
.last-refreshed {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
|
|
|
@ -257,6 +257,37 @@ function onTrainData(data) {
|
||||||
stationPlatform.textContent = `platform ${station.platform}`
|
stationPlatform.textContent = `platform ${station.platform}`
|
||||||
stationPlatform.classList.add('thi', 'platform')
|
stationPlatform.classList.add('thi', 'platform')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (station.notes && station.notes.length > 0) {
|
||||||
|
var stationNotes = document.createElement('div')
|
||||||
|
stationItem.appendChild(stationNotes)
|
||||||
|
stationNotes.classList.add('notes')
|
||||||
|
|
||||||
|
station.notes.forEach(function (note) {
|
||||||
|
var noteP = document.createElement('p')
|
||||||
|
stationNotes.appendChild(noteP)
|
||||||
|
noteP.classList.add('note', 'thi')
|
||||||
|
|
||||||
|
switch (note.kind) {
|
||||||
|
case 'departsAs': {
|
||||||
|
noteP.textContent = `Train departs as ${note.rank} ${note.number}`
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'detachingWagons': {
|
||||||
|
noteP.textContent = `Detaching wagons to ${note.station}`
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'receivingWagons': {
|
||||||
|
noteP.textContent = `Receiving wagons from ${note.station}`
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'trainNumberChange': {
|
||||||
|
noteP.textContent = `Train changes number to ${note.rank} ${note.number}`
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
lastSuccessfulFetch = new Date()
|
lastSuccessfulFetch = new Date()
|
||||||
|
|
Loading…
Add table
Reference in a new issue