PageSourceSearch

https://rowehomes.co.uk/wp-content/plugins/propertyhive-location-a…/js/ph-location-autocomplete.js?ver=1.0.6

js rowehomes.co.uk collected 2026-09-27 03:25:47 UTC 4,943 bytes, 149 lines download raw bytes

1jQuery( function($)
2{
3	if ( ( location_autocomplete_object.data_source == '' || location_autocomplete_object.data_source == 'manual' || location_autocomplete_object.data_source == 'locations' ) && location_autocomplete_object.location_values.length > 0 )
4	{
5		jQuery(document).keyup(function(e) 
6		{
7	    	if ( jQuery('.autocomplete-results').css('display') == 'block' )
8	    	{
9	    		if (e.key === "Escape") { // escape key maps to keycode `27`
10		        	jQuery('.autocomplete-results').hide();
11		    	}
12
13		    	switch (e.keyCode) {
14		    		case 38: // if the UP key is pressed
15		    		{
16		    			var index_of_current_active = jQuery('.autocomplete-results ul').find('li.active').index();
17		    			var new_index = jQuery('.autocomplete-results ul li').length - 1;
18		    			if ( index_of_current_active != -1 )
19		    			{
20		    				new_index = index_of_current_active - 1;
21		    			}
22		    			if ( new_index < 0 )
23		    			{
24		    				new_index = 0;
25		    			}
26
27		    			jQuery('.autocomplete-results li.active').removeClass('active');
28		    			jQuery('.autocomplete-results li').eq(new_index).addClass('active');
29		    			break;
30		    		}
31		    		case 40: // if the DOWN key is pressed
32		    		{
33		    			var index_of_current_active = jQuery('.autocomplete-results ul').find('li.active').index();
34		    			var new_index = 0;
35		    			if ( index_of_current_active != -1 )
36		    			{
37		    				new_index = index_of_current_active + 1;
38		    			}
39		    			if ( new_index >= jQuery('.autocomplete-results ul li').length )
40		    			{
41		    				new_index = jQuery('.autocomplete-results ul li').length - 1;
42		    			}
43
44		    			jQuery('.autocomplete-results li.active').removeClass('active');
45		    			jQuery('.autocomplete-results li').eq(new_index).addClass('active');
46		    			break;
47		    		}
48		    	}
49		    }
50		});
51
52		jQuery('.property-search-form input[name=\'address_keyword\']').each(function()
53		{
54			jQuery(this).attr('autocomplete', 'off');
55			jQuery(this).wrap( '<div class="autocomplete-container"></div>' );
56			jQuery(this).after( '<div class="autocomplete-results" style="top:' + jQuery(this).outerHeight() + 'px;"><ul></ul></div>' );
57		});
58
59		jQuery('.property-search-form input[name=\'address_keyword\']').keydown(function(e)
60		{
61			if ( jQuery('.autocomplete-results').css('display') == 'block' )
62	    	{
63				if ( e.keyCode == 13 )
64				{
65					if ( jQuery('.autocomplete-results ul li.active').length > 0 )
66	    			{
67	    				e.preventDefault();
68	    				jQuery('.autocomplete-results ul li.active').trigger('click');
69	    				return;
70	    			}
71				}
72			}
73		});
74
75		jQuery('.property-search-form input[name=\'address_keyword\']').keyup(function(e)
76		{
77			if ( e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 13 )
78			{
79				return;
80			}
81
82			jQuery(this).next('.autocomplete-results').hide();
83
84			var results = [];
85			if ( jQuery(this).val() != '' )
86			{
87				for ( var i = 0; i < location_autocomplete_object.location_values.length; i++ ) 
88				{
89					if ( location_autocomplete_object.data_source == 'locations' )
90					{
91						if ( 
92					    	location_autocomplete_object.location_values[i].search.toLowerCase().indexOf( jQuery(this).val().toLowerCase() ) == 0 ||
93					    	location_autocomplete_object.location_values[i].search.toLowerCase().indexOf( ' ' + jQuery(this).val().toLowerCase() ) != -1
94					    ) 
95					    {
96					    	results.push(location_autocomplete_object.location_values[i].label);
97					    }
98					}
99					else
100					{
101					    if ( 
102					    	location_autocomplete_object.location_values[i].toLowerCase().indexOf( jQuery(this).val().toLowerCase() ) == 0 ||
103					    	location_autocomplete_object.location_values[i].toLowerCase().indexOf( ' ' + jQuery(this).val().toLowerCase() ) != -1
104					    ) 
105					    {
106					    	results.push(location_autocomplete_object.location_values[i]);
107					    }
108					}
109				}
110			}
111			
112			if ( results.length > 0 )
113			{
114				jQuery(this).next('.autocomplete-results').find('ul').empty();
115				for ( var i in results )
116				{
117					jQuery(this).next('.autocomplete-results').find('ul').append('<li>' + results[i] + '</li>');
118				}
119				jQuery(this).next('.autocomplete-results').show();
120			}
121		});
122
123		jQuery('.property-search-form').on('click', '.autocomplete-results ul li', function()
124		{
125			jQuery('.autocomplete-results').hide();
126			jQuery('.property-search-form input[name=\'address_keyword\']').val( jQuery(this).html() );
127		});
128	}
129});
130
131var placeSearch;
132var autocomplete;
133var componentForm = {
134	street_number: 'short_name',
135	route: 'long_name',
136	locality: 'long_name',
137	administrative_area_level_1: 'short_name',
138	country: 'long_name',
139	postal_code: 'short_name'
140};
141function init_location_autocomplete()
142{
143	var input = document.getElementById('address_keyword');
144	var options = {
145	   componentRestrictions: { country: location_autocomplete_object.country }
146	};
147	var autocomplete = new google.maps.places.Autocomplete(input, options);
148	autocomplete.setFields(['address_components']);
149}

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.