aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/search.js
blob: 8887ab28e01638994994a4f50f9c1b6300928b7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const autocomplete = require('./autocomplete')
const iframe = require('./iframe')

const self = {}

self._nodes = {
  search: document.querySelector('#search'),
  input: document.querySelector('input[type="search"]')
}

self.submit = function () {
  self._nodes.input.blur()

  const selectedItem = autocomplete.getSelectedItem()
  console.log(selectedItem)
  iframe.viewItem(0, selectedItem)
}

self._handleSubmit = function (event) {
  event.preventDefault()
  self.submit()
}

self._nodes.search.addEventListener('submit', self._handleSubmit)

console.log(self)

module.exports = self