Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- function getLbData() {
- var lbData = null;
- adoric.lightboxes.forEach(function(item) {
- if (item.options.campaignId === self.campaignId) {
- lbData = item;
- }
- });
- return lbData;
- }
- var form = document.querySelector('.' + self.identifier + ' [tabindex] form');
- var allCampaignData = getLbData();
- form.addEventListener('submit', function() {
- var userName = form.querySelector('INPUT[name="firstName"]');
- var email = form.querySelector('INPUT[name="emailAddress"]');
- var checkBoxField = form.querySelector('INPUT[type="checkbox"]');
- userName ? userName = userName.value : userName = '';
- email ? email = email.value : email = '';
- checkBoxField ? checkBoxField = checkBoxField.value : checkBoxField = '';
- var data = {
- subscribe: {
- email: email,
- newsletterapproved: checkBoxField,
- firstname: userName,
- adoricApiKey: '1621416163064',
- userId: '5e4ea052e98c750012b2c583',
- header: '{}'
- },
- referrer: document.referrer,
- country: sessionStorage.getItem('country_code_cache'),
- action: 'https://us-east4-adoric-production.cloudfunctions.net/Support_chef_lavan_integration',
- enctype: '#',
- method: 'GET',
- campaignData: {
- options: {
- id: allCampaignData.id,
- userId: allCampaignData.options.userId,
- domainId: "5e66050a27c6d400185bf304",
- accountId: allCampaignData.options.userId,
- campaignTitle: allCampaignData.options.campaignTitle,
- title: allCampaignData.options.title,
- type: allCampaignData.options.type
- }
- }
- };
- var xhr = new XMLHttpRequest();
- xhr.addEventListener('readystatechange', function() {
- if (this.readyState === 4) {
- console.log('response - ', this.responseText);
- }
- });
- xhr.open('POST', 'https://app.adoric-om.com/v1/forms/webhook');
- xhr.setRequestHeader('cache-control', 'no-cache');
- xhr.send(JSON.stringify(data));
- });
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment