PageSourceSearch

https://careeramaze.com/wp-content/plugins/wp-jobsearch/js/jquery.location-autocomplete.js?ver=2.6.3

js careeramaze.com collected 2026-10-04 08:27:44 UTC 8,839 bytes, 180 lines download raw bytes

1var jobsearch_autosugg_ajxreq;
2jQuery.fn.extend({
3    cityAutocomplete: function (options) {
4
5        if (jobsearch_plugin_vars.locmap_type == 'mapbox') {
6
7            var mapbox_acces_token = jobsearch_plugin_vars.mapbox_token;
8            var mapbox_style_url = jobsearch_plugin_vars.mapbox_style;
9            if (mapbox_acces_token != '' && mapbox_style_url != '') {
10
11                
12            }
13
14        } else {
15
16            return this.each(function () {
17                var input = jQuery(this);
18                var predictionsDropDown = jQuery('<div class="jobsearch_location_autocomplete" class="city-autocomplete"></div>').appendTo(jQuery(this).parent());
19                var request_var = 1;
20
21                input.off('keyup');
22
23                input.on('keyup', function () {
24
25                    jQuery(this).parent(".jobsearch_searchloc_div").find('.loc-loader').html("<i class='fa fa-refresh fa-spin'></i>");
26                    if (request_var == 1) {
27                        var searchStr = jQuery(this).val();
28                        // Min Number of characters
29                        var num_of_chars = 0;
30                        if (searchStr.length > num_of_chars) {
31                            updatePredictions(input);
32                        } else {
33                            jQuery(".jobsearch_searchloc_div").find('.loc-loader').html('');
34                        }
35                    }
36                });
37                predictionsDropDown.delegate('div', 'click', function () {
38                    if (jQuery(this).text() != jobsearch_plugin_vars.var_address_str && jQuery(this).text() != jobsearch_plugin_vars.var_other_locs_str) {
39                        // address with slug
40                        var jobsearch_address_html = jQuery(this).text();
41                        // slug only
42                        var jobsearch_address_slug = jQuery(this).find('span').html();
43                        // remove slug
44                        jQuery(this).find('span').remove();
45                        input.val(jQuery(this).text());
46                        input.next('.loc_search_keyword').val(jobsearch_address_slug);
47                        predictionsDropDown.hide();
48                        input.next('.loc_search_keyword').closest("form.side-loc-srch-form").submit();
49                    }
50                });
51                jQuery(document).mouseup(function (e) {
52                    predictionsDropDown.hide();
53                });
54                jQuery(window).resize(function () {
55                    updatePredictionsDropDownDisplay(predictionsDropDown, input);
56                });
57                updatePredictionsDropDownDisplay(predictionsDropDown, input);
58                function updatePredictions(input) {
59
60                    if (typeof jobsearch_autosugg_ajxreq !== undefined && jobsearch_autosugg_ajxreq != undefined) {
61                        jobsearch_autosugg_ajxreq.abort();
62                    }
63                    predictionsDropDown.empty();
64                    // AJAX GET Locations
65                    var dataString = 'action=jobsearch_get_google_autocomplete_locations&_nonce=' + jobsearch_comon_script_vars.nonce + '&keyword=' + input.val();
66                    var plugin_url = jobsearch_plugin_vars.ajax_url;
67                    jobsearch_autosugg_ajxreq = jQuery.ajax({
68                        type: "POST",
69                        url: plugin_url,
70                        data: dataString,
71                    });
72
73                    jobsearch_autosugg_ajxreq.done(function (data) {
74                        jQuery(".jobsearch_searchloc_div").find('.loc-loader').html('');
75                        var result = jQuery.parseJSON(data);
76                        var loc_results = result.locs;
77                        var gloc_results = result.glocs;
78                        predictionsDropDown.empty();
79                        if (gloc_results != '') {
80                            var google_results = '<div class="address_headers"><h5>' + jobsearch_plugin_vars.var_address_str + '</h5></div>';
81                            jQuery(gloc_results).each(function (key, value) {
82                                google_results += '<div class="jobsearch_google_suggestions"><i class="icon-location-arrow"></i> ' + value + '<span style="display:none">
82' + value + '</span></div>';
83                            });
84                            predictionsDropDown.append(google_results);
85                        }
86                        if (loc_results != '') {
87                            predictionsDropDown.append('<div class="address_headers"><h5>' + jobsearch_plugin_vars.var_address_str + '</h5></div>');
88                            jQuery(loc_results).each(function (key, value) {
89                                if (value.hasOwnProperty('child')) {
90                                    jQuery(value.child).each(function (child_key, child_value) {
91                                        predictionsDropDown.append('<div class="jobsearch_location_child">' + child_value.value + '<span style="display:none">' + child_value.slug + '</span></div');
92                                    })
93                                } else {
94                                    predictionsDropDown.append('<div class="jobsearch_location_parent">' + value.value + '<span style="display:none">' + value.slug + '</span></div');
95                                }
96                            });
97                        }
98                        request_var = 1;
99                    });
100
101                    jobsearch_autosugg_ajxreq.fail(function (jqXHR, textStatus) {
102                        jQuery(".jobsearch_searchloc_div").find('.loc-loader').html('');
103                    });
104
105                    predictionsDropDown.show();
106                }
107                return input;
108            });
109        }
110    }
111});
112
113function updatePredictionsDropDownDisplay(dropDown, input) {
114    if (typeof (input.offset()) !== 'undefined') {
115        dropDown.css({
116            'width': input.outerWidth(),
117            'left': input.offset().left,
118            'top': input.offset().top + input.outerHeight()
119        });
120    }
121}
122
123function jobsearch_fulladres_to_city_contry(geoData) {
124    // debugger;
125    var region, countryName, placeName, returnStr;
126    if (geoData.context) {
127        $.each(geoData.context, function (i, v) {
128            if (v.id.indexOf('region') >= 0) {
129                region = v.text;
130            }
131            if (v.id.indexOf('country') >= 0) {
132                countryName = v.text;
133            }
134        });
135    }
136    if (region && countryName) {
137        returnStr = region + ", " + countryName;
138    } else {
139        returnStr = geoData.place_name;
140    }
141    return returnStr;
142}
143
144jQuery(document).on('click', '.jobsearch_search_location_field', function() {
145    jQuery('.jobsearch_search_location_field').cityAutocomplete();
146});
147jQuery(document).on('click', '.jobsearch_searchloc_div', function () {
148    jQuery('.jobsearch_search_location_field').prop('disabled', false);
149});
150jQuery(document).on('change', '.jobsearch_search_location_field', function () {
151    var this_new_loc = jQuery(this).val();
152    if (typeof jobsearch_listing_dataobj !== 'undefined') {
153        var locMapType = jobsearch_plugin_vars.locmap_type;
154        if (locMapType == 'mapbox') {
155            var mapbox_access_token = jobsearch_plugin_vars.mapbox_token;
156            var map_addrapi_uri = 'https://api.mapbox.com/geocoding/v5/mapbox.places/' + encodeURI(this_new_loc) + '.json?access_token=' 
156+ mapbox_access_token;
157            jobsearch_common_getJSON(map_addrapi_uri, function (new_loc_status, new_loc_response) {
158                if (typeof new_loc_response === 'object') {
159                    var new_cords = new_loc_response.features[0].geometry.coordinates;
160                    if (new_cords !== 'undefined') {
161                        jobsearch_listing_map.flyTo({
162                            center: new_cords,
163                        });
164                    }
165                }
166            });
167        }
168    }
169});
170
171jQuery(document).on('click', 'form', function () {
172    var src_loc_val = jQuery(this).find('.jobsearch_search_location_field');
173    src_loc_val.next('.loc_search_keyword').val(src_loc_val.val());
174    //
175    if (jQuery('.jobsearch-filter-keywordsrch').length > 0) {
176        var srch_keyword_val = jQuery(this).find('.jobsearch-keywordsrch-inp-field').val();
177        jQuery('.jobsearch-filter-keywordsrch').find('.jobsearch-keywordsrch-filinp-field').val(srch_keyword_val);
178        jQuery('.jobsearch-filter-keywordsrch').find('.jobsearch-keywordsrch-filinp-field').attr('value', srch_keyword_val);
179    }
180});

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.