aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/search.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/javascripts/search.js')
-rw-r--r--public/javascripts/search.js27
1 files changed, 17 insertions, 10 deletions
diff --git a/public/javascripts/search.js b/public/javascripts/search.js
index a07d6dd..96413b0 100644
--- a/public/javascripts/search.js
+++ b/public/javascripts/search.js
@@ -13,22 +13,29 @@ self._nodes = {
}
self.submit = function () {
- const selectedItem = autocomplete.getSelectedItem()
- if (selectedItem == null) return
+ const selectedUser = autocomplete.getSelectedUser()
+ if (selectedUser == null) return
- console.log(selectedItem)
+ console.log(selectedUser)
self._nodes.input.blur()
document.body.classList.remove('week-selector-not-visible') // Safari bug
- self.emit('search', selectedItem)
+ self.emit('search', selectedUser)
}
-self.updateDom = function (selectedItem) {
- self._nodes.input.value = selectedItem.value
- autocomplete.removeAllItems()
- document.body.classList.remove('no-input')
- document.body.classList.add('searched')
+self.updateDom = function (selectedUser) {
+ if (selectedUser == null) {
+ self._nodes.input.value = ''
+ autocomplete.removeAllItems()
+ document.body.classList.add('no-input')
+ document.body.classList.remove('searched')
+ } else {
+ self._nodes.input.value = selectedUser.value
+ autocomplete.removeAllItems()
+ document.body.classList.remove('no-input')
+ document.body.classList.add('searched')
+ }
}
self.focus = function () {
@@ -42,7 +49,7 @@ self._handleSubmit = function (event) {
self._calculate = function (searchTerm) {
const allResults = fuzzy.filter(searchTerm, USERS, {
- extract: function (item) { return item.value }
+ extract: function (user) { return user.value }
})
const firstResults = allResults.slice(0, 7)