PageSourceSearch

https://www.techniques-ingenieur.fr/assets/controllers/lead_factory_free_extract_controller-i5FON73.js

js techniques-ingenieur.fr collected 2026-09-24 09:15:37 UTC 4,732 bytes, 120 lines download raw bytes

1import {Controller} from '@hotwired/stimulus'
2import {useIntersection} from 'stimulus-use'
3import $ from 'jquery';
4import 'jquery-ui';
5import {pushDataLayerEvent} from 'datalayer-event';
6import {normalizeLeadsFactoryHtml} from 'leadsfactory-html';
7import {applyCountryCityFixes} from 'leadsfactory-country-city';
8
9window.jQuery = $;
10
11/* stimulusFetch: 'lazy' */
12export default class extends Controller {
13    static values = {
14        baseUrl: String,
15        virtualDomain: String,
16        redirectUrl: String,
17        jsonFormData: Object,
18        articleId: String,
19        offer: String,
20        formName: String,
21        diName: String,
22        sector: String,
23        locale: String,
24    }
25
26    connect() {
27        useIntersection(this)
28    }
29
30    appear(entry) {
31        const baseUrl = this.baseUrlValue;
32        window.baseUrl = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
33        window.virtualDomain = this.virtualDomainValue;
34        const diName = this.diNameValue;
35        const jsonFormData = this.jsonFormDataValue ?? {};
36        const urlParams = new URLSearchParams(window.location.search);
37        const utmCampaign = urlParams.get('utm_campaign');
38        const utmSource = urlParams.get('utm_source');
39        const utmMedium = urlParams.get('utm_medium');
40        const utmTerm = urlParams.get('utm_term');
41        const utmContent = urlParams.get('utm_content');
42
43        jsonFormData.redirect_url = this.redirectUrlValue;
44
45        if (utmCampaign !== null) {
46            jsonFormData.utmcampaign = utmCampaign;
47        }
48        if (utmSource !== null) {
49            jsonFormData.utmsource = utmSource;
50        }
51        if (utmMedium !== null) {
52            jsonFormData.utmmedium = utmMedium;
53        }
54        if (utmTerm !== null) {
55            jsonFormData.utmterm = utmTerm;
56        }
57        if (utmContent !== null) {
58            jsonFormData.utmcontent = utmContent;
59        }
60
61        // Scripts to load
62        const scriptsToLoad = [
63            '/web/bundles/tellawleadsfactory/js/lf.js',
64            '/web/bundles/tellawleadsfactory/js/libs/formValidator/jquery.validationEngine.js',
65            '/web/bundles/tellawleadsfactory/js/libs/formValidator/languages/jquery.validationEngine-fr.js',
66            '/web/bundles/wekaleadsexport/js/libs/phoneformat.js',
67            `/web/client/form/twig/${this.formNameValue}?lang=${this.localeValue}`
68        ];
69
70        function loadScript(url) {
71            return $.getScript(baseUrl + url);
72        }
73
74        $.when(...scriptsToLoad.map(loadScript)).done(function () {
75            $.when(loadScript('/web/bundles/wekaleadsexport/js/ti/webcallback.js')).done(function () {
76            $(entry.target)
77                .html(normalizeLeadsFactoryHtml(leadsfactory.html))
78                .removeClass('loading-leads');
79
80            const params = jsonFormData;
81            const options = {attrReadonly: true};
82
83            // Free extract specific parameters
84            params['salutation'] = params['salutation'] || '';
85            params['lastName'] = params['lastName'] || '';
86            params['firstName'] = params['firstName'] || '';
87            params['email'] = params['email'] || '';
88            params['profil'] = params['profil'] || '';
89            params['etablissement'] = params['etablissement'] || '';
90            params['phone'] = params['phone'] || '';
91
92            params['service'] = '';
93            params['fonction'] = '';
94            params['secteur-activite'] = '';
95
96            params['pays'] = params['pays'] || '';
97            params['zip'] = params['zip'] || '';
98            params['ville_id'] = params['ville_id'] || '';
99            params['product_sku'] = params['product_sku'] || '';
100            params['product_name'] = params['product_name'] || '';
101            params['linked_content'] = params['linked_content'] || '';
102            params['thematique'] = params['thematique'] || '';
103            params['utmsource'] = params['utmsource'] || '';
104            params['utmmedium'] = params['utmmedium'] || '';
105            params['utmcontent'] = params['utmcontent'] || '';
106            params['comment'] = '';
107            params['generic_comment'] = params['generic_comment'] || '';
108            params['origin'] = '';
109            params['document_title'] = params['document_title'] || '';
110            params['fragment_url'] = params['fragment_url'] || '';
111            params['sector'] = this.sectorValue || '';
112
113            leadsfactory.init(diName, params, options);
114            applyCountryCityFixes(entry.target, {countryPrefilled: params['pays'] !== ''});
115
116            $(entry.target).one('submit', 'form', () => pushDataLayerEvent('di_extrait_submit_form'));
117            }); // webcallback.js
118        });
119    }
120}

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.