var ratingSnippetGlobalSettings; var ratingSnippetObserverTimeout = false; var ratingSnippetObserver = false; var ratingSnippetSkuMap = []; var ratingSnippetSkuMapChar = false; var ratingSnippetMaxReq = 7500; var ratingSnippetBatchNum = 0 function renderSnippet(rating,num_ratings,text,options){ if (num_ratings < options.minReviewCount) { return ''; } var ratingHtml = ''; decimalPlaces = options.decimalPlaces; if (decimalPlaces==null) { decimalPlaces = 2; } switch(options.mode) { case 'minimal': rating = Math.round(rating * 100) / 100; ratingHtml += ''; ratingHtml +=''+ rating.toFixed(decimalPlaces) + ''; if(options.linebreak == true){ ratingHtml += '
'; } else { ratingHtml += ''; } if(text) { ratingHtml +='' +num_ratings + text + ''; } break; case 'extended': default: roundedRating = Math.round(rating * 4)/4; for(var i=1;i<=5;i++) { if(roundedRating >= i) { ratingHtml += ''; } else if(roundedRating >= i-0.25) { ratingHtml += ''; } else if(roundedRating >= i-0.5) { ratingHtml += ''; } else if(roundedRating >= i-0.75) { ratingHtml += ''; } else { ratingHtml += ''; } } if(options.linebreak == true){ ratingHtml += '
'; } if(options.removeBrackets == true){ ratingHtml +='' +num_ratings + text + ''; } else { ratingHtml +='(' +num_ratings + text + ')'; } if(options.mode == 'extended') { ratingHtml += ''+ (Math.round(rating * 100) / 100).toFixed(decimalPlaces) + ' / '+((5).toFixed(decimalPlaces))+''; } break; } return ratingHtml; } reinitialiseRatingSnippet = function() { if(ratingSnippetGlobalSettings) { ratingSnippet(ratingSnippetGlobalSettings.class, ratingSnippetGlobalSettings.options); } } const getCompressable = function(str, array, index) { const maxChunks = 8; const plLength = ratingSnippetSkuMap.length.toString().length+2; let match = false; for (let offset = maxChunks; offset >= 0; offset--) { item = array.slice(index, index+offset).join(''); if (item.length < 6) { return false; } if (ratingSnippetSkuMap.includes(item)) { return false; } if (!str.includes(item)) { break; } matches = ((str.match(new RegExp(item.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&'), 'g')) ||[]).length); if (matches > 1) { saving = (item.length * matches) - (plLength * matches); if (saving && item.length > plLength+2 && saving > item.length) { if (!match || saving > match.saving) { match = { word: item, offset: offset, saving: saving }; } break; } } } if (match) { if (match.offset) { array.splice(index, match.offset - 1); } return match.word; } return false; } const compressSku = function(skus) { const mapChars = ['.', '_', '~', '*']; skus = skus.toLowerCase(); //find some url safe character that's not anywhere in the sku string //repeated strings are going to be replaced with eg {0, {1, etc for (let char of mapChars) { if (!skus.includes(char)) { ratingSnippetSkuMapChar = char; break; } } //if no safe character could be found then don't compress if (!ratingSnippetSkuMapChar) { return skus; } const split = skus.split(/\b|([a-z][0-9]|\d{3})/gi).filter(item => !!item); for (let i = 0; i < split.length && i<5000; i++) { const item = getCompressable(skus, split, i); if (item !== false) { const index = ratingSnippetSkuMap.indexOf(item); if (index === -1) { const newIndex = ratingSnippetSkuMap.push(item) - 1; rep = ratingSnippetSkuMapChar + newIndex.toString(36) + '*'; } else { rep = ratingSnippetSkuMapChar + index.toString(36) + '*'; } skus = skus.replace(new RegExp(item.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&'), 'gi'), rep); if (skus.length + (ratingSnippetSkuMap.length*5) < 6000) { return skus; } } } return skus; } ratingSnippet = function(ratingClassName,opts){ ratingSnippetGlobalSettings = {'class': ratingClassName, 'options': opts}; // Create new link Element let rsCssId = 'rating-snippet-stars__css'; let rsCssTag = document.getElementById(rsCssId); let rsIconUrls = [ 'https://d1azc1qln24ryf.cloudfront.net/40686/revsglobal-pr-mod/style-cf.css?ezld0b' ]; let rsIconCssFound = false; let cssLinks = document.querySelectorAll("link"); for (let index = 0; index < cssLinks.length; index++) { const cssLink = cssLinks[index]; if (cssLink.href) { rsIconUrls.forEach(href => { if (href == cssLink.href) { rsIconCssFound = true; } }); } } if (!rsCssTag && !rsIconCssFound) { rsCssTag = document.createElement('link'); rsCssTag.rel = 'stylesheet'; rsCssTag.type = 'text/css'; rsCssTag.id = rsCssId; rsCssTag.href = 'https://d1azc1qln24ryf.cloudfront.net/40686/revsglobal-pr-mod/style-cf.css?ezld0b'; document.getElementsByTagName('HEAD')[0].appendChild(rsCssTag); } if(opts == undefined){ opts = {} } if(opts.usePolaris) { let polarisId = 'rating-snippet-polaris__script'; let polarisTag = document.getElementById(polarisId); let polarisDists = [ 'https://widget.reviews.io/polaris/build.js', 'https://widget.reviews.co.uk/polaris/build.js', 'http://localhost:8080/dist/2/build.js', ]; let polarisScriptFound = false; let scripts = document.querySelectorAll("script"); for (let index = 0; index < scripts.length; index++) { const script = scripts[index]; if (script.src) { polarisDists.forEach(url => { if (url == script.src) { polarisScriptFound = true; } }); } } if (!polarisTag && !polarisScriptFound) { polarisScript = document.createElement('script'); polarisScript.type = 'text/javascript'; polarisScript.id = polarisId; polarisScript.async = true; polarisScript.src = 'https://widget.reviews.io/polaris/build.js'; document.getElementsByTagName('head')[0].appendChild(polarisScript); } } if(opts.linebreak == undefined){ opts.linebreak = false; } if (opts.removeBrackets == undefined) { opts.removeBrackets = false; } if(opts.mode == undefined){ opts.mode = false; } if(opts.color == undefined){ opts.color = '#67c116' } if(opts.textClr == undefined){ opts.textClr = '#333' } if(opts.useCustomLookup == undefined) { opts.useCustomLookup = false; } if(opts.useProductGroup == undefined) { opts.useProductGroup = false; } if(opts.mpnLookup == undefined) { opts.mpnLookup = false; } if(opts.customLookupSkuFallback == undefined) { opts.customLookupSkuFallback = false; } if(opts.showNumberDatesFormat == undefined) { opts.showNumberDatesFormat = 'dd.MM.yyyy'; } if(opts.minRating == undefined) { opts.minRating = 1; } if(opts.showNumberDates == undefined) { opts.showNumberDates = false; } if(opts.enableSyndication == undefined) { opts.enableSyndication = false; } if(opts.enableReviewerAddress == undefined){ opts.enableReviewerAddress = true; } if(opts.enableDate == undefined){ opts.enableDate = true; } //Translations if(opts.translateAverage == undefined) { opts.translateAverage = 'Average'; } if(opts.translateReviews == undefined) { opts.translateReviews = 'Reviews'; } if(opts.translateNoReviews == undefined) { opts.translateNoReviews = 'Be the first to review this product.'; } if(opts.translateMoreRatings == undefined) { opts.translateMoreRatings = 'More Ratings'; } if(opts.translateNoComments == undefined) { opts.translateNoComments = 'This review has no comments'; } if(opts.translateReplyFrom == undefined) { opts.translateReplyFrom = 'Reply From'; } if(opts.translatePosted == undefined) { opts.translatePosted = 'Posted'; } if(opts.translateWriteReview == undefined) { opts.translateWriteReview = 'Write a Review'; } if(opts.translateShow == undefined) { opts.translateShow = 'Show'; } if(opts.translateDetails == undefined) { opts.translateDetails = 'More'; } if(opts.translateRateThisProduct == undefined) { opts.translateRateThisProduct = 'Rate This Product'; } if(opts.translateSelectProduct == undefined) { opts.translateSelectProduct = 'Select Product:'; } if(opts.translateWriteReviewPlaceholder == undefined) { opts.translateWriteReviewPlaceholder = 'Write your review here'; } if(opts.translateSubmitReview == undefined) { opts.translateSubmitReview = 'Submit Review'; } if(opts.translateYourNamePlaceholder == undefined) { opts.translateYourNamePlaceholder = 'Your Name'; } if(opts.translateEmailAddressPlaceholder == undefined) { opts.translateEmailAddressPlaceholder = 'Email Address'; } if(opts.translateThankyouForYourReview == undefined) { opts.translateThankyouForYourReview = 'Thank you for your review!'; } if(opts.translateYourReviewHasBeenSubmitted == undefined) { opts.translateYourReviewHasBeenSubmitted = 'Your review has been submitted.'; } if(opts.translateReviewsCount == undefined) { opts.translateReviewsCount = 'Reviews'; } if(opts.translateVerifiedBuyer == undefined) { opts.translateVerifiedBuyer = 'Verified Buyer'; } if(opts.translateUnverifiedBuyer == undefined) { opts.translateUnverifiedBuyer = 'Unverified Buyer'; } if(opts.translateVerifiedBuyerYes == undefined) { opts.translateVerifiedBuyerYes = 'Yes'; } if(opts.translateVerifiedBuyerNo == undefined) { opts.translateVerifiedBuyerNo = 'No'; } if(opts.translateAnonymousReviewerName == undefined) { opts.translateAnonymousReviewerName = 'Anonymous'; } if(opts.enableProductName == undefined) { opts.enableProductName = false; } if(opts.formatReviewCount == undefined) { opts.formatReviewCount = false; } if(opts.formatLanguage == undefined) { opts.formatLanguage = 'en-GB'; } if(opts.lang == undefined) { opts.lang = 'en'; } if(opts.snippetPopup == undefined) { opts.snippetPopup = true; } if(opts.dataAttributeSelector == undefined) { opts.dataAttributeSelector = 'data-sku'; } var store; var sku = []; var rating_snippets = document.querySelectorAll('.'+ratingClassName); if(rating_snippets.length > 0){ for (var i = 0; i < rating_snippets.length; i++) { var snippet = rating_snippets[i]; var _sku = snippet.getAttribute(opts.dataAttributeSelector).split(';'); snippet.setAttribute('rating-snippet-batch', ratingSnippetBatchNum); sku = sku.concat(_sku); if (sku.join(';').length > ratingSnippetMaxReq) { doRatingSnippetReq([...sku], opts, ratingClassName, ratingSnippetBatchNum++); sku = []; } } } if (sku.length) { doRatingSnippetReq(sku, opts, ratingClassName, ratingSnippetBatchNum); } } const doRatingSnippetReq = function(sku, opts, ratingClassName, batch) { var xmlhttp; ratingSnippetSkuMap = []; ratingSnippetSkuMapChar = false; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { var data = JSON.parse(xmlhttp.responseText); var rating_snippets = document.querySelectorAll('.'+ratingClassName + '[rating-snippet-batch="'+batch+'"]'); if(rating_snippets.length > 0){ for(var x =0; x= 0) && addedSkus.indexOf(data[i].sku) == -1){ rating += parseFloat(data[i].average_rating) * data[i].num_ratings; num_ratings += parseFloat(data[i].num_ratings); rating_count++; addedSkus.push(data[i].sku); } } } rating = rating / num_ratings; var ratingText = (opts.text != undefined)? ' ' + opts.text : ''; if (num_ratings==1) { ratingText = (opts.singularText ? ' ' + opts.singularText : (ratingText == ' Reviews' ? ' Review' : ratingText)); } snippet.setAttribute('data-retrieved', true); if(rating_count > 0){ if (opts.formatReviewCount){ num_ratings = num_ratings.toLocaleString(opts.formatLanguage); } snippet.setAttribute('title', (Math.round(rating * 100) / 100) + ' Stars - ' + num_ratings + ratingText); snippet.innerHTML = renderSnippet(rating,num_ratings,ratingText, opts); snippet.setAttribute('data-done', true); if (window.__fullPictureEvents) { snippet.setAttribute('data-rating', rating); snippet.setAttribute('data-count', num_ratings); snippet.setAttribute('data-product-name', data[i].name); } } else if(opts.showEmptyStars) { snippet.innerHTML = renderSnippet(0,0,ratingText, opts); snippet.setAttribute('data-done', true); } var rating_snippet_texts = document.querySelectorAll('.ruk-rating-snippet-count'); if(rating_snippet_texts.length > 0){ rating_snippet_texts.forEach(function (element){ if(opts.textClr != undefined){ element.style.color = opts.textClr; } }) } if(opts.callback){ opts.callback({ data: data, rating: rating, count: rating_count }); } } } } } try { sku = [...new Set(sku)]; } catch (e) { } var _sku = (sku.join(';')); if (_sku.length>7000) { _sku = compressSku(_sku); } _sku = encodeURIComponent(_sku); if (_sku=='') { return ; } var queryString = 'sku=' + _sku + '&store=' + opts.store; if (opts.useCustomLookup) { queryString += '&useCustomLookup=' + opts.useCustomLookup; } if (opts.customLookupSkuFallback) { queryString += '&customLookupSkuFallback=' + opts.customLookupSkuFallback; } if (opts.useProductGroup) { queryString += '&useProductGroup='+ opts.useProductGroup; } if (opts.mpnLookup) { queryString += '&mpnLookup=' + opts.mpnLookup; } if (ratingSnippetSkuMap.length) { queryString += '&skumap=' + (ratingSnippetSkuMap.join(ratingSnippetSkuMapChar)); queryString += '&skumapc=' + ratingSnippetSkuMapChar; } if(opts.tag) { queryString += '&tag=' + opts.tag; } if(opts.lang){ queryString += '&lang=' + opts.lang; } if(opts.enableSyndication){ queryString += '&enableSyndication=' + opts.enableSyndication; } if(queryString.length > 8000){ xmlhttp.open('POST','https://api.reviews.co.uk/product/rating-batch',true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send(queryString); } else { xmlhttp.open('GET','https://api.reviews.co.uk/product/rating-batch?' + queryString,true); xmlhttp.send(); } var modal = document.createElement('div'); modal.innerHTML = ''; document.body.appendChild(modal); if (window.__fullPictureEvents) { window.__fullPictureEvents.addWidget('#reviews_fade #reviews_container', 'rating-snippet'); } else { if (!window.__reviewsIoWidgetList) { window.__reviewsIoWidgetList = []; } window.__reviewsIoWidgetList.push({target:'#reviews_fade #reviews_container', widget:'rating-snippet'}); } if(opts.listenForChanges && "MutationObserver" in window && !ratingSnippetObserver) { window.addEventListener('load', (event) => { ratingSnippetObserver = new MutationObserver(function(mutations) { if(ratingSnippetObserverTimeout) { clearTimeout(ratingSnippetObserverTimeout); } if(ratingSnippetGlobalSettings && document.querySelector('.'+ratingSnippetGlobalSettings.class +':not([data-retrieved])')) { ratingSnippetObserverTimeout = setTimeout(function() { reinitialiseRatingSnippet(); }, 1000); } }); ratingSnippetObserver.observe(document, {attributes: false, childList: true, characterData: false, subtree:true}); }); } var rating_snippets = document.querySelectorAll('.'+ratingClassName); if(rating_snippets.length > 0){ for(var i in rating_snippets){ var snippet = rating_snippets.item(i); if(opts.color != undefined){ snippet.style.color = opts.color; } if((typeof productWidget != 'undefined' || opts.usePolaris) && snippet.onclick == null && opts.snippetPopup){ snippet.onclick = function(event){ var sku = this.getAttribute(opts.dataAttributeSelector); if (window.__fullPictureEvents) { window.__fullPictureEvents.event('rating-snippet', 'click'); window.__fullPictureEvents.setWidgetData('rating-snippet', { product:this.getAttribute('data-product-name'), rating:this.getAttribute('data-rating'), count:this.getAttribute('data-count') }); } if (! this.getAttribute('data-done')) { return; } var root = document.getElementsByTagName( 'html' )[0]; document.getElementById('reviews_widget').innerHTML = ''; if(opts.usePolaris && typeof ReviewsWidget != "undefined") { var options = { store: opts.store, widget: 'polaris', options: { types: 'product_review', lang: opts.hasOwnProperty("lang") ? opts.lang : 'en', layout: '', enable_syndication: opts.enableSyndication, per_page: opts.polarisPerPage ? opts.polarisPerPage : 8, product_review:{ sku: sku, hide_if_no_results: false, min_rating: opts.minRating ? opts.minRating : 1, }, header:{ enable_summary: true, //Show overall rating & review count enable_ratings: true, enable_attributes: true, enable_image_gallery: true, //Show photo & video gallery enable_percent_recommended: false, //Show what percentage of reviewers recommend it enable_write_review: (opts.writeButton != undefined ? opts.writeButton : true), //Show "Write Review" button enable_ask_question: true, //Show "Ask Question" button enable_sub_header: true, //Show subheader always_show: true, }, filtering:{ enable: true, //Show filtering options enable_text_search: true, //Show search field enable_sorting: true, //Show sorting options (most recent, most popular) enable_overall_rating_filter: true, //Show overall rating breakdown filter enable_ratings_filters: true, //Show product attributes filter enable_attributes_filters: true, //Show author attributes filter }, reviews:{ enable_replies: opts.showPopupReplies, enable_avatar: true, //Show author avatar enable_reviewer_name: true, //Show author name enable_reviewer_address: opts.enableReviewerAddress, //Show author location reviewer_address_format: 'city, country', //Author location display format enable_verified_badge: true, //Show "Verified Customer" badge enable_reviewer_recommends: true, //Show "I recommend it" badge enable_attributes: true, //Show author attributes enable_product_name: true, //Show display product name enable_images: true, //Show display review photos enable_ratings: true, //Show product attributes (additional ratings) enable_share: true, //Show share buttons enable_helpful_vote: true, //Show "was this helpful?" section enable_helpful_display: true, //Show how many times times review upvoted enable_report: true, //Show report button enable_date: opts.enableDate, //Show when review was published }, }, styles: { '--base-font-size': '16px', '--common-button-font-family': 'inherit', '--common-button-font-size':'16px', '--common-button-font-weight':'500', '--common-button-letter-spacing':'0', '--common-button-text-transform':'none', '--common-button-vertical-padding':'10px', '--common-button-horizontal-padding':'20px', '--common-button-border-width':'2px', '--common-button-border-radius':'0px', '--primary-button-bg-color': '#0E1311', '--primary-button-border-color': '#0E1311', '--primary-button-text-color': '#ffffff', '--secondary-button-bg-color': 'transparent', '--secondary-button-border-color': '#0E1311', '--secondary-button-text-color': '#0E1311', '--common-star-color': opts.color, '--common-star-disabled-color': 'rgba(0,0,0,0.25)', '--medium-star-size': '22px', '--small-star-size': '19px', '--heading-text-color': '#0E1311', '--heading-text-font-weight': '600', '--heading-text-font-family': 'inherit', '--heading-text-line-height': '1.4', '--heading-text-letter-spacing': '0', '--heading-text-transform': 'none', '--body-text-color': '#0E1311', '--body-text-font-weight': '400', '--body-text-font-family': 'inherit', '--body-text-line-height': '1.4', '--body-text-letter-spacing': '0', '--body-text-transform': 'none', '--inputfield-text-font-family': 'inherit', '--input-text-font-size': '14px', '--inputfield-text-font-weight': '400', '--inputfield-text-color': '#0E1311', '--inputfield-border-color': 'rgba(0,0,0,0.2)', '--inputfield-background-color': 'transparent', '--inputfield-border-width': '1px', '--inputfield-border-radius': '0px', '--common-border-color': 'rgba(0,0,0,0.15)', '--common-border-width': '1px', '--common-sidebar-width': '190px', '--slider-indicator-bg-color': 'rgba(0,0,0,0.1)', '--slider-indicator-button-color': '#0E1311', '--slider-indicator-width': '190px', '--badge-icon-color': '#0E1311', '--badge-icon-font-size': 'inherit', '--badge-text-color': '#0E1311', '--badge-text-font-size': 'inherit', '--badge-text-letter-spacing': 'inherit', '--badge-text-transform': 'inherit', '--author-font-size': 'inherit', '--author-text-transform': 'none', '--avatar-thumbnail-size': '60px', '--avatar-thumbnail-border-radius': '100px', '--avatar-thumbnail-text-color': '#0E1311', '--avatar-thumbnail-bg-color': 'rgba(0,0,0,0.1)', '--photo-video-thumbnail-size': '80px', '--photo-video-thumbnail-border-radius': '0px', '--mediaslider-scroll-button-icon-color': '#0E1311', '--mediaslider-scroll-button-bg-color': 'rgba(255, 255, 255, 0.85)', '--mediaslider-overlay-text-color': '#ffffff', '--mediaslider-overlay-bg-color': 'rgba(0, 0, 0, 0.8))', '--mediaslider-item-size': '110px', '--pagination-tab-text-color': '#0E1311', '--pagination-tab-text-transform': 'none', '--pagination-tab-text-letter-spacing': '0', '--pagination-tab-text-font-size': '16px', '--pagination-tab-text-font-weight': '600', '--pagination-tab-active-text-color': '#0E1311', '--pagination-tab-active-text-font-weight': '600', '--pagination-tab-active-border-color': '#0E1311', '--pagination-tab-border-width': '3px', }, }; if(opts.useMpn) options.options.product_review.mpn = sku; if(opts.useCustomLookup) options.options.product_review.lookup = sku; if(opts.tag) options.options.product_review.tag = opts.tag; if(typeof ReviewsWidgetInstances != "undefined" && ReviewsWidgetInstances[Object.keys(ReviewsWidgetInstances)[0]] && typeof ReviewsWidgetInstances[Object.keys(ReviewsWidgetInstances)[0]].state == "object" && typeof ReviewsWidgetInstances[Object.keys(ReviewsWidgetInstances)[0]].state.config == "object" && typeof ReviewsWidgetInstances[Object.keys(ReviewsWidgetInstances)[0]].state.config.widget == "string" && ReviewsWidgetInstances[Object.keys(ReviewsWidgetInstances)[0]].state.config.widget == "polaris" && typeof ReviewsWidgetInstances[Object.keys(ReviewsWidgetInstances)[0]].state.config.styles == "object") { options.styles = ReviewsWidgetInstances[Object.keys(ReviewsWidgetInstances)[0]].state.config.styles; } //Overwrite polaris config - handle config if header object included if(opts.polarisStyles) { if(opts.polarisStyles.styles) { options.styles = opts.polarisStyles.styles; } else { options.styles = opts.polarisStyles; } } if(opts.polarisHeader) { if(opts.polarisHeader.header) { options.options.header = opts.polarisHeader.header; } else { options.options.header = opts.polarisHeader; } } if(opts.polarisReviews) { if(opts.polarisReviews.reviews) { options.options.reviews = opts.polarisReviews.reviews; } else { options.options.reviews = opts.polarisReviews; } } if(opts.polarisFiltering) { if(opts.polarisFiltering.filtering) { options.options.filtering = opts.polarisFiltering.filtering; } else { options.options.filtering = opts.polarisFiltering; } } new ReviewsWidget('#reviews_widget', options); } else { var options = { store: opts.store, sku: sku, css: opts.css, primaryClr: opts.color, neutralClr: "#EBEBEB", buttonClr: "#EEE", textClr: opts.textClr, tabClr: "#eee", questions: true, showTabs: false, ratingStars: false, showAvatars: true, snippetPopup: opts.snippetPopup ? opts.snippetPopup : true, minRating: opts.minRating ? opts.minRating : 1, hidePoweredBy: opts.hidePoweredBy ? opts.hidePoweredBy : false, hideLogo: opts.hideLogo ? opts.hideLogo : false, showNumberDates: opts.showNumberDates, showNumberDatesFormat: opts.showNumberDatesFormat, enableProductName: opts.enableProductName, enableDate: opts.enableDate, enableReviewerAddress: opts.enableReviewerAddress, translateAverage: opts.translateAverage, translateReviews: opts.translateReviews, translateNoReviews: opts.translateNoReviews, translateMoreRatings: opts.translateMoreRatings, translateNoComments: opts.translateNoComments, translateReplyFrom: opts.translateReplyFrom, translatePosted: opts.translatePosted, translateWriteReview: opts.translateWriteReview, translateShow: opts.translateShow, translateDetails: opts.translateDetails, translateRateThisProduct: opts.translateRateThisProduct, translateSelectProduct: opts.translateSelectProduct, translateWriteReviewPlaceholder: opts.translateWriteReviewPlaceholder, translateSubmitReview: opts.translateSubmitReview, translateYourNamePlaceholder: opts.translateYourNamePlaceholder, translateEmailAddressPlaceholder: opts.translateEmailAddressPlaceholder, translateThankyouForYourReview: opts.translateThankyouForYourReview, translateYourReviewHasBeenSubmitted: opts.translateYourReviewHasBeenSubmitted, translateReviewsCount: opts.translateReviewsCount, translateVerifiedBuyer: opts.translateVerifiedBuyer, translateUnverifiedBuyer: opts.translateUnverifiedBuyer, translateVerifiedBuyerYes: opts.translateVerifiedBuyerYes, translateVerifiedBuyerNo: opts.translateVerifiedBuyerNo, translateAnonymousReviewerName: opts.translateAnonymousReviewerName, // Translations formatReviewCount: opts.formatReviewCount ? opts.formatReviewCount : false, formatLanguage: opts.hasOwnProperty("formatLanguage") ? opts.formatLanguage : 'en-GB', lang: opts.hasOwnProperty("lang") ? opts.lang : 'en', }; if(opts.useMpn) { options.mpn = sku; } if(opts.useCustomLookup) { options.lookup = sku; } if(opts.useProductGroup) { options.productGroup = sku; } if(opts.tag) { options.tag = opts.tag; } if(opts.writeButton != undefined){ options.writeButton = opts.writeButton; } productWidget("reviews_widget", options); } document.getElementById('reviews_fade').style.display = 'block'; document.body.classList.add("reviews-popup"); root.classList.add('reviews-popup'); } } } } document.getElementById('reviews_fade').onclick = function(event){ var root = document.getElementsByTagName( 'html' )[0]; document.getElementById('reviews_fade').style.display = 'none'; document.body.classList.remove("reviews-popup"); root.classList.remove('reviews-popup'); } document.getElementById('reviews_container-close').onclick = function(){ var root = document.getElementsByTagName( 'html' )[0]; document.getElementById('reviews_fade').style.display = 'none'; document.body.classList.remove("reviews-popup"); root.classList.remove('reviews-popup'); } document.querySelector('#reviews_fade #reviews_container').onclick = function(event){ event.stopPropagation(); return false; } }; if (typeof ratingSnippetCallback == 'function') { ratingSnippetCallback(); }