|
|
|
@ -78,15 +78,21 @@ function rebuildSuggestions() {
|
|
|
|
|
}, 500) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function lsk() { |
|
|
|
|
document.getElementById('trainNumber').focus() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
window.addEventListener('load', function (e) { |
|
|
|
|
var trainNumber = document.getElementById('trainNumber') |
|
|
|
|
trainNumber.addEventListener('input', function (e) { |
|
|
|
|
rebuildSuggestions() |
|
|
|
|
}) |
|
|
|
|
trainNumber.addEventListener('focus', function (e) { |
|
|
|
|
document.getElementsByClassName('lsk')[0].textContent = '' |
|
|
|
|
document.getElementsByClassName('csk')[0].textContent = 'Search' |
|
|
|
|
}) |
|
|
|
|
trainNumber.addEventListener('blur', function (e) { |
|
|
|
|
document.getElementsByClassName('lsk')[0].textContent = 'Search' |
|
|
|
|
document.getElementsByClassName('csk')[0].textContent = 'Select' |
|
|
|
|
}) |
|
|
|
|
trainNumber.addEventListener('keypress', function (e) { |
|
|
|
@ -95,6 +101,17 @@ window.addEventListener('load', function (e) {
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
document.querySelectorAll('.lsk').forEach(function (lskElem) { |
|
|
|
|
lskElem.addEventListener('click', function (e) { |
|
|
|
|
lsk() |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
document.body.addEventListener('keydown', function (e) { |
|
|
|
|
if (e.key == 'SoftLeft') { |
|
|
|
|
lsk() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
fetch('https://scraper.infotren.dcdev.ro/v2/trains') |
|
|
|
|
.then(function (response) { |
|
|
|
|
return response.json() |
|
|
|
|