PageSourceSearch

https://www.techniques-ingenieur.fr/assets/controllers/lead_factory_controller-FpqpN5G.js

js techniques-ingenieur.fr collected 2026-10-02 11:26:03 UTC 3,063 bytes, 83 lines download raw bytes

1import {Controller} from '@hotwired/stimulus'
2import {useIntersection} from 'stimulus-use'
3import $ from 'jquery';
4import 'jquery-ui';
5import {normalizeLeadsFactoryHtml} from 'leadsfactory-html';
6
7// Utile pour les bibliothèques importées qui ont besoin de Jquery en tant que variable globale.
8window.jQuery = $;
9
10/* stimulusFetch: 'lazy' */
11export default class extends Controller {
12    static values = {
13        baseUrl: String,
14        virtualDomain: String,
15        redirectUrl: String,
16        jsonFormData: Object,
17        locale: String,
18    }
19
20    connect() {
21        useIntersection(this)
22    }
23
24    appear(entry) {
25        const baseUrl = this.baseUrlValue;
26        window.baseUrl = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
27        window.virtualDomain = this.virtualDomainValue;
28        const jsonFormData = this.jsonFormDataValue ?? {};
29        const urlParams = new URLSearchParams(window.location.search);
30        const utmCampaign = urlParams.get('utm_campaign');
31        const utmSource = urlParams.get('utm_source');
32        const utmMedium = urlParams.get('utm_medium');
33        const utmTerm = urlParams.get('utm_term');
34        const utmContent = urlParams.get('utm_content');
35
36        jsonFormData.redirect_url = this.redirectUrlValue;
37
38        if (utmCampaign !== null) {
39            jsonFormData.utmcampaign = utmCampaign;
40        }
41        if (utmCampaign !== null) {
42            jsonFormData.utmsource = utmSource;
43        }
44        if (utmCampaign !== null) {
45            jsonFormData.utmmedium = utmMedium;
46        }
47        if (utmCampaign !== null) {
48            jsonFormData.utmterm = utmTerm;
49        }
50        if (utmCampaign !== null) {
51            jsonFormData.utmcontent = utmContent;
52        }
53
54        // Liste des scripts à charger
55        const scriptsToLoad = [
56            '/web/bundles/tellawleadsfactory/js/lf.js',
57            '/web/bundles/wekaleadsexport/js/libs/phoneformat.js',
58            '/web/bundles/tellawleadsfactory/js/libs/formValidator/jquery.validationEngine.js',
59            '/web/bundles/tellawleadsfactory/js/libs/formValidator/languages/jquery.validationEngine-en.js',
60            `/web/client/form/twig/ti_en_contact?lang=${this.localeValue}`
61        ];
62
63        // Fonction pour charger les scripts de manière asynchrone
64        function loadScript(url) {
65            return $.getScript(baseUrl + url);
66        }
67
68        // Charger tous les scripts de manière asynchrone
69        $.when(...scriptsToLoad.map(loadScript)).done(function () {
70            $.when(loadScript('/web/bundles/wekaleadsexport/js/ti/webcallback.js')).done(function () {
71            // Insérer le contenu du formulaire
72            $(entry.target)
73                .html(normalizeLeadsFactoryHtml(leadsfactory.html))
74                .removeClass('loading-leads');
75
76            // Initialiser le formulaire
77            const params = jsonFormData;
78            const options = {attrReadonly: true};
79            leadsfactory.init('ti_en_contact', params, options);
80            }); // webcallback.js
81        });
82    }
83}

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.