PageSourceSearch

https://www.clickufficio.it/Themes/Emporium/Content/scripts/ShippingGeocoding.js

js clickufficio.it collected 2026-10-08 22:55:13 UTC 3,340 bytes, 75 lines download raw bytes

1
2
3function initAutocomplete(addressIdSelector, address2IdSelctor, zipPostalCodeIdSelector, cityIdSelector, stateProvinceIdSelector) {
4   var  address1Field = document.querySelector(addressIdSelector);
5   var  address2Field = document.querySelector(address2IdSelctor);
6   var  postalField = document.querySelector(zipPostalCodeIdSelector);
7   var  cityField = document.querySelector(cityIdSelector);
8   var  stateProvinceSelector = document.querySelector(stateProvinceIdSelector);
9
10    // Create the autocomplete object, restricting the search predictions to
11    // addresses in the US and Canada.
12    var autocomplete = new google.maps.places.Autocomplete(address1Field, {
13        componentRestrictions: { country: ["it",] },
14        fields: ["address_components", "geometry"],
15        types: ["address"],
16    });
17    address1Field.focus();
18    // When the user selects an address from the drop-down, populate the
19    // address fields in the form.
20    autocomplete.addListener("place_changed", function () {
21        // Get the place details from the autocomplete object.
22        const place = autocomplete.getPlace();
23        let address1 = "";
24        let postcode = "";
25
26        // Get each component of the address from the place details,
27        // and then fill-in the corresponding field on the form.
28        // place.address_components are google.maps.GeocoderAddressComponent objects
29        // which are documented at http://goo.gle/3l5i5Mr
30        for (const component of place.address_components) {
31            const componentType = component.types[0];
32            switch (componentType) {
33
34                case "street_number": {
35                    address1 = `${component.short_name}`;
36                    break;
37                }
38                case "route": {
39                    address1 = component.short_name + ' ' + address1;
40                    break;
41                }
42                case "postal_code": {
43                    postcode = `${component.long_name}${postcode}`;
44                    break;
45                }
46                case "postal_code_suffix": {
47                    postcode = `${postcode}-${component.long_name}`;
48                    break;
49                }
50                case "administrative_area_level_3":
51                    cityField.value = component.long_name;
52                    break;
53                case "administrative_area_level_2": {
54                    $(stateProvinceSelector).find("option[data-id='" + component.short_name + "']").prop("selected", true);
55                    break;
56                }
57                //case "country":
58                //    document.querySelector("#country").value = component.long_name;
59                //    break;
60            }
61        }
62
63        address1Field.value = address1;
64        postalField.value = postcode;
65
66
67        // After filling the form with address components from the Autocomplete
68        // prediction, set cursor focus on the second address line to encourage
69        // entry of subpremise information such as apartment, unit, or floor number.
70        address2Field.focus();
71        //document.querySelector("#state").reportValidity()
72
73        //validità dei campi
74        document.querySelector(".edit-address input").reportValidity();});
75}

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.