diff --git a/blocks/applyloanform/applyloanform.js b/blocks/applyloanform/applyloanform.js index a08c9bb5e6..ebf0091800 100644 --- a/blocks/applyloanform/applyloanform.js +++ b/blocks/applyloanform/applyloanform.js @@ -7,7 +7,7 @@ import { validationJSFunc } from './validation.js'; import AirDatepicker from '../datepickerlib/datepickerlib.js'; import Popper from '../datepickerlib/popper.js'; import { buttonCLick } from './loanformapi.js'; -import { fetchAPI } from '../../scripts/scripts.js'; +import { CFApiCall, fetchAPI } from '../../scripts/scripts.js'; export default async function decorate(block) { const cfURL = block.textContent.trim(); @@ -32,13 +32,6 @@ export default async function decorate(block) { } } -export async function CFApiCall(cfurl) { - const response = await fetchAPI('GET', cfurl); - const responseJson = await response.json(); - return responseJson; -} - - function applyLoanFormJson(data) { var mainObj = {}; diff --git a/blocks/aprcalculator/aprcalculator.js b/blocks/aprcalculator/aprcalculator.js index de80e6f90d..620b3829f3 100644 --- a/blocks/aprcalculator/aprcalculator.js +++ b/blocks/aprcalculator/aprcalculator.js @@ -1,13 +1,13 @@ -import { fetchAPI } from '../../scripts/scripts.js'; +import { calculatorFlatStrLogic, CFApiCall, fetchAPI } from '../../scripts/scripts.js'; import { homeLoanCalcFunc } from '../emiandeligiblitycalc/homeloancalculators.js'; import { homeloanCalHTML } from '../homeloancalculatorv2/templatehtmlv2.js'; export default async function decorate(block) { const cfURL = block.textContent.trim(); - const cfRepsonse = await CFApiCall(cfURL); - const repsonseData = cfRepsonse.data[0].data; - const jsonResponseData = JSON.parse(repsonseData); + const cfRepsonse = cfURL && await CFApiCall(cfURL); + const repsonseData = cfRepsonse.data; + const jsonResponseData = calculatorFlatStrLogic(repsonseData); block.innerHTML = homeloanCalHTML(jsonResponseData); @@ -34,12 +34,6 @@ export default async function decorate(block) { } } -export async function CFApiCall(cfurl) { - const response = await fetchAPI('GET', cfurl); - const responseJson = await response.json(); - return responseJson; -} - function onloadAPRCalc() { const isAprCalculator = document.querySelector('.homeloancalculator .apr'); if (isAprCalculator) { diff --git a/blocks/authorisedagencies/authorisedagencies.js b/blocks/authorisedagencies/authorisedagencies.js index 8f3dae5ae4..9439abb6d1 100644 --- a/blocks/authorisedagencies/authorisedagencies.js +++ b/blocks/authorisedagencies/authorisedagencies.js @@ -1,9 +1,9 @@ -import { fetchAPI, targetObject } from '../../scripts/scripts.js'; +import { CFApiCall, fetchAPI, targetObject } from '../../scripts/scripts.js'; import { ctaClickInteraction } from '../../dl.js'; export default async function decorate(block) { const cfURL = block.textContent.trim(); - const cfRepsonse = await fetchApiCall(cfURL); + const cfRepsonse = await CFApiCall(cfURL); const repsonseData = cfRepsonse.data; const result = Object.groupBy(repsonseData, ({ Location }) => { const lowercaseLocation = Location.toLowerCase(); @@ -158,8 +158,3 @@ export default async function decorate(block) { // }) }; } -export async function fetchApiCall(cfurl) { - const response = await fetchAPI('GET', cfurl); - const responseJson = await response.json(); - return responseJson; -} diff --git a/blocks/branchcarousel/branchcarousel.js b/blocks/branchcarousel/branchcarousel.js index 07e0bc0156..d3f10b7a4c 100644 --- a/blocks/branchcarousel/branchcarousel.js +++ b/blocks/branchcarousel/branchcarousel.js @@ -1,4 +1,4 @@ -import { fetchAPI } from '../../scripts/scripts.js'; +import { CFApiCall, fetchAPI } from '../../scripts/scripts.js'; import { setLocationObj } from '../moredetailsaddress/moredetailsaddress.js'; export default async function decorate(block) { @@ -25,8 +25,3 @@ export default async function decorate(block) { block.classList.add('dp-none'); } -export async function CFApiCall(linkURL) { - const response = await fetchAPI('GET', linkURL); - const responseJson = await response.json(); - return responseJson; -} diff --git a/blocks/branchkeyfeatures/branchkeyfeatures.js b/blocks/branchkeyfeatures/branchkeyfeatures.js index ba1b290d1a..5f4d9961a4 100644 --- a/blocks/branchkeyfeatures/branchkeyfeatures.js +++ b/blocks/branchkeyfeatures/branchkeyfeatures.js @@ -1,4 +1,4 @@ -import { fetchAPI } from '../../scripts/scripts.js'; +import { CFApiCall, fetchAPI } from '../../scripts/scripts.js'; import { featureDropDownClick } from '../keyfeatures/keyfeatures.js'; import { setLocationObj } from '../moredetailsaddress/moredetailsaddress.js'; @@ -52,9 +52,3 @@ export default async function decorate(block) { block.classList.add('dp-none'); } - -export async function CFApiCall(linkURL) { - const response = await fetchAPI('GET', linkURL); - const responseJson = await response.json(); - return responseJson; -} diff --git a/blocks/branchlocator/branchlocator-biz.js b/blocks/branchlocator/branchlocator-biz.js index 0121a9b976..ca4bfc2ae6 100644 --- a/blocks/branchlocator/branchlocator-biz.js +++ b/blocks/branchlocator/branchlocator-biz.js @@ -107,6 +107,11 @@ async function getStateCity(lat, lng) { setLocationObj.geoInfo.city = city.long_name; setLocationObj.geoInfo.state = region.long_name; setLocationObj.geoInfo.country = country.long_name; + + /* setLocationObj.getExcelData[region.long_name].filter((each) => { + return each['Location'].includes(city.long_name); + }); */ + resolve(); } else { reject('No results found'); diff --git a/blocks/branchlocator/branchlocator.js b/blocks/branchlocator/branchlocator.js index 1b906f803f..b53768703c 100644 --- a/blocks/branchlocator/branchlocator.js +++ b/blocks/branchlocator/branchlocator.js @@ -1,4 +1,4 @@ -import { branchURLStr, fetchAPI } from '../../scripts/scripts.js'; +import { branchURLStr, CFApiCall, fetchAPI } from '../../scripts/scripts.js'; import { dropDownStateCity, locateMeClick, onloadBranchLocator } from './branchlocator-biz.js'; import { setLocationObj } from './branchlocator-init.js'; @@ -93,12 +93,6 @@ export function innerBranchFunc(branchhList) { return innerBranch; } -export async function CFApiCall(cfurl) { - const response = await fetchAPI('GET', cfurl); - const responseJson = await response.json(); - return responseJson; -} - export default async function decorate(block) { const props = Array.from(block.children, (row) => row.firstElementChild); diff --git a/blocks/breadcrumb/breadcrumb.js b/blocks/breadcrumb/breadcrumb.js index df3465490a..ceb1401996 100644 --- a/blocks/breadcrumb/breadcrumb.js +++ b/blocks/breadcrumb/breadcrumb.js @@ -73,7 +73,7 @@ export default async function decorate(block) { 'aria-label': 'Breadcrumb', }); - if (multiText && multiUrl) { + if (multiText.innerText?.trim() && multiUrl.innerText?.trim()) { const breadcrumbsText = []; const multiUrls = multiUrl.innerText.trim().replace(/~/g, '/').split(','); multiText.innerText.trim().split(',').forEach((text, index) => { diff --git a/blocks/calculatorsection/calculatorsection.js b/blocks/calculatorsection/calculatorsection.js index 75fbf7bb75..9f5a8e3195 100644 --- a/blocks/calculatorsection/calculatorsection.js +++ b/blocks/calculatorsection/calculatorsection.js @@ -1,4 +1,4 @@ -import { fetchAPI } from '../../scripts/scripts.js'; +import { calculatorFlatStrLogic, CFApiCall, fetchAPI } from '../../scripts/scripts.js'; import { homeLoanCalcFunc } from '../emiandeligiblitycalc/homeloancalculators.js'; import { renderCalculatorData } from './renderdatafunc.js'; import { homeloanCalHTML } from '../homeloancalculatorv2/templatehtmlv2.js'; @@ -6,9 +6,9 @@ import { homeloanCalHTML } from '../homeloancalculatorv2/templatehtmlv2.js'; export default async function decorate(block) { const cfURL = block.textContent.trim(); - const cfRepsonse = await CFApiCall(cfURL); - const repsonseData = cfRepsonse.data[0].data; - const jsonResponseData = JSON.parse(repsonseData); + const cfRepsonse = cfURL && await CFApiCall(cfURL); + const repsonseData = cfRepsonse.data; + const jsonResponseData = calculatorFlatStrLogic(repsonseData); block.innerHTML = homeloanCalHTML(jsonResponseData); @@ -39,12 +39,6 @@ export default async function decorate(block) { } } -export async function CFApiCall(cfurl) { - const response = await fetchAPI('GET', cfurl); - const responseJson = await response.json(); - return responseJson; -} - export function readMoreFucn(block) { document.querySelector('.discalimer-details').classList.remove('dp-none'); if (block.querySelector('.discalimer-calc')) { diff --git a/blocks/code/code.js b/blocks/code/code.js index 631a1183d0..9a7bfce353 100644 --- a/blocks/code/code.js +++ b/blocks/code/code.js @@ -1,5 +1,5 @@ import { decorateIcons } from "../../scripts/aem.js"; -import { decoratePlaceholder } from "../../scripts/scripts.js"; +import { decodeHtmlSymbols, decoratePlaceholder } from "../../scripts/scripts.js"; import { mobileHeaderAnalytics } from "./code-analytics.js"; import { decorateTable } from "./table.js"; export default async function decorate(block) { @@ -9,7 +9,7 @@ export default async function decorate(block) { decorateTable(block) return block } - const titleData = block.children[0]?.querySelector('p')?.innerHTML.trim().replaceAll('<', '<').replaceAll('>', '>') || ''; + const titleData = decodeHtmlSymbols(block.children[0]?.querySelector('p')?.innerHTML.trim() || ''); block.innerHTML = ''; if (titleData) { const titleElement = document.createElement('div'); diff --git a/blocks/gstcalculator/gstcalculator.js b/blocks/gstcalculator/gstcalculator.js index 22fdbed604..f390cdaf71 100644 --- a/blocks/gstcalculator/gstcalculator.js +++ b/blocks/gstcalculator/gstcalculator.js @@ -1,18 +1,17 @@ -import { currenyCommaSeperation, fetchAPI } from '../../scripts/scripts.js'; +import { calculatorFlatStrLogic, CFApiCall, currenyCommaSeperation, fetchAPI } from '../../scripts/scripts.js'; import { homeLoanCalcFunc } from '../emiandeligiblitycalc/homeloancalculators.js'; import { homeloanCalHTML } from '../homeloancalculatorv2/templatehtmlv2.js'; export default async function decorate(block) { const cfURL = block.textContent.trim(); - const cfRepsonse = await CFApiCall(cfURL); - const repsonseData = cfRepsonse.data[0].data; - const jsonResponseData = JSON.parse(repsonseData); + const cfRepsonse = cfURL && await CFApiCall(cfURL); + const repsonseData = cfRepsonse.data; + const jsonResponseData = calculatorFlatStrLogic(repsonseData); block.innerHTML = homeloanCalHTML(jsonResponseData); - let elgCalDiv; let - elgOverlay; +let elgCalDiv; let elgOverlay; try { elgCalDiv = document.querySelector('.home-page-calculator-call-xf'); @@ -34,11 +33,6 @@ export default async function decorate(block) { } } -export async function CFApiCall(cfurl) { - const response = await fetchAPI('GET', cfurl); - const responseJson = await response.json(); - return responseJson; -} function onloadGSTCalc() { const isGstCalculator = document.querySelector('.homeloancalculator .gst'); diff --git a/blocks/homeloancalculatorv2/homeloancalculatorv2.js b/blocks/homeloancalculatorv2/homeloancalculatorv2.js index a098af1c2e..cdcfc34455 100644 --- a/blocks/homeloancalculatorv2/homeloancalculatorv2.js +++ b/blocks/homeloancalculatorv2/homeloancalculatorv2.js @@ -3,17 +3,16 @@ import { firstTabActive } from "./commonfile.js"; */ import { homeloanCalHTML } from './templatehtmlv2.js'; import { homeLoanCalcFunc } from './homeloancalculators.js'; import { calculatorTypeTabClick, mainTabClick, renderEmiEligibility } from './combineemieligibility.js'; -import { fetchAPI } from '../../scripts/scripts.js'; +import { calculatorFlatStrLogic, CFApiCall, fetchAPI } from '../../scripts/scripts.js'; -let calculatorType; let emiCalDiv; let - emiOverlay; +let calculatorType; let emiCalDiv; let emiOverlay; export default async function decorate(block) { const cfURL = block.textContent.trim(); const cfRepsonse = cfURL && await CFApiCall(cfURL); - const repsonseData = cfRepsonse && cfRepsonse.data[0].data; - const jsonResponseData = repsonseData && JSON.parse(repsonseData); + const repsonseData = cfRepsonse.data; + const jsonResponseData = calculatorFlatStrLogic(repsonseData); if (!jsonResponseData) return; @@ -63,12 +62,6 @@ export default async function decorate(block) { } } -export async function CFApiCall(cfurl) { - // const cfModification = cfurl?.replace("/content/dam/", "/api/assets/"); - const response = await fetchAPI('GET', cfurl); - const responseJson = await response.json(); - return responseJson; -} /* export function homeLoancalculatorCallXf() { document.querySelectorAll("[data-teaserv2-xf='home-page-calculator-call-xf']") && diff --git a/blocks/homeloancalculatorv2/templatehtmlv2.js b/blocks/homeloancalculatorv2/templatehtmlv2.js index 1f698861e0..4d2d6d66a8 100644 --- a/blocks/homeloancalculatorv2/templatehtmlv2.js +++ b/blocks/homeloancalculatorv2/templatehtmlv2.js @@ -7,7 +7,7 @@ export function homeloanCalHTML(callJson) { buttonLink2 = callJson.button2link.replace('DWEB', 'MWEB'); } - const salaried = callJson.salaried?.salariedcheck + const salaried = callJson.salaried?.salariedcheck == 'true' ? `