PageSourceSearch

https://www.josepcarol.cat/wp-content/themes/fe-1.0.8/js/functions.js?ver=1772546534

js josepcarol.cat collected 2026-10-10 01:18:04 UTC 6,310 bytes, 180 lines download raw bytes

1/* global wp, jQuery */
2/**
3 * File customizer.js.
4 *
5 * Theme Customizer enhancements for a better user experience.
6 *
7 * Contains handlers to make Theme Customizer preview reload changes asynchronously.
8 */
9jQuery(document).ready(function ($) {
10    $(".filter-formacions").on("click", function (e) {
11        e.preventDefault();
12        let termsSelected = $(this).attr("data-key");
13        $('.filter-formacions').removeClass('selected');
14        $(this).addClass('selected');
15
16        updateFormacions();
17    });
18
19    function updateFormacions() {
20        var jsonTaxTerm = {};
21
22        $(".filter-formacions.selected").map(function () {
23            let taxonomy = $(this).attr("data-key");
24            jsonTaxTerm['taxonomy'] = taxonomy;
25        });
26
27        let data = {
28            'action': 'filterformacions',
29            'jsonTaxTerm': jsonTaxTerm,
30        };
31
32        $.ajax({
33            url: '/wp-admin/admin-ajax.php',
34            data: data,
35            type: 'POST',
36            beforeSend: function () {
37                $('.formacions-general').html('Carregant...');
38            },
39            success: function (data) {
40                if (data && data !== '0') {
41                    const editedText = data.slice(0, -1) //'abcde'
42                    $('.formacions-general').html(editedText);
43                } else {
44                    $('.formacions-general').html('No s\'han trobat formacions.');
45                }
46            }
47        });
48    }
49
50    $('#Contacts___fejc_escoltescatalans_c').change(function () {
51        let price = $('#price').val();
52        if ($(this).val() === 'si') {
53            $('#Accounts___name_div').css('display', 'block')
54            $('#input-entitat').css('display', 'none')
55            $('#input-federacio').css('display', 'none')
56			$('#input-federacio-altres').css('display', 'none')
57			$('#stic_Registrations___fejc_federacio_c').val('')
58            price = $('#price_escoltes').val();
59            var req_id = $('#req_id').val();
60            req_id = req_id + 'Accounts___name;';
61            $('#req_id').val(req_id);
62        } else {
63            $('#Accounts___name_div').css('display', 'none')
64            $('#input-entitat').css('display', 'block')
65            $('#input-federacio').css('display', 'block')
66            let req_id = $('#req_id').val();
67            let result = req_id.includes("Accounts___name;");
68            if (result) {
69                req_id = req_id.replace("Accounts___name;", "");
70                $('#req_id').val(req_id);
71            }
72        }
73        if (price > 0) {
74            $('#stic_Payment_Commitments___amount').val(price);
75        }
76    })
77
78    $('#stic_Registrations___fejc_federacio_c').change(function () {
79        if ($(this).val() === 'altres') {
80            $('#input-federacio-altres').css('display', 'block')
81
82        } else {
83            $('#input-federacio-altres').css('display', 'none')
84        }
85        if (price > 0) {
86            $('#stic_Payment_Commitments___amount').val(price);
87        }
88    })
89
90
91    $("#searchTerrenys").on("click", function (e) {
92        e.preventDefault();
93
94        updateTerrenys();
95    });
96
97    function updateTerrenys() {
98        var jsonTaxTerm = {};
99        const checkboxChecked = $('.serveis-booking > input:checkbox').not(this).prop('checked', this.checked);
100        $(checkboxChecked).map(function () {
101            let id = $(this).attr("id");
102            jsonTaxTerm[id] = $(this)[0].checked;
103        });
104        let num_persones = $('#num_persones').val();
105        let start_date = $('#start_date').val();
106        let end_date = $('#end_date').val();
107        jsonTaxTerm['num_persones'] = num_persones;
108        jsonTaxTerm['start_date'] = start_date;
109        jsonTaxTerm['end_date'] = end_date;
110
111
112        let data = {
113            'action': 'filterterrenys',
114            'jsonTaxTerm': jsonTaxTerm,
115        };
116
117        $.ajax({
118            url: '/wp-admin/admin-ajax.php',
119            data: data,
120            type: 'POST',
121            beforeSend: function () {
122                $('.archive-terrenys').html('Carregant...');
123            },
124            success: function (data) {
125                data = data.slice(0, -1);//remove last characters is 0
126                data = JSON.parse(data);
127                var maps = window.WPLeafletMapPlugin.maps;
128                for (var i = 0, mapslen = maps.length; i < mapslen; i++) {
129                    var map = maps[i];
130                    map.eachLayer(function (layer) {
131                        if (layer._latlng) {
132                            let show = false
133                            if (data.addresses) {
134                                data.addresses.map(function (address) {
135                                    if (roundTo(address.lat, 5) === roundTo(layer._latlng.lat, 5)
136                                        && roundTo(address.lng, 5) === roundTo(layer._latlng.lng, 5)) {
137                                        show = true;
138                                    }
139                                })
140                            }
141                            if (show) {
142                                layer._icon.style.display = 'block';
143                                layer._shadow.style.display = 'block';
144                            } else {
145                                layer._icon.style.display = 'none';
146                                layer._shadow.style.display = 'none';
147                            }
148                        }
149                    });
150                }
151                if (data.status && data.content !== '<section class="archive-terrenys"> <ul></ul></section>') {
152                    $('.archive-terrenys').html(data.content);
153                } else {
154                    $('.archive-terrenys').html('No s\'han trobat terreyns.');
155                }
156            }
157        });
158    }
159
160
161    function roundTo(n, digits) {
162        var negative = false;
163        if (digits === undefined) {
164            digits = 0;
165        }
166        if (n < 0) {
167            negative = true;
168            n = n * -1;
169        }
170        var multiplicator = Math.pow(10, digits);
171        n = parseFloat((n * multiplicator).toFixed(11));
172        n = (Math.round(n) / multiplicator).toFixed(digits);
173        if (negative) {
174            n = (n * -1).toFixed(digits);
175        }
176        return n;
177    }
178
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.