/** * Function that move the DOM position of contact sales. * to fix Bug https://dev.azure.com/GDCBADE/Web%20Development/_workitems/edit/322561. */ (() => { const IDS = { OCID: 'ocid', ICID: 'icid' } const SELECTOR = { AZURE_FOOTER: '.root>.aem-Grid>.azure-footer', REIMAGINE_CONTACT_SALES: 'section#oc-contact-sales', UNIVERSAL_FOOTER: '.root>.aem-Grid>.universalfooter', ONECLOUD_CONTACT_SALES: '[data-mount="contact-sales"]', EMAIL_CONTACT_SALES_LINK: '[data-mount="contact-sales"] .contact-sales-widget:has(.glyph-prepend-mail) a' } /** * * @param {string} key * @returns {string | null} the value of the key in the query string */ function getTrackId(key) { const currentPageUrl = new URL(window.location.href.toLocaleLowerCase()); return currentPageUrl.searchParams.get(key); } // Move the contact sales section before the azure footer element function moveContactSalesBeforeFooter() { // check if there is a `.root>.aem-Grid>.azure-footer` element const azureFooterEle = document.querySelector(SELECTOR.AZURE_FOOTER); if (azureFooterEle) { const reimagineContactSalesEle = document.querySelector(SELECTOR.REIMAGINE_CONTACT_SALES); if (reimagineContactSalesEle) { // move the contact sales section before the azure footer azureFooterEle.insertAdjacentElement('beforebegin', reimagineContactSalesEle); } } // check if there is a `.root>.aem-Grid>.universalfooter` element const universalFooterEle = document.querySelector(SELECTOR.UNIVERSAL_FOOTER); if (universalFooterEle) { const onecloudContactSalesEle = document.querySelector(SELECTOR.ONECLOUD_CONTACT_SALES); if (onecloudContactSalesEle) { // move the contact sales section before the azure footer universalFooterEle.insertAdjacentElement('beforebegin', onecloudContactSalesEle); } } } function appendTrackIdToContactSales() { // append OCID and ICID to the contact sales section const emailContactSalesLink = document.querySelector(SELECTOR.EMAIL_CONTACT_SALES_LINK); if (!emailContactSalesLink) return; if (!URL.canParse(emailContactSalesLink.href)) return; const emailCSUrl = new URL(emailContactSalesLink.href); const ocId = getTrackId(IDS.OCID); const icId = getTrackId(IDS.ICID); if (ocId) { emailCSUrl.searchParams.append(IDS.OCID, ocId); } if (icId) { emailCSUrl.searchParams.append(IDS.ICID, icId); } emailContactSalesLink.href = emailCSUrl.href; } $(document).ready(function () { moveContactSalesBeforeFooter(); appendTrackIdToContactSales(); }); })();