aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/main.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-09-05 16:23:12 +0200
committerNoah Loomans <noahloomans@gmail.com>2016-09-05 16:23:12 +0200
commit8e4c9d666672e415957ae8b99e7ab400342f8b98 (patch)
tree885bb8e4e0e887ba07a72ba90f5254c9d0d0a070 /public/javascripts/main.js
parentff5f463f77d7eef492d3ae926ce65cdfdb45dfdb (diff)
add click on autocomplete suport
Diffstat (limited to 'public/javascripts/main.js')
-rw-r--r--public/javascripts/main.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js
index c492ace..f311e17 100644
--- a/public/javascripts/main.js
+++ b/public/javascripts/main.js
@@ -50,7 +50,9 @@ getUsers().then(function (users) {
}
})
- searchNode.addEventListener('submit', function (e) {
+ searchNode.addEventListener('submit', submitForm)
+
+ function submitForm (e) {
e.preventDefault()
const indexInResult = selectedResult === -1 ? 0 : selectedResult
const selectedUser = users[results[indexInResult].index]
@@ -61,6 +63,13 @@ getUsers().then(function (users) {
inputNode.blur()
scheduleIframe.src = getURLOfUser(0, selectedUser.type, selectedUser.index + 1)
+ }
+
+ autocompleteNode.addEventListener('click', function (e) {
+ if (e.target.tagName === 'LI' && e.target.parentElement === autocompleteNode) {
+ selectedResult = Array.prototype.indexOf.call(e.target.parentElement.childNodes, e.target)
+ submitForm({preventDefault: function () {}}) // HACK: this is horrible.
+ }
})
})