Skip to content

Commit

Permalink
PM-730: update widget logic (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
hero-dokane authored Dec 18, 2024
1 parent 11e2133 commit 93add57
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions blocks/widget-aggregator/widget-aggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,27 @@ export default async function decorate(block) {
blockMetadata[key] = value;
}
}
const { source, script } = blockMetadata;

block.innerText = '';
block.setAttribute('id', '24petwatch-quote-form');
if (script === 'iframe') {
const frame = document.createElement('iframe');
frame.id = source;
frame.src = 'https://quote.petted.com/widget/petplace';
frame.setAttribute('loading', 'lazy');

block.innerText = '';
block.append(frame);
} else if (script === 'widget') {
block.innerText = '';
loadScript('https://quote.petted.com/Scripts/lib/widgets/petplace/quote-form/widget.min.js', { async: true }).then(() => {
if (window.QuoteEngine) {
window.QuoteEngine.setOptions({
targetId: '24petwatch-quote-form',
redirectUrl: 'https://quote.petted.com/quote',
baseUrl: 'https://quote.petted.com/',
urlParam: {
source,
utm_source: '',
utm_medium: '',
utm_campaign: '',
utm_content: '',
utm_term: '',
},
refCode: '24petwatch',
});
window.QuoteEngine.init();
}
});
} else {
block.innerText = '';
}
loadScript('https://quote.petplace.com/lib/widgets/petplace/quote-form/widget.min.js', { async: true }).then(() => {
if (window.QuoteEngine) {
window.QuoteEngine.setOptions({
targetId: '24petwatch-quote-form',
redirectUrl: 'https://quote.petplace.com/quote',
baseUrl: 'https://quote.petplace.com',
urlParam: {
source: blockMetadata.source || '',
utm_source: '',
utm_medium: '',
utm_campaign: '',
utm_content: '',
utm_term: '',
},
refCode: '24petwatch',
});
window.QuoteEngine.init();
}
});
}

0 comments on commit 93add57

Please sign in to comment.