1 2import Request from 'reader/Request'; 3import Results from 'reader/html/Results'; 4import ResultsHeader from 'reader/html/ResultsHeader'; 5import ErrorMessage from 'reader/html/ErrorMessage'; 6import QueryParams from 'reader/QueryParams'; 7import SearchStrategyFactory from 'reader/SearchStrategyFactory'; 8 9/** 10 * Requests the actual results from the API and renders the header and each result. 11 */ 12export default class Search { 13 get searchStrategy() { 14 return new SearchStrategyFactory().create(); 15 } 16 17 async perform() { 18 try { 19 const request = new Request(this.searchStrategy.endpoint, this.searchStrategy.fetchOptions); 20 21 const data = await request.json(); 22 23 this.notLoading(); 24 25 data.rc = QueryParams.current().roomContext(); 26 27 [ResultsHeader, Results].forEach((builder) => { 28 new builder(data).build(); 29 }); 30 } catch (e) { 31 // eslint-disable-next-line no-console 32 console.error(e); 33 34 this.notLoading(); 35 36 const error = new ErrorMessage(); 37 error.build(); 38 } 39 } 40 41 notLoading() { 42 document.querySelector('.results-spinner').remove(); 43 } 44}
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.