mirror of
https://codeberg.org/kbruen/kai.infotren.git
synced 2025-02-22 17:19:37 +02:00
Add train notes
This commit is contained in:
parent
ccc3d8e127
commit
c60c20a736
4 changed files with 55 additions and 13 deletions
24
items.js
24
items.js
|
@ -15,17 +15,19 @@ function nav(offset) {
|
|||
}
|
||||
|
||||
function handleKeyDown(e) {
|
||||
switch (e.key) {
|
||||
case 'ArrowUp':
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
nav(-1)
|
||||
break
|
||||
case 'ArrowDown':
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
nav(1)
|
||||
break
|
||||
if (e.target.classList.contains('items')) {
|
||||
switch (e.key) {
|
||||
case 'ArrowUp':
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
nav(-1)
|
||||
break
|
||||
case 'ArrowDown':
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
nav(1)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
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_TRAINS = `${API_ORIGIN}v3/trains`
|
||||
const API_STATIONS = `${API_ORIGIN}v2/stations`
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
grid-template-areas:
|
||||
"arr name dep"
|
||||
"arr km dep"
|
||||
"arr platform dep";
|
||||
"arr platform dep"
|
||||
"arr notes dep";
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
|
@ -87,6 +88,14 @@
|
|||
grid-area: platform;
|
||||
}
|
||||
|
||||
.stationItem .notes {
|
||||
grid-area: notes;
|
||||
}
|
||||
|
||||
.stationItem .note {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.last-refreshed {
|
||||
font-size: 12px;
|
||||
text-transform: none;
|
||||
|
|
|
@ -257,6 +257,37 @@ function onTrainData(data) {
|
|||
stationPlatform.textContent = `platform ${station.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()
|
||||
|
|
Loading…
Add table
Reference in a new issue