1/** 2 * @file 3 * Addsearch search widget configuration. 4 */ 5(($, Drupal) => { 6 7 var client = new AddSearchClient('416728699284b6132b6d6c72e4a8f823'); 8 9 // Set the search language 10 let pageLang = jQuery('html').attr('lang'); 11 12 client.setLanguage(pageLang); 13 14 // domain filter 15 client.setCategoryFilters('0x'+drupalSettings.addsearch.subsite); 16 17 var conf = { 18 searchResultsPageUrl: Drupal.t('/search-results'), 19 updateBrowserHistory: false, 20 baseFilters: { 21 'not': { 'custom_fields.type': 'Network' } 22 } 23 }; 24 25 26 const SEARCHFIELD_TEMPLATE = ` 27 <div class="addsearch-searchfield-container"> 28 <form class="addsearch-searchfield" autocomplete="off" action="?" role="search"> 29 <div class="search-field-wrapper"> 30 <input type="search" placeholder="{{placeholder}}" aria-label="${Drupal.t('Search')}" class="{{#not icon false}}icon{{/not}}" /> 31 </div> 32 {{#if button}} 33 <button type="button" aria-label="Search button" >{{button}}</button> 34 {{/if}} 35 </form> 36 </div> 37 `; 38 39 const SEARCHRESULTS_TEMPLATE = ` 40 <div class="addsearch-searchresults"> 41 {{#if resultcount}} 42 {{> numberOfResultsTemplate }} 43 {{/if}} 44 45 {{#each hits}} 46 <div class="hit{{#equals type "PROMOTED"}} promoted{{/equals}}"> 47 <h3> 48 <a href="{{url}}" data-analytics-click="{{id}}">{{#if title}} {{title}} {{else}} {{removeTrailingQueriesFromUrl url}} {{/if}}</a> 49 </h3> 50 <div class="highlight"> 51 {{> searchResultImageTemplate}} 52 {{{highlight}}}{{#not type "PROMOTED"}}…{{/not}} 53 </div> 54 {{#gt categories.length 1}} 55 <div class="category"> 56 {{selectCategory ..}} 57 </div> 58 {{/gt}} 59 </div> 60 {{/each}} 61 </div> 62 `; 63 64 const NUMBER_OF_RESULTS_TEMPLATE = ` 65 <div class="number-of-results"> 66 {{#gt page 1}}Page {{../page}} of {{/gt}} 67 {{total_hits}}{{#equals total_hits 10000}}+{{/equals}} ${Drupal.t('results')} 68 </div> 69 `; 70 const NO_RESULTS_TEMPLATE = ` 71 <div class="addsearch-searchresults addsearch-searchresults-no-results"> 72 <h2>${Drupal.t('No search results with keyword')} <em>{{keyword}}</em></h2> 73 </div> 74 `; 75 76 $('.addsearch-widget').each(function() { 77 let $widget = $(this); 78 let searchui = new AddSearchUI(client, conf); 79 80 searchui.searchField({ 81 containerId: $widget.attr('id')+'-search', 82 placeholder: Drupal.t('Search'), 83 template: SEARCHFIELD_TEMPLATE, 84 searchAsYouType: true, 85 icon: false, 86 autofocus: false, 87 minLengthToShowResults: 3 88 }); 89 90 searchui.searchResults({ 91 containerId: $widget.attr('id')+'-results', 92 template: SEARCHRESULTS_TEMPLATE, 93 template_resultcount: NUMBER_OF_RESULTS_TEMPLATE, 94 template_noresults: NO_RESULTS_TEMPLATE 95 }); 96 97 searchui.start(); 98 99 }); 100 101})(jQuery, Drupal)
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.