1$(document).ready(function(){ 2 $(".basicAutoComplete").autoComplete({ 3 resolver: "custom", 4 events: { 5 search: function(a, b, c) { 6 $.ajax({ 7 url: "https://suggestqueries.google.com/complete/search?hl=en&ds=yt&client=youtube&q=" + a, 8 type: "GET", 9 dataType: "jsonp", 10 success: function(a) { 11 b(a[1].map(function(a) { return a[0]; })); 12 }, 13 error: function(a, b, c) { 14 console.log(a, b, c); 15 } 16 }); 17 }, 18 select: function(a, b) { 19 console.log(a, b); 20 } 21 } 22 }); 23 24 $(".basicAutoComplete").on("autocomplete.select", function(a, b) { 25 $(this).closest('form').submit(); 26 }); 27 28 // Only fix dropdown for homepage hero search (.tb-search-wrapper) 29 // Navbar and non-home pages: let the plugin handle positioning natively 30 var $heroInput = $(".tb-search-wrapper .basicAutoComplete"); 31 if ($heroInput.length) { 32 var $wrapper = $heroInput.closest(".tb-search-wrapper"); 33 var observer = new MutationObserver(function(mutations) { 34 mutations.forEach(function(mutation) { 35 for (var i = 0; i < mutation.addedNodes.length; i++) { 36 var node = mutation.addedNodes[i]; 37 if (node.nodeType === 1 && $(node).hasClass("bootstrap-autocomplete")) { 38 $wrapper.append(node); 39 $(node).removeAttr("style"); 40 observer.disconnect(); 41 break; 42 } 43 } 44 }); 45 }); 46 observer.observe($heroInput.parent()[0], { childList: true }); 47 } 48});
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.