mirror of
				https://codeberg.org/kbruen/kai.infotren.git
				synced 2025-11-04 00:46:35 +02:00 
			
		
		
		
	Allow choosing train that is not known/suggested
This commit is contained in:
		
							parent
							
								
									f4ae034812
								
							
						
					
					
						commit
						555f80aa1c
					
				
					 1 changed files with 31 additions and 0 deletions
				
			
		
							
								
								
									
										31
									
								
								train.js
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										31
									
								
								train.js
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue