diff --git a/static/js/app.js b/static/js/app.js new file mode 100644 index 0000000..a195ec2 --- /dev/null +++ b/static/js/app.js @@ -0,0 +1,30 @@ +var app = new Vue({ + el: '#app', + data: { + searchTerms: '', + hits: [], + new_depicts: [], + }, + methods: { + add_depicts(hit) { + this.new_depicts.push(hit); + this.hits = []; + this.searchTerms = ''; + }, + search(event) { + var terms = this.searchTerms; + if (terms.length < 3) { + this.hits = []; + return; + } + + var vm = this; + + fetch(lookup_url + '?terms=' + encodeURI(terms)) + .then((res) => res.json()) + .then((data) => { + vm.hits = data.hits; + }) + } + }, +});