diff options
Diffstat (limited to 'public/javascripts/search.js')
-rw-r--r-- | public/javascripts/search.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/public/javascripts/search.js b/public/javascripts/search.js new file mode 100644 index 0000000..8887ab2 --- /dev/null +++ b/public/javascripts/search.js @@ -0,0 +1,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 |