[description]
[metaContentTemplate]Copyright � 2024 All Filters LLC. All rights reserved.
[description]
[metaContentTemplate][description]
[metaContentTemplate]'; var metaContentTemplate = ' '; var ratingReviewTemplate = '[price] [inStock]
'; searchResult.items.forEach((item, index) => { var description = ''; var thumbnailTemplate1 = thumbnailTemplate; var contentTemplate1 = contentTemplate; var searchResultTemplate1 = searchResultTemplate; var metaContentTemplate1 = metaContentTemplate; var ratingReviewTemplate1 = ratingReviewTemplate; var templateVariableList = {}; var contentTemplateItems = {}; description = item.snippet; contentTemplateItems['[title]'] = item.title; contentTemplateItems['[titleURL]'] = item.link; contentTemplateItems['[description]'] = description; if (item.pagemap != undefined) { var aggregateRating = item.pagemap.aggregaterating; if (aggregateRating != null && aggregateRating != undefined && aggregateRating.length > 0) { var ratingvalue = parseFloat(aggregateRating[0].ratingvalue); var reviewcount = aggregateRating[0].reviewcount; ratingReviewTemplate1 = ratingReviewTemplate1.replace('[rateIndex]', index); ratingReviewTemplate1 = ratingReviewTemplate1.replace('[reviewCount]', reviewcount); var ratingIndex = 0; if (ratingvalue >= 4.5) { ratingReviewTemplate1 = ratingReviewTemplate1.replace('[isChecked5]', 'checked'); } else if (ratingvalue >= 3.5 && ratingvalue < 4.5) { ratingReviewTemplate1 = ratingReviewTemplate1.replace('[isChecked4]', 'checked'); } else if (ratingvalue >= 2.5 && ratingvalue < 3.5) { ratingReviewTemplate1 = ratingReviewTemplate1.replace('[isChecked3]', 'checked'); } else if (ratingvalue >= 1.5 && ratingvalue < 2.5) { ratingReviewTemplate1 = ratingReviewTemplate1.replace('[isChecked2]', 'checked'); } else if (ratingvalue >= 0.5 && ratingvalue < 1.5) { ratingReviewTemplate1 = ratingReviewTemplate1.replace('[isChecked1]', 'checked'); } // Replace rest values with ''. for (var i = 1; i <= 5; i++) { ratingReviewTemplate1 = ratingReviewTemplate1.replace('[isChecked' + i + ']', ''); } metaContentTemplate1 = metaContentTemplate1.replace('[ratingTemplate]', ratingReviewTemplate1); contentTemplateItems['[metaContentTemplate]'] = metaContentTemplate1; } else { contentTemplateItems['[metaContentTemplate]'] = ''; } var source = (item.pagemap == undefined && item.pagemap.thumbnail == undefined) ? (item.pagemap == undefined && item.pagemap.cse_thumbnail == undefined) ? undefined : item.pagemap.cse_thumbnail : item.pagemap.thumbnail; if (source != null && source != undefined && source.length > 0) { // Replacing thumbnail. thumbnailTemplate1 = thumbnailTemplate1.replace('[imageURL]', source[0].src); templateVariableList['[thumbnailTemplate]'] = thumbnailTemplate1; // Replacing content template. Object.keys(contentTemplateItems).forEach((key) => { //console.log(key, contentTemplateItems[key]); contentTemplate1 = contentTemplate1.replace(key, contentTemplateItems[key]); }); templateVariableList['[contentTemplate]'] = contentTemplate1; templateVariableList['[contentWithoutImageTemplate]'] = ''; } else { contentTemplate1 = contentWithoutImageTemplate; // Replacing content template. Object.keys(contentTemplateItems).forEach((key) => { //console.log(key, contentTemplateItems[key]); contentTemplate1 = contentTemplate1.replace(key, contentTemplateItems[key]); }); templateVariableList['[contentTemplate]'] = ''; templateVariableList['[contentWithoutImageTemplate]'] = contentTemplate1; templateVariableList['[thumbnailTemplate]'] = ''; } // Replacing content template. Object.keys(templateVariableList).forEach((key) => { //console.log(key, templateVariableList[key]); searchResultTemplate1 = searchResultTemplate1.replace(key, templateVariableList[key]); }); finalResult += searchResultTemplate1; } }); resultSection.innerHTML = finalResult; document.querySelector('#emptySearch').style.display = 'none'; document.querySelector('#search.new').style.display = 'block'; } else { document.querySelector('#emptySearch').innerHTML = 'No result found'; } } const autocompleteHandler = (autocompleteResult) => { if (autocompleteResult.items != null) { if (autocompleteResult.items.length > 0) { var ulStart = '[title]
[description]
[title]
[description]