1/* Skelly search autocomplete â uses Awesomplete (same library as live). 2 Suggestions are page/post titles; the matched text is <mark>-highlighted by 3 Awesomplete. Selecting a suggestion runs a SEARCH for that text (like live) 4 and lands on the results page. Data: window.SKELLY_SEARCH = { home, items:[{t,u,k}] }. */ 5(function () { 6 var DATA = window.SKELLY_SEARCH || { home: '/', items: [] }; 7 var home = DATA.home || '/'; 8 var seen = {}, titles = []; 9 (DATA.items || []).forEach(function (it) { 10 var t = it.t || ''; 11 if (t && !seen[t.toLowerCase()]) { seen[t.toLowerCase()] = 1; titles.push(t); } 12 }); 13 14 function init(input) { 15 if (!input || input.__skAuto || typeof Awesomplete === 'undefined') { return; } 16 input.__skAuto = true; 17 input.setAttribute('autocomplete', 'off'); 18 19 var aw = new Awesomplete(input, { 20 list: titles, 21 minChars: 2, 22 maxItems: 7, 23 autoFirst: false 24 // default filter = FILTER_CONTAINS, default item = <mark> highlight (matches live) 25 }); 26 27 // Like live: choosing a suggestion searches for that text -> results page. 28 input.addEventListener('awesomplete-selectcomplete', function (e) { 29 var text = (e.text && e.text.value) ? e.text.value : input.value; 30 window.location = home + '?s=' + encodeURIComponent(text); 31 }); 32 } 33 34 function boot() { 35 var inputs = document.querySelectorAll('#site-search, input[name="s"]'); 36 Array.prototype.forEach.call(inputs, init); 37 } 38 if (document.readyState !== 'loading') { boot(); } 39 else { document.addEventListener('DOMContentLoaded', boot); } 40})();
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.