diff options
author | Noah Loomans <noahloomans@gmail.com> | 2016-10-12 10:41:00 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2016-10-12 10:41:00 +0200 |
commit | fe54db967ff79d75f2d793d41aeec677b01c6067 (patch) | |
tree | ff448ed8609eab0e435b28dde24fedc72c69f2f2 /public/javascripts/main.js | |
parent | bb9e55ec41194a085cb7c627b7ef2c77938baa49 (diff) |
fix error when no results
Diffstat (limited to 'public/javascripts/main.js')
-rw-r--r-- | public/javascripts/main.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 37e9677..55bf054 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -29,7 +29,7 @@ if (window.location.href.split('?')[1] !== 'nfd') { // nfd = no feature detectio let selectedResult = -1 let selectedUser -let results +let results = [] let offset = 0 function getUsers () { @@ -88,7 +88,7 @@ function updateWeekText () { updateWeekText() searchNode.addEventListener('keydown', function (e) { - if (results && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) { + if ((results.length !== 0) && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) { e.preventDefault() if (document.querySelector('.selected')) document.querySelector('.selected').classList.remove('selected') @@ -122,7 +122,7 @@ searchNode.addEventListener('submit', submitForm) function submitForm (e) { if (e) e.preventDefault() - if (results != null) { + if (results.length !== 0) { const indexInResult = selectedResult === -1 ? 0 : selectedResult selectedUser = users[results[indexInResult].index] } |