PageSourceSearch

https://auser.it/wp-content/themes/auser-wp/assets/js/sedi.js?ver=054b47c45361275afd6fe84fd2bd2974

js auser.it collected 2026-10-02 07:15:24 UTC 6,561 bytes, 177 lines download raw bytes

1var IS_HEADQUARTER_SEARCHING = false;
2
3jQuery(document).ready(() => {
4
5    if(jQuery('#region-search-input').length > 0)
6        initHeadquartersSearch();
7
8    
9    if(jQuery('#map').length > 0) {
10        // searchRegions("0");
11        searchHeadquarters("0");
12        map = L.map('map').setView([41.8719, 12.5674], 6);
13
14        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
15    }
16    
17});
18
19function initHeadquartersSearch() {
20    jQuery('#region-search-input').on('input', function(ev) {
21        const debouncedSearch = debounce(function () {
22            searchHeadquarters(jQuery('#region-search-input').val());
23        }, 500);
24
25        jQuery('#region-search-input').on('input', debouncedSearch);
26    });
27}
28
29function debounce(func, delay) {
30    let timer;
31    return function(...args) {
32        clearTimeout(timer);
33        timer = setTimeout(() => {
34            func.apply(this, args);
35        }, delay);
36    };
37}
38
39function searchHeadquarters(searchTerm = '') {
40
41    console.log(searchTerm, IS_HEADQUARTER_SEARCHING);
42
43    if(IS_HEADQUARTER_SEARCHING)
44        return;
45
46    IS_HEADQUARTER_SEARCHING = true;
47
48    searchTerm = searchTerm.trim();
49    
50    if(searchTerm.length < 3) {
51        let nSediOld = jQuery('#n-result').attr('data-old');
52        jQuery('#n-result').text(nSediOld + " sedi per la ricerca");
53
54        jQuery('#search-results').html('');
55
56        jQuery('.region-card').each(function() {    
57            jQuery(this).show();
58        });
59
60        IS_HEADQUARTER_SEARCHING = false;
61
62        searchTerm = null;
63    }
64    
65    jQuery.ajax({
66        url: ajax.ajax_url,
67        type: 'GET',
68        dataType: "json",
69        data: {
70            action: 'search_regions_meta',
71            search: searchTerm,
72        },
73        success: function(response) {
74            if(response.success == true) {
75
76                if(response.data.municipal) {
77                    setMapView(response.data.coords.lat, response.data.coords.lon);
78                }
79
80                const results = response.data.results;
81
82                
83                if(results.length === 0) {
84                    IS_HEADQUARTER_SEARCHING = false;
85                    console.log('Nessun risultato trovato.');
86                    return;
87                }
88
89                if(map)
90                    map.remove();
91
92                map = L.map('map', {minZoom: 6, maxBounds: [
93                    [35.5, 5.5], [47.5, 19.0]
94                ],
95                maxBoundsViscosity: 1.0}).setView([41.8719, 12.5674], 6);
96
97                L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
98
99                const markerCluster = L.markerClusterGroup();
100                var nSedi = 0;
101
102                results.forEach(post => {
103                    var slug = post.meta.regione
104                        .toLowerCase()
105                        .normalize("NFD").replace(/[\u0300-\u036f]/g, "")
106                        .replace(/[^\w\s-]/g, '')
107                        .trim()
108                        .replace(/\s+/g, '-');
109
110                    if (searchTerm) {
111                        jQuery('.region-card').each(function () {
112                            var region = jQuery(this).data('region').toLowerCase();
113                            if (region == slug) {
114                                jQuery(this).show();
115                            } else {
116                                jQuery(this).hide();
117                            }
118                        });
119                    }
120
121                    var icon = L.icon({
122                        iconUrl: 'data:image/svg+xml;charset=UTF-8,' + encodeURIComponent(`
123                        <svg xmlns="http://www.w3.org/2000/svg" width="25" height="41" viewBox="0 0 25 41">
124                            <path d="M12.5 0C5.596 0 0 5.596 0 12.5C0 19.404 12.5 41 12.5 41S25 19.404 25 12.5C25 5.596 19.404 0 12.5 0Z" fill="#3aaa36"/>
125                            <circle cx="12.5" cy="12.5" r="5.5" fill="${post.meta.tipo_sede != 'regionale' ? 'white' : 'red'}"/>
126                        </svg>
127                        `),
128                        iconSize: [25, 41],
129                        iconAnchor: [12.5, 41],
130                        popupAnchor: [0, -41]
131                    });
132
133                    console.log(post);
134                    
135
136                    const marker = L.marker([post.meta.latitudine, post.meta.longitudine], { icon: icon })
137                        .bindPopup(`
138                            <b class="mb-5">${post.title}</b><br>
139                            ${post.meta.email && post.meta.email !== 'null' && post.meta.email != 'NULL'? `<p>Email: ${post.meta.email}</p>` : ''}
140                            ${post.meta.telefono && post.meta.telefono !== 'null' ? `<p>Telefono: ${post.meta.telefono}</p>` : ''}
141                            ${post.meta.indirizzo && post.meta.indirizzo !== 'null' ? `<p>Indirizzo: ${post.meta.indirizzo}${post.meta.civico && post.meta.civico !== 'null' ? ' ' + post.meta.civico : ''}${post.meta.cap && post.meta.cap !== 'null' ? ', ' + post.meta.cap : ''}${post.meta.comune && post.meta.comune !== 'null' ? ', ' + post.meta.comune : ''}</p>` : ''}
142                        `);
143
144                    markerCluster.addLayer(marker);
145                    nSedi++;
146                });
147
148                map.addLayer(markerCluster);
149                map.fitBounds(markerCluster.getBounds(), { padding: [30, 30] });
150
151                if(results[0].lat) {
152                    map.setView([results[0].lat, results[0].lon], 10);
153                } else {
154                    if(!searchTerm) {
155                        map.setView([41.8719, 12.5674], 5);
156                    } else {
157                        map.setView([results[0].meta.latitudine, results[0].meta.longitudine], 8);
158                    }
159                }
160
161
162                jQuery('#n-result').text(nSedi + " sedi per la ricerca");
163                jQuery('#search-results').addClass('d-none');
164                IS_HEADQUARTER_SEARCHING = false;
165            } else {
166                IS_HEADQUARTER_SEARCHING = false;
167                jQuery('#n-result').toggleClass('d-none');
168                jQuery('#search-results').html('<div class="alert alert-info text-center">Nessun risultato trovato per "' + searchTerm + '"</div>');
169                jQuery('#search-results').toggleClass('d-none');
170            }
171        },
172        error: function(xhr, status, error) {
173            console.error('Errore AJAX:', error);
174            IS_HEADQUARTER_SEARCHING = false;
175        }
176    });
177}

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.