PageSourceSearch

https://www.tw.abbott/etc.clientlibs/corp/clientlibs/clientlib-cor…-f3a1d32d7c49fde00a0c428f92bfe4c7-lc.min.js

js tw.abbott collected 2026-10-08 22:04:48 UTC 14,157 bytes, 423 lines download raw bytes

1/**
2 * FORM CONTAINER
3 */
4
5/* Code for Newsletter subscription Form - Starts here */
6
7let userEmail = '';
8let consentTypes = [];
9
10/**
11 * @function
12 * Summary: Function to capture the User Email ID before ESL call
13 * Parameters: data -> payload
14 */
15
16function updateRequestNewsletterSubscription(data) {
17    toggleLoadingSpinner();
18    userEmail = data.body['email'];
19    data.body['captchaValue'] = data.body['g-recaptcha-response'];
20    delete data.body['g-recaptcha-response'];
21    delete data.body['node'];
22    return data;
23}
24
25/**
26 * @function
27 * Summary: Function to store user Email ID in session storage
28 * Parameters: data -> payload
29 */
30
31function onSuccessNewsletterSubscription(data) {
32    if (data.errorCode == 0) {
33        let redirectRequired = true;
34        setItemSessionStorage('email', userEmail);
35        if (data.response.i18nMessageKey == 'SUB001') {
36            redirectRequired = false;
37            triggerManageSubscriptionForm();
38        } else if (data.response?.subscriptions?.length) {
39            const check_concentName = $('input[name="check-consent"]').val();
40            data.response.subscriptions.forEach(function (item) {
41                if (
42                item.consentName == check_concentName &&
43                !item.consentValue
44                ) {
45                redirectRequired = false;
46                triggerManageSubscriptionForm();
47                }
48            });
49            consentTypes = data.response.subscriptions;
50        }
51        setItemSessionStorage('consentTypes', JSON.stringify(consentTypes));
52        if (redirectRequired) {
53            let redirectURL = $('.formcontainer input[name="redirect-url"]').attr('value');
54            redirectURL?.length && (globalThis.location = redirectURL);
55        }
56    } else {
57        onErrorNewsletterSubscription();
58    }
59}
60
61/**
62 * @function
63 * Summary: Function to trigger manage subscription form
64 */
65
66function triggerManageSubscriptionForm() {
67    let manageSubscriptionForm = $('#triggerFormForNewUser'); // ID to be used inside the hidden form container
68    if (manageSubscriptionForm.length) {
69        let formSubmitButton = manageSubscriptionForm.find('.o-form-container__buttons button[type="submit"]');
70        formSubmitButton.removeAttr('disabled');
71        formSubmitButton[0].click();
72    }
73}
74
75/**
76 * @function
77 * Summary: Function to remove user Email ID in session storage
78 * Parameters: data -> payload
79 */
80
81function onErrorNewsletterSubscription(error) {
82    removeItemSessionStorage('email');
83    removeItemSessionStorage('consentTypes');
84    userEmail = '';
85    consentTypes = [];
86    toggleLoadingSpinner();
87    onErrorSignup(error);
88
89}
90
91/* Code for Newsletter subscription Form - Ends here */
92
93
94/* Code for EU DPO Form - Starts here */
95
96/**
97 * @function
98 * Summary: Function to lowercase email and verify email IDs
99 * Parameters: data -> payload
100 */
101
102function updateRequestEUDPO(data) {
103    if (data.body['emailAddress']) data.body['emailAddress'] = data.body['emailAddress'].toLowerCase();
104    
105    // Find all OneTrust checkboxes within onetrustcheckbox options container and create consentList
106    let consentList = [];
107    $('.onetrustcheckbox.options fieldset input.a-checkbox__input.onetrust__input').each(function() {
108        let consentName = $(this).attr('name');
109        if (consentName && data.body[consentName] !== undefined) {
110            consentList.push({
111                consentName: consentName,
112                consentValue: data.body[consentName]
113            });
114            delete data.body[consentName];
115        }
116    });
117    
118    if (consentList.length > 0) {
119        data.body['consentList'] = consentList;
120    }
121    
122    if (data.body['verifyEmail']) data.body['verifyEmail'] = data.body['verifyEmail'].toLowerCase();
123    if (data.body.hasOwnProperty('uploaded-file') && data.body['uploaded-file'].length) {
124        data.body['Identitydocumentation'] = btoa(data.body['uploaded-file']);
125        data.body['identityDocumentName'] = $(document).find('.m-file-uploader .m-file-uploader__filedetails .m-file-uploader__name').text();
126        delete data.body['uploaded-file'];
127    } else {
128        data.body['Identitydocumentation'] = "";
129        data.body['identityDocumentName'] = "";
130        if (data.body.hasOwnProperty('uploaded-file')) delete data.body['uploaded-file'];
131    }
132    if (!data.body['Identitydocumentation'] || data.body['Identitydocumentation'] === "") {
133        delete data.body['Identitydocumentation'];
134    }
135    if (!data.body['identityDocumentName'] || data.body['identityDocumentName'] === "") {
136        delete data.body['identityDocumentName'];
137    }
138    return data;
139}
140
141/* Code for EU DPO Form - Ends here */
142
143/* Code for Sign up Form - Starts here */
144
145/**
146 * @function
147 * Summary: Function to redirect page to abbott hom page on API success
148 * Parameters: data -> payload
149 */
150
151function onsuccessSignup(data) {
152    if (data.errorCode == 0) {
153        globalThis.assign("https://www.abbott.com");
154    }
155}
156
157/* Code for Sign up Form - Ends here */
158
159/**
160 * @function
161 * Summary: Function to clear user session storage values
162 */
163
164function clearUserSessionValues() {
165    removeItemSessionStorage('email');
166    removeItemSessionStorage('consentTypes');
167}
168
169/**
170 * @function
171 * Summary: Function to parse consentTypes to object array and find individual consents
172 * data: payload
173 */
174
175function parseConsentTypesData(data) {
176    if ($($(document).find('.a-spinner')[0]).css('display') == 'none') {
177        toggleLoadingSpinner();
178    }
179    if (data.body['email']?.length == 0 && getItemSessionStorage('email')?.length > 0) {
180        data.body['email'] = getItemSessionStorage('email');
181    }
182
183    if (data?.body['consentTypes']?.length && typeof (data.body['consentTypes']) == 'string') {
184        data.body['consentTypes'] = JSON.parse(data.body['consentTypes']);
185    }
186
187    if (data.body.hasOwnProperty('EdgeNewsletter')) {
188        updateConsentTypes(data.body['consentTypes'], 'EdgeNewsletter', data.body['EdgeNewsletter']);
189        delete data.body['EdgeNewsletter'];
190    }
191
192    if (data.body.hasOwnProperty('InnovationTechnology')) {
193        updateConsentTypes(data.body['consentTypes'], 'InnovationTechnology', data.body['InnovationTechnology']);
194        delete data.body['InnovationTechnology'];
195    }
196
197    if (data.body.hasOwnProperty('HealthWellness')) {
198        updateConsentTypes(data.body['consentTypes'], 'InnovationTechnology', data.body['InnovationTechnology']);
199        data.body['consentTypes'].push({ consentName: 'HealthWellness', consentValue: data.body['HealthWellness'] });
200        delete data.body['HealthWellness'];
201    }
202
203    if (data.body.hasOwnProperty('HealthyHeart')) {
204        updateConsentTypes(data.body['consentTypes'], 'HealthyHeart', data.body['HealthyHeart']);
205        delete data.body['HealthyHeart'];
206    }
207
208    if (data.body.hasOwnProperty('DiabetesCare')) {
209        updateConsentTypes(data.body['consentTypes'], 'DiabetesCare', data.body['DiabetesCare']);
210        delete data.body['DiabetesCare'];
211    }
212
213    if (data.body.hasOwnProperty('ChronicPain')) {
214        updateConsentTypes(data.body['consentTypes'], 'ChronicPain', data.body['ChronicPain']);
215        delete data.body['ChronicPain'];
216    }
217
218    if (data.body.hasOwnProperty('ItAllAddsUpNewsletter')) {
219        updateConsentTypes(data.body['consentTypes'], 'ItAllAddsUpNewsletter', data.body['ItAllAddsUpNewsletter']);
220        delete data.body['ItAllAddsUpNewsletter'];
221    }
222    consentTypes = data.body['consentTypes'];
223    return data;
224}
225
226/**
227 * @function
228 * Summary: Function to append individual consents to main consentTypes object
229 * data: payload
230 */
231function updateConsentTypes(consentSet, newConsentName, newConsentValue) {
232    let consentIndex = consentSet.findIndex(consent => consent.consentName == newConsentName);
233    if (consentIndex == -1) {
234        consentSet.push({ consentName: newConsentName, consentValue: newConsentValue })
235    } else {
236        consentSet[consentIndex].consentValue = newConsentValue;
237    }
238}
239
240/**
241 * @function
242 * Summary: Function to remove form and replace success html for women in stem form
243 * data: response
244 */
245function onSuccessStemBlueprint(data) {
246    let formContainer = $('.modal .formcontainer');
247    formContainer.find('.o-form-container__success-msg').addClass('d-none');
248    let successHTML = formContainer.find('input[name="successMessage"]').attr('value');
249    let modalBody = formContainer.parents('.modal-body');
250    let modalFooter = formContainer.parents('.modal').find('.modal-footer');
251    if (data.errorCode == 0) {
252        modalBody.css('padding-top', '10px');
253        modalFooter.addClass('d-none');
254        formContainer.addClass('d-none');
255        formContainer.parent().append('<div class="form__success-msg">' + successHTML + '</div>');
256    }
257
258    // Click event to track if modal is closed and repopulate the form
259    formContainer.parents('.modal').off('click').on('click', function () {
260        setTimeout(function () {
261            if (!($(this).hasClass('show'))) {
262                modalBody.removeAttr('style');
263                modalFooter.removeClass('d-none');
264                formContainer.removeClass('d-none');
265                modalBody.find('.form__success-msg').remove();
266            }
267        }.bind(this), 500);
268    });
269}
270
271/**
272 * @function
273 * Summary: Function to change payload before ESL call
274 * Parameters: data -> payload
275 */
276
277function updateLikeThisCount(data) {
278    const pageURL = globalThis.pathname;
279    data.body['pageURL'] = pageURL;
280    delete data.body['g-recaptcha-response'];
281    delete data.body['node'];
282    delete data.body['requestType'];
283    return data;
284}
285function onLoadCount(data) {
286    const pageURL = globalThis.pathname;
287    let textValue = $(".a-button-corp--likebutton span").first().text();
288    localStorage.setItem('likeButtonText',textValue);
289    $(".a-button-corp--likebutton .loadCount").text("Loading...");
290    data.body['pageURL'] = pageURL;
291    data.body['pageLoad'] = true;
292    delete data.body['g-recaptcha-response'];
293    delete data.body['node'];
294    delete data.body['requestType'];
295    return data;
296}
297/**
298 * @function
299 * Summary: Function to store like count in session storage
300 * Parameters: data -> payload
301 */
302
303function updateLikeCount(data, storageKeySuffix) {
304    if (data.errorCode !== 0) return;
305
306    const { response: { count = 0 } } = data;
307    const pagePath = globalThis.pathname;
308    let likeText;
309    switch (count) {
310        case 0:
311            likeText = localStorage.getItem('likeButtonText');
312            localStorage.removeItem('likeButtonText')
313            break;
314        case 1:
315            likeText = count + " Like";
316            break;
317        default:
318            likeText = count + " Likes";
319    }
320
321    const $likeButton = $('.a-button-corp--likebutton');
322    const $counterDiv = $likeButton.next('.like-count');
323    const $countEl = $counterDiv.find('.count-number');
324
325    $countEl.text(likeText);
326    $counterDiv.addClass('visible');
327    $(".a-button-corp--likebutton .loadCount").text(likeText);
328
329    if (typeof (Storage) !== "undefined") {
330        sessionStorage.setItem(`${pagePath}${storageKeySuffix}`, "true");
331        sessionStorage.setItem(`${pagePath}:${storageKeySuffix}likeCount`, count);
332    }
333}
334
335function onSuccessLikeThis(data) {
336    updateLikeCount(data, "");
337}
338
339function onLoadLikeThis(data) {
340    updateLikeCount(data, "load");
341}
342
343/* Code to hide the like this form when dom is loading */
344document.addEventListener("readystatechange", function () {
345    if ((document.readyState == 'interactive') && document.querySelector('#like-this-form') != null) {
346        document.querySelectorAll('#like-this-form').forEach(function (node) {
347            (node.style.display != 'none') && (node.style.display = 'none');
348        });
349    }
350    if ((document.readyState == 'complete') && document.querySelector('#like-this-form') != null) {
351        document.querySelectorAll('#like-this-form').forEach(function (node) {
352            (node.style.display == 'none') && (node.style.display = '');
353        });
354    }
355});
356
357/*Push Form page data to digitalDataLayer for Form Start and Form Error*/
358function getDigitalDataLayer(evt_value, evt_label){	
359    const dt = new Date();
360    let obj = {
361        eventInfo: {
362            eventName: evt_value,
363            formName: evt_label,
364            formPage:evt_label+":"+evt_label+" form",
365            timestamp: dt
366        
367        }
368    }
369    return obj;
370}
371function getDigitalDataLayerError(evt_value, evt_label){	
372    const dt = new Date();
373    let obj = {
374        eventInfo: {
375            eventName: evt_value,
376            errorName: evt_label,
377            timestamp: dt,
378        }
379    }
380    return obj;
381}
382
383const inputField = document.querySelectorAll('input[type]');
384document.isFormInitiated=false;
385for (let i of inputField) {
386    i.addEventListener('click', onValueChange);
387}
388
389  function onValueChange() {
390    let id;
391    if(document.querySelector('[id^="formcontainer-"]').id === null){
392            id= document.getElementById("contactForm");
393    }
394    else{
395            let formEle= document.querySelector('[id^="formcontainer-"]').id;
396            id= document.getElementById(formEle);
397    }
398    
399    let formName= id.dataset.formName;
400    if(!(document.isFormInitiated) &&  id.dataset.eventTracking=='true') {
401        if(id.dataset.eventTrackingType == 'gtm' || id.dataset.eventTrackingType == 'aa' && (globalThis.__satelliteLoaded)) {
402            // GTM and AA
403            
404            let formInitiateDigitalData = getDigitalDataLayer("formStart",formName);
405            document.isFormInitiated=true;
406            globalThis.digitalData.events.push(formInitiateDigitalData);
407        } 
408    }
409    globalThis.digitalData.events= globalThis.digitalData.events.filter(x=>!x.eventPayload);
410           
411}
412function onErrorSignup(data) {
413    let statusReason = 'Something went wrong';
414    if (!(data.response== undefined || data.response == null)) {
415      if (data.response?.statusReason) {
416          statusReason = data.response.statusReason;
417      }
418    }
419    let formErrorDigitalData = getDigitalDataLayerError("formError",statusReason);
420    globalThis.digitalData.events.push(formErrorDigitalData);
421  
422}
423

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.