1jQuery(document).ready(function($){ 2 var selectedLocatorValue = ''; // Variable to store selected radio button value 3 var storedCookie = $.cookie('branch_location'); 4 console.log(storedCookie); 5 if (storedCookie) { 6 console.log('YES'); 7 selectedLocatorValue = storedCookie; 8 // Automatically trigger the AJAX request to populate the updated query result 9 $.ajax({ 10 type: 'POST', 11 url: ajax_object.ajax_url, // WordPress AJAX URL 12 data: { 13 action: 'set_branch_location', // WordPress AJAX action name 14 branch_location: selectedLocatorValue 15 }, 16 success: function(response) { 17 $('#result').html(response); 18 console.log('first function success'); 19 $.ajax({ 20 type: 'POST', 21 url: ajax_object.ajax_url, 22 data: { 23 action: 'get_updated_query_result', 24 25 branch_location: selectedLocatorValue 26 }, 27 success: function(updatedResponse) { 28 $('.updated-query-result').html(updatedResponse); 29 console.log('second function success'); 30 } 31 }); 32 } 33 }); 34 } else { 35 console.log('SAD'); 36 } 37 // Event handler for radio button changes 38 $(document).on('change','.location-chooser', function() { 39 selectedLocatorValue = $(this).val().trim(); 40 }); 41 42 // Event handler for the "Save" button click 43 $(document).on('click', '.save-btn', function() { 44 if (selectedLocatorValue !== '') { 45 console.log(selectedLocatorValue); 46 // Set the cookie using jQuery Cookie plugin 47 $.cookie('branch_location', selectedLocatorValue, { expires: 1, path: '/' }); 48 49 // Send the cookie value to the WordPress AJAX handler using the correct AJAX URL 50 $.ajax({
51 type: 'POST', 52 url: ajax_object.ajax_url, // WordPress AJAX URL 53 data: { 54 action: 'set_branch_location', // WordPress AJAX action name 55 branch_location: selectedLocatorValue 56 }, 57 success: function(response) { 58 $('#result').html(response); 59 $.ajax({ 60 type: 'POST', 61 url: ajax_object.ajax_url, 62 data: { 63 action: 'get_updated_query_result', 64 branch_location: selectedLocatorValue 65 }, 66 success: function(updatedResponse) { 67 $('.updated-query-result').html(updatedResponse); 68 location.reload(); 69 } 70 }); 71 } 72 }); 73 } 74 }); 75 $(document).on('click','.clear-btn',function(){ 76 console.log('clicked'); 77 $.ajax({
78 type: 'POST', 79 url: ajax_object.ajax_url, 80 data: { 81 action: 'clear_branch_location_cookie' 82 }, 83 success: function(response) { 84 // Handle the success response, if needed 85 location.reload(); 86 } 87 }); 88 }); 89 90 $(document).on('click','.branch-title',function(){ 91 if($(this).hasClass('branch-act')) { 92 $('.branch-detail').fadeOut(); 93 $(this).removeClass('branch-act'); 94 } else { 95 $('.branch-detail').fadeIn(); 96 $(this).addClass('branch-act'); 97 } 98 }); 99 $(document).click(function(e){ 100 var target = e.target; 101 if (!$(target).is('.branch-detail') && !$(target).closest('.branch-detail').length && !$(target).is('.branch-parent') && !$(target).is('.branch-title') && !$(target).is('.branch-title span')) { 102 $('.branch-detail').fadeOut(); 103 $('.branch-title').removeClass('branch-act'); 104 } 105 }); 106});
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.