Add depicts drop downs to the catalog page.
This commit is contained in:
parent
039240b3c5
commit
0bebf2de86
2 changed files with 92 additions and 1 deletions
38
static/js/catalog.js
Normal file
38
static/js/catalog.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
var typingTimer;
|
||||
var doneTypingInterval = 500;
|
||||
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
delimiters: ['${', '}'],
|
||||
data: {
|
||||
prevTerms: {},
|
||||
searchTerms: {},
|
||||
hits: {},
|
||||
},
|
||||
methods: {
|
||||
run_search(qid) {
|
||||
var terms = this.searchTerms[qid];
|
||||
if (terms == this.prevTerms[qid]) {
|
||||
return; // no change
|
||||
}
|
||||
this.prevTerms[qid] = terms;
|
||||
if (terms.length < 3) {
|
||||
this.hits[qid] = [];
|
||||
return;
|
||||
}
|
||||
|
||||
var vm = this;
|
||||
|
||||
fetch(lookup_url + '?terms=' + encodeURI(terms))
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
vm.hits[qid] = data.hits;
|
||||
})
|
||||
},
|
||||
search(event) {
|
||||
var qid = event.target.dataset.qid
|
||||
clearTimeout(typingTimer);
|
||||
typingTimer = setTimeout(this.run_search, doneTypingInterval, qid);
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue