function capitalizeTheFirstLetterOfEachWord(words) { var separateWord = words.toLowerCase().split(' '); for (var i = 0; i < separateWord.length; i++) { separateWord[i] = separateWord[i].charAt(0).toUpperCase() + separateWord[i].substring(1); } return separateWord.join(' '); } function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } if($("body#home-page").length > 0){ console.log("Nosto Home"); nostojs(api => { api.defaultSession() .setResponseMode('HTML') .viewFrontPage() .setPlacements(api.placements.getPlacements()) .load() .then(data => { api.placements.injectCampaigns(data.recommendations) }) }); } if($("body.august-2022").length > 0 || $("body.Home-august-desktop-2022").length > 0){ console.log("Nosto Home"); nostojs(api => { api.defaultSession() .setResponseMode('HTML') .viewFrontPage() .setPlacements(api.placements.getPlacements()) .load() .then(data => { api.placements.injectCampaigns(data.recommendations) }) }); } if($("body#blackfriday-page").length > 0 || $("body#blackfriday-2020").length > 0){ console.log("Nosto Home Temporada"); nostojs(api => { api.defaultSession() .setResponseMode('HTML') .viewFrontPage() .setPlacements(api.placements.getPlacements()) .load() .then(data => { api.placements.injectCampaigns(data.recommendations) }) }); } if($("body#product-page").length > 0){ console.log("Nosto Product"); nostojs(api => { api.defaultSession() .setResponseMode('HTML') .viewProduct(skuJson.productId) .setPlacements(api.placements.getPlacements()) .load() .then(data => { api.placements.injectCampaigns(data.recommendations) }) }); } if($("body#grid-page").length > 0){ console.log("Nosto Grid"); var urlLocation = window.location.pathname; var myArrayLocation = urlLocation.split("/"); for(var i = 0; i < myArrayLocation.length ; i++){ myArrayLocation[i] = capitalizeFirstLetter(myArrayLocation[i].replaceAll('-', ' ')); } nostojs(api => { api.defaultSession() .setResponseMode('HTML') .viewCategory(myArrayLocation.join('/')) .setPlacements(api.placements.getPlacements()) .load() .then(data => { api.placements.injectCampaigns(data.recommendations) }) }); } if($("body.sistema.404").length > 0){ console.log("Not found"); nostojs(api => { api.defaultSession() .setResponseMode('HTML') .viewNotFound() .setPlacements(api.placements.getPlacements()) .load() .then(data => { api.placements.injectCampaigns(data.recommendations) }) }); }