vendor: 2,871 bytes, lines 1-98
1function getSearchTermFromLocation() { 2 var sPageURL = window.location.search.substring(1); 3 var sURLVariables = sPageURL.split('&'); 4 for (var i = 0; i < sURLVariables.length; i++) { 5 var sParameterName = sURLVariables[i].split('='); 6 if (sParameterName[0] == 'q') { 7 return decodeURIComponent(sParameterName[1].replace(/\+/g, '%20')); 8 } 9 } 10} 11 12function joinUrl (base, path) { 13 if (path.substring(0, 1) === "/") { 14 // path starts with `/`. Thus it is absolute. 15 return path; 16 } 17 if (base.substring(base.length-1) === "/") { 18 // base ends with `/` 19 return base + path; 20 } 21 return base + "/" + path; 22} 23 24function formatResult (location, title, summary) { 25 return '<article><h3><a href="' + joinUrl(base_url, location) + '">'+ title + '</a></h3><p>' + summary +'</p></article>'; 26} 27 28function displayResults (results) { 29 var search_results = document.getElementById("mkdocs-search-results"); 30 while (search_results.firstChild) { 31 search_results.removeChild(search_results.firstChild); 32 } 33 if (results.length > 0){ 34 for (var i=0; i < results.length; i++){ 35 var result = results[i]; 36 var html = formatResult(result.location, result.title, result.summary); 37 search_results.insertAdjacentHTML('beforeend', html); 38 } 39 } else { 40 search_results.insertAdjacentHTML('beforeend', "<p>No results found</p>"); 41 } 42} 43 44function doSearch () { 45 var query = document.getElementById('mkdocs-search-query').value; 46 if (query.length > min_search_length) { 47 if (!window.Worker) { 48 displayResults(search(query)); 49 } else { 50 searchWorker.postMessage({query: query}); 51 } 52 } else { 53 // Clear results for short queries 54 displayResults([]); 55 } 56} 57 58function initSearch () { 59 var search_input = document.getElementById('mkdocs-search-query'); 60 if (search_input) { 61 search_input.addEventListener("keyup", doSearch); 62 } 63 var term = getSearchTermFromLocation(); 64 if (term) { 65 search_input.value = term; 66 doSearch(); 67 } 68} 69 70function onWorkerMessage (e) { 71 if (e.data.allowSearch) { 72 initSearch(); 73 } else if (e.data.results) { 74 var results = e.data.results; 75 displayResults(results); 76 } else if (e.data.config) { 77 min_search_length = e.data.config.min_search_length-1; 78 } 79} 80 81if (!window.Worker) { 82 console.log('Web Worker API not supported'); 83 // load index in main thread 84 $.getScript(joinUrl(base_url, "search/worker.js")).done(function () { 85 console.log('Loaded worker'); 86 init(); 87 window.postMessage = function (msg) { 88 onWorkerMessage({data: msg}); 89 }; 90 }).fail(function (jqxhr, settings, exception) { 91 console.error('Could not load worker.js'); 92 }); 93} else { 94 // Wrap search in a web worker 95 var searchWorker = new Worker(joinUrl(base_url, "search/worker.js")); 96 searchWorker.postMessage({init: true}); 97 searchWorker.onmessage = onWorkerMessage; 98}
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.