PageSourceSearch

https://www.credit-municipal-toulouse.fr/wp-content/themes/kelkiicmt/js/script.js?v=490636

js credit-municipal-toulouse.fr collected 2026-10-05 22:56:36 UTC 15,568 bytes, 395 lines download raw bytes

1// hide ajaxload
2jQuery(document).ready(function () {
3    jQuery("#ajaxload").hide();
4});
5
6//Scroll top button fade
7jQuery(window).scroll(function(){
8    if (jQuery(this).scrollTop() > 700) {
9        jQuery('.gototop').fadeIn();
10    } else {
11        jQuery('.gototop').fadeOut();
12    }
13});
14
15jQuery(document).ready(function () {
16    jQuery("#hamburger").click(function(){
17        jQuery(this).toggleClass("is-active");
18        jQuery("#mobilemenu").slideToggle();
19        jQuery("body").toggleClass('openmenu');
20    });
21});
22
23// CMT
24jQuery(document).ready(function () {
25    var date = new Date();
26    date.setDate(date.getDate());
27    date.setMonth(date.getMonth());
28    date.setFullYear(date.getFullYear() - 18);
29
30    jQuery( ".changesitemenu" ).focus(function() {
31        jQuery('.user-menu-wrap').addClass("usopen");
32    });
33});
34
35function add_months(dt, n)
36{
37    return new Date(dt.setMonth(dt.getMonth() + n));
38}
39
40jQuery('.user-menu').on("click", function (e) {
41    jQuery('.user-menu-wrap').toggleClass("usopen");
42});
43
44jQuery('#closeusermenu').on("click", function (e) {
45    jQuery('.user-menu-wrap').toggleClass("usopen");
46});
47
48/**
49 * search
50 */
51jQuery('#btnsearch').on("click", function (e) {
52    if(jQuery('#searchformwrap').hasClass("hidethis")) {
53        jQuery('#searchformwrap').removeClass("hidethis");
54    } else {
55        if(jQuery('#search').val() == '') {
56            jQuery('#searchformwrap').addClass("hidethis");
57        } else {
58            jQuery( "#mainsearchform" ).submit();
59        }
60    }
61    jQuery('#search').focus();
62});
63jQuery('#closesearchform').on("click", function (e) {
64    jQuery('#searchformwrap').addClass("hidethis");
65});
66
67/**
68 * Simulation PSG
69 */
70jQuery('#simulpsgform input').on("change", function (e) {
71    updatePSG();
72});
73
74function updatePSG() {
75    var action = jQuery('#simulpsgform').data('action');
76    var originaction = jQuery('#simulpsgform').data('originaction');
77    var spsg_amount = jQuery('#spsg_amount').val();
78    var spsg_start_date = jQuery('#spsg_start_date').val();
79    var spsg_pay_date = jQuery('#spsg_pay_date').val();
80
81    // if not empty and something is different
82    if(spsg_amount != "" && spsg_start_date != "" && spsg_pay_date != "" && (jQuery('#histopsgstartdate').val() != spsg_start_date || jQuery('#histospsgpaydate').val() != spsg_pay_date || jQuery('#histoamount').val() != spsg_amount)) {
83        jQuery('#psgload').show();
84        jQuery('#histopsgstartdate').val(spsg_start_date);
85        jQuery('#histospsgpaydate').val(spsg_pay_date);
86        jQuery('#histoamount').val(spsg_amount);
87        jQuery('#simulpsgdata').hide();
88
89        jQuery.ajax({
90            method: "POST",
91            url: action,
92            data: {amount: spsg_amount, start_date: spsg_start_date, pay_date: spsg_pay_date, ourl: originaction}
93        })
94            .done(function (data) {
95                jQuery('#psgload').hide();
96                if(data) {
97                    html = '<div class="renderpsg"><div><strong>Détails du coût de votre prêt<br><br></strong></div>'+
98                        '<div><span>Intérêts simples</span> '+data.detail.loan+' €</div>'+
99                        '<div><span>Droit de magasinage</span> '+data.detail.keep+' €</div>';
100
101                    if(data.graph.penalties > 0) {
102                        html = html + '<div><span>Pénalités de retard</span> '+data.detail.penalties+' €</div>';
103                    }
104
105                    html = html + '<div><span>Coût total du crédit</span> '+data.detail.totalcost+' €</div>' +
106                        '<div><span>Total</span> '+data.total+' €</div>';
107                } else {
108                    html = '<p class="warning">Ce montant n\'est pas pris en compte dans cette simulation</p>';
109                }
110                jQuery('#simulpsgdata').html(html).show();
111            });
112    }
113}
114
115/**
116 * Simulation MCPA
117 */
118
119// change type
120jQuery('.inputmcpatype').on("click", function (e) {
121    var selectedTypeId = jQuery("input[name='mcpatype']:checked").val();
122
123    jQuery('.mcpatypedetails').hide();
124    jQuery('#mcpatypedetails'+selectedTypeId).show();
125    jQuery('#stepError').hide();
126});
127
128// valid type -> go to step 2
129jQuery('#mcpaValidStep1').on("click", function (e) {
130    var selectedType = jQuery("input[name='mcpatype']:checked");
131    var selectedTypeId = selectedType.val();
132    var selectedSubType = jQuery("#substypes"+selectedTypeId+" :selected");
133    var canProceed = selectedType.data('possible');
134
135    if(canProceed == 1) {
136        jQuery('#simmcpa').data('type', selectedTypeId).data('subtype', selectedSubType.val());
137        jQuery('#step1Wrap').hide().addClass('valid');
138        jQuery('#chekoutmcpa1').addClass('valid').removeClass('actif');
139        jQuery('#chekoutmcpa2').addClass('actif');
140        jQuery('#step2Wrap').show();
141        jQuery('#step1Error').hide();
142    } else if(canProceed == 0) {
143        jQuery('#step1Error').show();
144        jQuery('#step1Error').html('Ce type de projet n\'est pas éligible au microcrédit');
145    } else {
146        jQuery('#step1Error').show();
147        jQuery('#step1Error').html('Veuillez sélectionner la nature de votre projet');
148    }
149});
150
151// valid amount -> go to step 3
152jQuery('#mcpaValidStep2').on("click", function (e) {
153    var mcpaamount = jQuery("#mcpaamount");
154    var selectedAmount = mcpaamount.val();
155
156    if(selectedAmount >
156= mcpaamount.data('mcpamini') && selectedAmount <= mcpaamount.data('mcpamaxi')) {
157        jQuery('#simmcpa').data('amount', selectedAmount);
158        jQuery('#step2Wrap').hide().addClass('valid');
159        jQuery('#chekoutmcpa2').addClass('valid').removeClass('actif');
160        jQuery('#chekoutmcpa3').addClass('actif');
161        jQuery('#step3Wrap').show();
162        jQuery('#step2Error').hide();
163    } else {
164        jQuery('#step2Error').show();
165        jQuery('#step2Error').html('Le montant doit être supérieur à '+mcpaamount.data('mcpamini')+'€ et inférieur à '+mcpaamount.data('mcpamaxi')+'€');
166    }
167});
168
169// valid zipcode -> go to step 4
170jQuery('#mcpaValidStep3').on("click", function (e) {
171    var mcpazipcode = parseInt(jQuery("#code_postal").val());
172    var mcpadeptcode = parseInt(jQuery("#code_postal").val().slice(0,2)); // get only dept digits
173    var mcpacity = jQuery("#zipcity").val();
174
175    var permitedzipcodes = jQuery('#simmcpa').data('zipcodes');
176    var permiteddeptcodes = jQuery('#simmcpa').data('deptcodes');
177
178    // check if zipcode is permited in zip or dept
179    if(permitedzipcodes.includes(mcpazipcode) > 0 || permiteddeptcodes.includes(mcpadeptcode) > 0) {
180        jQuery('#simmcpa').data('zipcode', mcpazipcode).data('city', mcpacity);
181        jQuery('#step3Wrap').hide().addClass('valid');
182        jQuery('#chekoutmcpa3').addClass('valid').removeClass('actif');
183        jQuery('#chekoutmcpa4').addClass('actif');
184        jQuery('#step4Wrap').show();
185        jQuery('#step3Error').hide();
186
187        /* create html response */
188        // check if zipcode or dept
189        var html4 = '<p><strong>Votre demande entre dans le cadre du microcrédit personnel.</strong></p>';
190        // html4 += '<br>Montant : '+jQuery('#simmcpa').data('amount');
191        // html4 += '<br>type : '+jQuery('#simmcpa').data('type');
192        // html4 += '<br>subtype : '+jQuery('#simmcpa').data('subtype');
193        // html4 += '<br>zipcode : '+jQuery('#simmcpa').data('zipcode');
194        // html4 += '<br>city : '+jQuery('#simmcpa').data('city')+'<br><br>';
195
196        if(permitedzipcodes.includes(mcpazipcode) > 0) {
197            var findzip = false;
198            window.mcpajson.zipcodes.forEach(function(zipcode) {
199                if(zipcode.zipcode == mcpazipcode) {
200                    if(zipcode.structure.address3.search(mcpacity) > 0) {
201                        findzip = true;
202                    }
203                }
204            });
205
206            html4 += '<p>Merci de contacter la structure ci-dessous afin d\'étudier votre demande et monter un dossier de prêt.<br><br>';
207            html4 += '<strong>Attention</strong> : pour bénéficier d\'un microcrédit personnel, il est nécessaire de présenter les trois derniers relevés de comptes dont deux présentant un solde positif.</p><br><br>';
208
209            window.mcpajson.zipcodes.forEach(function(zipcode) {
210                if(zipcode.zipcode == mcpazipcode) {
211                    if(zipcode.structure.address3.search(mcpacity) > 0 || !findzip) {
212                        html4 += getStructureHtml(zipcode.structure);
213
214                        jQuery('#mcpamap').hide();
215                    }
216                }
217            });
218        } else {
219            window.mcpajson.deptcodes.forEach(function(deptcode) {
220                if(deptcode.code == mcpadeptcode) {
221
222                    jQuery('#mcpamap').show();
223
224                    html4 += '<p>Afin de poursuivre votre demande, merci de contacter l\'une des structures indiquée ci-dessous.</p><br><br>';
225
226                    var locations = [];
227                    deptcode.structures.forEach(function(structure) {
228                        if(structure.lat != 0) {
229                            locations.push([getStructureHtml(structure), structure.lat, structure.lng]);
230                        }
231                    });
232
233                    mapboxgl.accessToken = 'pk.eyJ1IjoidGVzdGxwZyIsImEiOiJjbTdtNmh6bTAwZzBrMm1xdDNrbjFvdDd4In0.v2SVqWCUjPqWtamgpR7J1w';
234
235                    var map = new mapboxgl.Map({
236                        container: 'mcpamap',
237                        style: 'mapbox://styles/mapbox/light-v10',
238                        zoom: 6,
239                        scrollZoom: true
240                    });
241
242                    // Controls
243                    map.addControl(new mapboxgl.NavigationControl({
244                        showCompass: false
245                    }), 'top-right');
246
247                    // Create bounds object to fit all markers
248                    var bounds = new mapboxgl.LngLatBounds();
249
250
251                    map.setCenter([1, 43]);
252
253                    // Add markers to the map
254                    locations.forEach(function(location) {
255                        var markerHtml = location[0];
256                        var lat = location[1];
257                        var lng = location[2];
258
259                        // Create popup with structure info - sans ancrage fixe
260                        var popup = new mapboxgl.Popup({
261                            offset: 25,
262                            closeButton: true,
263                            closeOnClick: true,
264                            anchor: 'auto' // Position automatique de la popup
265                        }).setHTML(markerHtml);
266
267                        // Create red marker
268                        var marker = new mapboxgl.Marker({
269                            color: '#c20e1a'
270                        })
271                            .setLngLat([lng, lat])
272                            .setPopup(popup)
273                            .addTo(map);
274
275                        // Extend bounds
276                        bounds.extend([lng, lat]);
277                    });
278
279// S'assurer que la carte s'ajuste aux limites après avoir ajouté tous les marqueurs
280                    map.fitBounds(bounds, {
281                        padding: 50
282                    });
283
284                    // Fit map to bounds
285                    if (!bounds.isEmpty()) {
286                        map.fitBounds(bounds, {
287                            padding: 50,
288                            maxZoom: 15
289                        });
290                    }
291                }
292            });
293        }
294
295        jQuery('#step4Wrapinner').html(html4);
296    } else {
297        jQuery('#step3Error').show();
298        jQuery('#step3Error').html('Votre code postal n\'est pas éligible');
299    }
300});
301
302// change MCPA step
303jQuery('#chekoutmcpa1').on("click", function (e) {if(jQuery(this).hasClass('actif') || jQuery(this).hasClass('valid')) {changeMcpaStep(1);}});
304jQuery('#chekoutmcpa2').on("click", function (e) {if(jQuery(this).hasClass('actif') || jQuery(this).hasClass('valid')) {changeMcpaStep(2);}});
305jQuery('#chekoutmcpa3').on("click", function (e) {if(jQuery(this).hasClass('actif') || jQuery(this).hasClass('valid')) {changeMcpaStep(3);}});
306jQuery('#chekoutmcpa4').on("click", function (e) {if(jQuery(this).hasClass('actif') || jQuery(this).hasClass('valid')) {changeMcpaStep(4);}});
307function changeMcpaStep(stepId) {
308    jQuery('#step1Wrap').hide().removeClass('actif');
309    jQuery('#step2Wrap').hide().removeClass('actif');
310    jQuery('#step3Wrap').hide().removeClass('actif');
311    jQuery('#step4Wrap').hide().removeClass('actif');
312
313    jQuery('#chekoutmcpa'+stepId).addClass('actif');
314    jQuery('#step'+stepId+'Wrap').show();
315    jQuery('#stepError').hide();
316}
317
318function getStructureHtml(structure) {
319    var html = '<div class="wrapstructure">';
320
321    if(structure.name) {html += '<p><strong>
321'+structure.name+'</strong></p>';}
322
323    if(structure.address) {html += '<p>'+structure.address+'</p>';}
324
325    if(structure.address2) {html += '<p>'+structure.address2+'</p>';}
326
327    if(structure.address3) {html += '<p>'+structure.address3+'</p>';}
328
329    if(structure.phone) {html += '<p>Téléphone : '+structure.phone+'</p>';}
330
331    if(structure.mail) {html += '<p>Email : '+structure.mail+'</p>';}
332
333    html += '</div>';
334
335    return html;
336}
337
338window.onload = function() {
339    // Récupération de tous les liens du site
340    const links = document.querySelectorAll("a");
341
342    // Parcours de chaque lien
343    links.forEach(link => {
344        // Vérification s'il y a un titre
345        if (!link.title) {
346            // Si pas de titre, mise à jour du titre avec le texte du lien
347            link.title = link.textContent;
348        }
349
350        // Vérification s'il y a un attribut target égal à "_blank"
351        if (link.target === "_blank") {
352            // Si oui, ajout d'un aria-label indiquant que le lien s'ouvre dans un nouvel onglet
353            link.setAttribute("aria-label", "Ouvrir le lien dans un nouvel onglet");
354        }
355    });
356};
357
358// fonction pour cacher/montrer les champs en fonction du service de saisine
359document.addEventListener('DOMContentLoaded', function() {
360    // Fonction pour gérer l'affichage conditionnel des champs
361    function setupConditionalFields() {
362        // Vérifier si le formulaire existe sur la page
363        var serviceSelect = document.getElementById('service_select');
364        if (!serviceSelect) return;
365
366        var birthdateField = document.querySelector('.birthdate-field');
367        var pdfField = document.querySelector('.pdf-field');
368
369        // Fonction pour mettre à jour l'affichage des champs
370        function toggleFields() {
371            // Les options commencent à 0, donc "Expertise" = 2-1 = 1, "Prêts personnels" = 3-1 = 2
372            var selectedIndex = serviceSelect.selectedIndex;
373
374            // Date de naissance visible uniquement pour "Prêts personnels" (index 3)
375            birthdateField.style.display = (selectedIndex === 3) ? 'block' : 'none';
376
377            // PDF visible pour "Expertise" (index 2) ou "Prêts personnels" (index 3)
378            pdfField.style.display = (selectedIndex === 2 || selectedIndex === 3) ? 'block' : 'none';
379        }
380
381        // Appliquer la logique initiale
382        toggleFields();
383
384        // Ajouter un écouteur d'événements
385        serviceSelect.addEventListener('change', toggleFields);
386    }
387
388    // Exécuter au chargement
389    setupConditionalFields();
390
391    // Réexécuter si le formulaire est rechargé via AJAX
392    document.addEventListener('wpcf7submit', function() {
393        setTimeout(setupConditionalFields, 500);
394    });
395});

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.