1jQuery(document).ready(function($) { 2 $('#constituency-selected').change(function() { 3 var constituency = $('#constituency-lookup').val(); 4 5 // disable select 6 $('#constituency-lookup').prop('disabled', true); 7 $('#constituency-lookup-results').hide(); 8 9 $.ajax({ 10 url: geek_constituency_lookup.ajax_url, 11 type: 'post', 12 data: { 13 action: 'db_constituency_candidates_lookup', 14 constituency: constituency 15 }, 16 beforeSend: function() { 17 $('#constituency-lookup-results').html('Loading...'); 18 $('#constituency-lookup-results').show(); 19 }, 20 success: function(response) { 21 var resultsContainer = $('#constituency-lookup-results'); 22 resultsContainer.html(response); 23 resultsContainer.show(); 24 $('#constituency-lookup').prop('disabled', false); 25 26 // add button to clear results 27 var hideButton = $('<a class="nectar-button medium regular">Hide Results</a>'); 28 hideButton.click(function() { 29 resultsContainer.html(''); 30 // unset the selected option 31 $('#constituency-lookup').val(''); 32 }); 33 resultsContainer.append(hideButton); 34 } 35 }); 36 }); 37 38 let lookupTimeout; 39 40 $('#constituency-lookup').on('keyup', function() { 41 var constituency = $('#constituency-lookup').val(); 42 43 $('#constituency-lookup-results').html('Loading...'); 44 $('#constituency-lookup-results').show(); 45 46 clearTimeout(lookupTimeout); 47 48 lookupTimeout = setTimeout(function() { 49 $.ajax({
50 url: geek_constituency_lookup.ajax_url, 51 type: 'post', 52 data: { 53 action: 'db_constituency_lookup', 54 constituency: constituency 55 }, 56 success: function(response) { 57 var resultsContainer = $('#constituency-lookup-results'); 58 resultsContainer.html(response); 59 resultsContainer.show(); 60 } 61 62 }); 63 }, 1000) 64 }); 65 $('body').on('click', '.constituency-select', function() { 66 var constituency = $(this).data('constituency'); 67 $('#constituency-lookup').val(constituency); 68 $('#constituency-selected').val(constituency); 69 $('#constituency-selected').trigger('change'); 70 }); 71});
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.