|
|
@ -2,6 +2,7 @@ var trainNumber |
|
|
|
var date |
|
|
|
var date |
|
|
|
var groupIndex = null |
|
|
|
var groupIndex = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var yesterday = false |
|
|
|
var showKm = false |
|
|
|
var showKm = false |
|
|
|
|
|
|
|
|
|
|
|
var trainData = null |
|
|
|
var trainData = null |
|
|
@ -39,10 +40,12 @@ function onTrainData(data) { |
|
|
|
dateHref.textContent = data.date |
|
|
|
dateHref.textContent = data.date |
|
|
|
dateHref.href = '#' |
|
|
|
dateHref.href = '#' |
|
|
|
dateHref.classList.add('no-a-custom') |
|
|
|
dateHref.classList.add('no-a-custom') |
|
|
|
// dateHref.classList.add('items', 'no-a-custom')
|
|
|
|
dateHref.classList.add('items', 'no-a-custom') |
|
|
|
dateHref.addEventListener('click', function (e) { |
|
|
|
dateHref.addEventListener('click', function (e) { |
|
|
|
e.preventDefault() |
|
|
|
e.preventDefault() |
|
|
|
// Implement date switcher
|
|
|
|
// Implement date switcher
|
|
|
|
|
|
|
|
yesterday = !yesterday |
|
|
|
|
|
|
|
refresh() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
document.getElementById('loading').classList.add('hidden') |
|
|
|
document.getElementById('loading').classList.add('hidden') |
|
|
@ -340,8 +343,15 @@ function refresh() { |
|
|
|
refresh() |
|
|
|
refresh() |
|
|
|
}, timeout || 60000) |
|
|
|
}, timeout || 60000) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @type {Date} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
var reqDate = date |
|
|
|
|
|
|
|
if (yesterday) { |
|
|
|
|
|
|
|
reqDate.setDate(reqDate.getDate() - 1) |
|
|
|
|
|
|
|
} |
|
|
|
return fetch( |
|
|
|
return fetch( |
|
|
|
`https://scraper.infotren.dcdev.ro/v3/trains/${trainNumber}?date=${date.getFullYear().toString()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`, |
|
|
|
`https://scraper.infotren.dcdev.ro/v3/trains/${trainNumber}?date=${reqDate.getFullYear().toString()}-${(reqDate.getMonth() + 1).toString().padStart(2, "0")}-${reqDate.getDate().toString().padStart(2, "0")}`, |
|
|
|
{ |
|
|
|
{ |
|
|
|
cache: 'no-store', |
|
|
|
cache: 'no-store', |
|
|
|
}, |
|
|
|
}, |
|
|
|