|
|
|
@ -58,7 +58,11 @@ function rebuildSuggestions() {
|
|
|
|
|
suggestions.splice(100) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var foundInput = false |
|
|
|
|
suggestions.forEach(function (suggestion, index) { |
|
|
|
|
if (trainNumber == suggestion.number) { |
|
|
|
|
foundInput = true |
|
|
|
|
} |
|
|
|
|
var suggestionLi = document.createElement('li') |
|
|
|
|
suggestionsArea.appendChild(suggestionLi) |
|
|
|
|
|
|
|
|
@ -93,6 +97,33 @@ function rebuildSuggestions() {
|
|
|
|
|
trainCompanyP.classList.add('thi') |
|
|
|
|
}, 0) |
|
|
|
|
}) |
|
|
|
|
if (!foundInput && trainNumber) { |
|
|
|
|
var suggestionLi = document.createElement('li') |
|
|
|
|
suggestionsArea.appendChild(suggestionLi) |
|
|
|
|
|
|
|
|
|
suggestionLi.classList.add('items') |
|
|
|
|
suggestionLi.tabIndex = suggestions.length + 2 |
|
|
|
|
suggestionLi.style.padding = '2px 0' |
|
|
|
|
|
|
|
|
|
function onAction(e) { |
|
|
|
|
goToTrain(trainNumber) |
|
|
|
|
} |
|
|
|
|
suggestionLi.addEventListener('click', onAction) |
|
|
|
|
suggestionLi.addEventListener('keypress', function (e) { |
|
|
|
|
if (e.key == 'Enter') { |
|
|
|
|
onAction(e) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
suggestionLi.addEventListener('focus', function (e) { |
|
|
|
|
focusedElement = suggestionLi |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
var trainNameP = document.createElement('p') |
|
|
|
|
suggestionLi.appendChild(trainNameP) |
|
|
|
|
|
|
|
|
|
trainNameP.textContent = `Train ${trainNumber}` |
|
|
|
|
trainNameP.classList.add('pri', 'trainName') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
_rebuildDebounce = null |
|
|
|
|