1(function ($) { 2 $(document).ready(function(){ 3 // I want to study 4 var url = window.location.origin+'/study'; 5 6 $.getJSON(url, function (data) { 7 // Initialize the widget with the data we got back: 8 // set change function to text field change and filter data to value. limit 9 // the results 10 $("#study-search").autocomplete({ 11 source: data, 12 minLength: 0, 13 classes: { 14 "ui-autocomplete": "careers-home" 15 }, 16 open: function( event, ui ) { 17 if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { 18 $('.ui-autocomplete').off('menufocus hover mouseover mouseenter'); 19 } 20 }, 21 select: function( event, ui ) { 22 $( "#study-search" ).attr('data-redirect', ui.item.redirect); 23 $( "#study-search" ).val( ui.item.value ); 24 25 // add title for mobile submits 26 $( "#study-search" ).attr('data-title', ui.item.value); 27 28 // send results to google events 29 // @todo: replace this with GA4 events. 30 // ga('send', 'event', 'Academics', 'click', ui.item.value); 31 32 // Encode the search term and its parent for use in a URL. 33 var searchTerm = ui.item.value; 34 if (ui.item.value !== ui.item.parent) { 35 searchTerm += ", " + ui.item.parent; 36 } 37 38 // set the window location to the desired URL 39 window.location.href = '/search/google/?keys=' + searchTerm; 40 return false; 41 }, 42 create: function () { 43 $(this).data('ui-autocomplete')._renderItem = function (ul, item) { 44 return $('<li>') 45 .append( "<div>" + item.label + " <span class='study-label'> - " + item.parent + "</span></div>" ) 46 .appendTo(ul); 47 }; 48 } 49 }); 50 }); 51 52 $('#block-academicsmajorfinder .form-submit').click(function(e){ 53 e.preventDefault(); 54 var searchTerm = $('#study-search').val(); 55 if (searchTerm) { 56 // @todo: replace this with GA4 events. 57 // ga('send', 'event', 'Academics', 'click', searchTerm); 58 // encode the search term and its parent for use in a URL 59 var encodedTerm = encodeURIComponent(searchTerm); 60 window.location.href = '/search/google/?keys=' + encodedTerm; 61 } 62 }); 63 64 $('#list-majors').click(function(){ 65 $('#study-search').val(''); 66 $('#study-search').keydown(); 67 }); 68 }); 69})(jQuery);
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.