Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- const currentLB = document.querySelector('.' + self.identifier + '.__ADORIC__ [tabindex]');
- function sendAdoricLead() {
- try {
- const inputs = currentLB.querySelectorAll('form input');
- const inputsData = {};
- Array.from(inputs).forEach(i => {
- const name = i.getAttribute('name');
- if (name !== 'submit') {
- inputsData[name] = currentLB.querySelector('INPUT[name="' + name + '"]').value;
- }
- });
- var currentCampaign = adoric.lightboxes.filter(function(lb) {
- return lb.id === self.versionId
- })[0];
- var data = {
- subscribe: inputsData,
- referrer: document.referrer,
- campaignData: {
- options: {
- id: self.versionId,
- userId: currentCampaign.options.userId,
- domainId: self.domainId,
- campaignId: currentCampaign.options.campaignId,
- accountId: currentCampaign.options.userId,
- campaignTitle: self.campaignTitle,
- title: self.versionTitle,
- type: currentCampaign.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/leads/subscribe', true);
- xhr.send(JSON.stringify(data));
- } catch (error) {
- console.log(error);
- }
- }
- const form = currentLB.querySelector('form');
- form.addEventListener('submit', () => {
- sendAdoricLead();
- });
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement