(function (w, d) { var businessKey = "1i2horx3"; var locationKey = "aj029326"; var tenantKey = ""; var tag = ""; var accessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbnRpdHlJZCI6ImFqMDI5MzI2IiwiZXhwIjoxNzMwNDI4MTM3LCJpc3MiOiJUcnVzdGlzdCIsImF1ZCI6IldpZGdldHMifQ.slavPu7SCscNFQqGzq6TjRic2GJMiO-et7ONHvxIPVg"; var templates = { main: '
', noborder: '
', }; var responsiveTemplate = '
'; var footer = '
Trustist
'; function start(f) { /in/.test(document.readyState) ? setTimeout(start, 5, f) : f(); } // add tags tsAddCssTag("https://wassets.trustist.com/assets/css/cleanslate.css"); tsAddCssTag("https://wassets.trustist.com/assets/css/reviewslider.css"); start(function () { // iterate over all widgets on the page and render var divs = d.querySelectorAll("[ts-reviewSliderWidget],div.ts-reviewSliderWidget"); if (divs.length === 0) { return; } for (var i = 0; i < divs.length; i++) { tsDisplayWidget(divs[i], tenantKey, businessKey, locationKey, tag); } }); function tsDisplayWidget(target, tenantKey, businessKey, locationKey, tag) { // get options before cleanslate var options = tsReadAttributes(target); var template = templates[options.templateName]; // see if the widget requested a different location var lkey = options.locationKey || locationKey; var bkey = options.businessKey || businessKey; var tkey = options.tenantKey || tenantKey; var tagkey = options.tag || tag; // introduce js/css for responsive version if (options.responsive === "true") { template = responsiveTemplate; tsAddCssTag("https://wassets.trustist.com/assets/css/responsiveslides.css"); tsAddScriptTag("https://wassets.trustist.com/assets/js/lib/responsiveslides.min.js"); } // set the target's identifiers for later drawing target.setAttribute("ts-location", lkey); target.setAttribute("ts-business", bkey); target.setAttribute("ts-tenant", tkey); target.setAttribute("ts-tag", tagkey); // put the container on the page target.innerHTML = template .replace("{{font-family}}", options.fontFamily) .replace("{{color}}", options.color) .replace(new RegExp("{{link-color}}", "g"), options.linkColor) .replace("{{border-width}}", options.borderWidth) .replace(new RegExp("{{shadow}}", "g"), options.shadow) .replace("{{shadow-blur}}", options.shadowBlur) .replace("{{slider-interval}}", options.sliderInterval * 4); // multiplied by the number of reviews to be displayed for css version // draw widget var xhr2 = new XMLHttpRequest(); var url = "https://widget.trustist.com/reviewlistdata?v=1&accessToken=" + accessToken + "&pageSize=" + options.pageSize + "&businessKey=" + bkey; if (typeof tkey !== "undefined" && tkey !== "") url += "&tenantKey=" + tkey; if (typeof bkey !== "undefined" && bkey !== "") url += "&businessKey=" + bkey; if (typeof lkey !== "undefined" && lkey !== "") url += "&locationKey=" + lkey; if (typeof tagkey !== "undefined" && tagkey !== "") url += "&tag=" + tagkey; if (options.ratingsAbove > 0) url += "&ratingFrom=" + options.ratingsAbove; if (options.exclude > '') url += "&exclude=" + options.exclude; xhr2.open("GET", url); xhr2.onload = function () { if (xhr2.status === 200 && xhr2.responseText !== "") { var reviews = JSON.parse(xhr2.responseText); // load and draw reviews tsDrawWidget(target, reviews, tenantKey, businessKey, locationKey, tagkey, options); } }; xhr2.send(); } function tsDrawWidget(target, reviews, tenantKey, businessKey, locationKey, tagKey, options) { var reviewContent = ""; reviews.forEach(function (review) { reviewContent += tsRenderReview(review, options); }); target.innerHTML = target.innerHTML .replace("", reviewContent); if (options.suppressFooter !== "true") { target.innerHTML = target.innerHTML .replace("", footer); } if (options.responsive === "true") { tsStartResponsiveSlideshow(options.sliderInterval); } } function tsStartResponsiveSlideshow(interval) { // wait until function becomes available then execute if (!jQuery(".ts-responsive-slides").responsiveSlides) { window.setTimeout(tsStartResponsiveSlideshow, 100, interval); } else { jQuery(".ts-responsive-slides").responsiveSlides({ pause: true, timeout: interval * 1000, nav: true, namespace: "centered-btns", }); } } function tsRenderReview(review, options) { var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var d = new Date(review.datePublished); var curr_date = d.getDate(); var curr_month = d.getMonth(); //Months are zero based var curr_year = d.getFullYear(); var dateString = curr_date + " " + months[curr_month] + " " + curr_year; var reply = ""; if (review.reply && review.reply !== "") { var replyDate = new Date(review.replyDate); var replyDateString = replyDate.getDate() + " " + months[replyDate.getMonth()] + " " + replyDate.getFullYear(); reply = "

Reply left " + replyDateString + ":  " + review.reply; } var reviewText = review.reviewBody || ""; var reviewId = review.datePublished.replace(new RegExp(":", "g"), "-"); var truncateLength = Number(options.truncateLength); if (isNaN(truncateLength) === false && truncateLength > 0 && reviewText.length > truncateLength) { reviewText = reviewText.substr(0, truncateLength) + '... read more' + '' + reviewText.substr(truncateLength, reviewText.length - truncateLength) + ''; } return '
  • ' + '

    ' + '" + '

    ' + '
    ' + reviewText + reply + "
  • "; } function tsGetSliderTextStyle(options) { if (options.lineClamp !== "") { return "-webkit-line-clamp: " + options.lineClamp + " !important;"; } return ""; } function tsGetContainerStyle(options) { if (options.templateName === "left") { return "ts-slider-container"; } return "ts-slider-container ts-slider-centre"; } function tsGetElementStyle(options) { if (options.templateName === "left") { return "ts-reviewSliderContentElementLeft"; } return ""; } function tsReadAttributes(target) { return { templateName: target.getAttribute("ts-reviewSliderWidget") || "main", locationKey: target.getAttribute("ts-location"), businessKey: target.getAttribute("ts-business"), fontFamily: target.getAttribute("ts-font-family") || "Lato, Helvetica, sans-serif", color: target.getAttribute("ts-color") || "#5a6a74", linkColor: target.getAttribute("ts-link-color") || "#111b47", pageSize: target.getAttribute("ts-page-size") || 5, borderWidth: target.getAttribute("ts-border-width") || 1, shadow: target.getAttribute("ts-shadow") || 2, shadowBlur: target.getAttribute("ts-shadow-blur") || 14, sliderInterval: target.getAttribute("ts-slider-interval") || 10, responsive: target.getAttribute("ts-responsive") || "false", linkTarget: target.getAttribute("ts-link-target") || "_self", truncateLength: target.getAttribute("ts-truncate-length") || "0", ratingsAbove: parseInt(target.getAttribute("ts-ratings-above")) || 0, suppressFooter: target.getAttribute("ts-suppress-footer") || "false", lineClamp: target.getAttribute("ts-line-clamp") || "", exclude: target.getAttribute("ts-exclude") || "", }; } function tsAddCssTag(url) { var includedAlready = tsCheckIfIncluded(url); var head = d.getElementsByTagName("head")[0]; if (!includedAlready) { var tag = d.createElement("link"); tag.rel = "stylesheet"; tag.type = "text/css"; tag.href = url; head.appendChild(tag); } } function tsAddScriptTag(url) { var includedAlready = tsCheckIfIncluded(url); var head = d.getElementsByTagName("head")[0]; if (!includedAlready) { var tag = d.createElement("script"); tag.src = url; head.appendChild(tag); } } function tsCheckIfIncluded(file) { var links = d.getElementsByTagName("link"); for (var i = 0; i < links.length; i++) { if (links[i].href?.substr(-file.length) === file) return true; } var scripts = d.getElementsByTagName("script"); for (var j = 0; j < scripts.length; j++) { if (scripts[j].src?.substr(-file.length) === file) return true; } return false; } })(window, document);