PageSourceSearch

https://messergroup.com/o/messergroup-theme/js/form_filling.js?t=1790248552761

js messergroup.com collected 2026-09-24 11:16:15 UTC 3,267 bytes, 114 lines download raw bytes

1function fillCustomerFields(cleanornot) {
2
3    setTimeout(function () {
4
5        var customerIdEl = document.getElementById('sapCustomerKunnr');
6        var customerNameEl = document.getElementById('sapCustomerName');
7
8        if (!customerIdEl || !customerNameEl) {
9            return;
10        }
11
12        var customerId = customerIdEl.innerText.trim();
13
14        // Remove parenthesis
15        customerId = customerId.slice(1, -1);
16
17        var customerName = customerNameEl.innerText.trim();
18
19        var customerNumField =
20            document.querySelector('input[id*="customernumberforms"]') ||
21            document.querySelector('input[id*="NumClient"]');
22
23        var customerNameField =
24            document.querySelector('input[id*="company"]') ||
25            document.querySelector('input[id*="NomClient"]');
26
27       function clearForm(form) {
28
29           form.querySelectorAll(
30                   'input:not([type="hidden"]), textarea, select'
31               ).forEach(function (field) {
32
33               // Skip Liferay hidden fields
34               if (field.closest('.HiddenDDMFormField-form-field')) {
35                   return;
36               }
37
38               if (field.type === 'checkbox' || field.type === 'radio') {
39                   field.checked = false;
40               } else {
41                   field.value = '';
42               }
43
44               field.dispatchEvent(new Event('input', { bubbles: true }));
45               field.dispatchEvent(new Event('change', { bubbles: true }));
46           });
47       }
48
49        function fillField(field, value) {
50
51            if (!field) {
52                return;
53            }
54
55            field.value = value;
56
57            // Notify Liferay/forms listeners
58            field.dispatchEvent(new Event('input', { bubbles: true }));
59            field.dispatchEvent(new Event('change', { bubbles: true }));
60
61            field.readOnly = true;
62        }
63
64        // Clear all form fields before filling customer data
65        if (cleanornot && customerNumField && customerNumField.form) {
66            clearForm(customerNumField.form);
67        }
68
69        fillField(customerNumField, customerId);
70        fillField(customerNameField, customerName);
71    }, 3000);
72
73}
74
75function waitForFields(callback, retries) {
76
77    retries = retries || 20;
78
79    var customerNumField =
80        document.querySelector('input[id*="customernumberforms"]') ||
81        document.querySelector('input[id*="NumClient"]');
82
83    var customerNameField =
84        document.querySelector('input[id*="company"]') ||
85        document.querySelector('input[id*="NomClient"]');
86
87    if (customerNumField && customerNameField) {
88        callback();
89        return;
90    }
91
92    if (retries > 0) {
93
94        setTimeout(function () {
95            waitForFields(callback, retries - 1);
96        }, 300);
97    }
98}
99
100function initCustomerFields(cleanornot) {
101    waitForFields(function () {
102        fillCustomerFields(cleanornot);
103    });
104}
105
106// Initial page load
107Liferay.on('allPortletsReady', function () {
108    initCustomerFields(true);
109});
110
111// SPA navigation / ajax rerender
112Liferay.on('endNavigate', function () {
113    initCustomerFields(false);
114});

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.