1import 'sites/easy-autocomplete' 2export class SearchControlBinding { 3 static setupEasyAutocomplete(options) { 4 const allInputQueries = document.querySelectorAll(`${options.cssIdentifier} input[name="query"][data-autocomplete-enabled="true"]`) 5 for (const [index, inputQuery] of allInputQueries.entries()) { 6 const action = inputQuery.dataset.autocompleteUrl 7 const easyAutocompleteOptions = { 8 url: (query) => this.buildUrl(action, query), 9 getValue: 'name', 10 requestDelay: 350, 11 categories: options.categories, 12 list: options.list, 13 cssClasses: "form-control form-control-sm fix-autocomplete", //https://github.com/pawelczak/EasyAutocomplete/issues/300 14 template: { 15 type: 'custom', 16 method: (value, item) => options.listItemTemplate(value, item, index) 17 } 18 }; 19 $ctj(inputQuery).easyAutocomplete(easyAutocompleteOptions) 20 } 21 } 22 23 static buildUrl(action, query) { 24 return URI(action).setQuery('query', query) 25 } 26 27 static cssIdFromItem(item, index) { 28 return `${item.name.toLowerCase().split(' ').join('_')}_${index}`; 29 } 30}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.