PageSourceSearch

https://decathlon.qa/cdn/shop/t/15/assets/product-review-stats.js?v=138805267357488784861774245880

js decathlon.qa collected 2026-10-04 13:25:55 UTC 5,757 bytes, 2 lines download raw bytes

1if(typeof ProductReviewStats>"u"){class ProductReviewStats2{constructor(){this.statsCache=new Map,this.mainModelCode=null,this.mainGlobalsInitialized=!1}async extractModelCode(){return window.reviewsTranslations&&window.reviewsTranslations.modelCode?window.reviewsTranslations.modelCode:null}async fetchStats(modelCode){if(!modelCode||!window.reviewsApiUrl)return null;if(this.statsCache.has(modelCode))return this.statsCache.get(modelCode);const url=`${window.reviewsApiUrl}/reviews/model/${modelCode}/only_stats`;try{const response=await fetch(url);if(!response.ok)throw new Error(`HTTP error! status: ${response.status}`);const data=await response.json();return this.statsCache.set(modelCode,data),data}catch(error){return console.error("Failed to fetch review stats:",error),null}}updateContainer(container,stats){if(!stats||!container)return;const{averageRating,count}=stats,starsContainer=container.querySelector("[data-review-stars]");starsContainer&&this.updateStars([starsContainer],averageRating);const ratingValue=container.querySelector("[data-review-rating]");ratingValue&&(ratingValue.forEach?ratingValue.forEach(el=>el.textContent=this.formatRating(averageRating)):ratingValue.textContent=this.formatRating(averageRating));const reviewCount=container.querySelector("[data-review-count]");if(reviewCount){const currentText=reviewCount.textContent.trim(),formattedCount=this.formatNumber(count);reviewCount.textContent=/\d+/.test(currentText)?currentText.replace(/\d+/,formattedCount):`${formattedCount} ${currentText}`}container.style.display="",container.setAttribute("data-stats-initialized","true")}updateMainProductGlobals(stats){if(this.mainGlobalsInitialized)return;const{count,ratingDistribution}=stats;document.querySelectorAll(".reviews_tab").forEach(tab=>{tab.style.display="";const tabText=tab.textContent.trim();if(/\d+/.test(tabText)){const formattedCount=this.formatNumber(count);tab.textContent=tabText.replace(/\d+/,formattedCount)}}),ratingDistribution&&this.updateDistribution(ratingDistribution,count),document.querySelectorAll(".ReviewDetails-title").forEach(title=>title.style.display=""),this.mainGlobalsInitialized=!0}hideMainProductGlobals(){document.querySelectorAll(".reviews_tab").forEach(tab=>tab.style.display="none"),document.querySelectorAll(".ReviewDetails-title").forEach(title=>title.style.display="none")}updateDistribution(ratingDistribution,totalCount){document.querySelectorAll("[data-review-distribution]").forEach(container=>{container.style.display="flex",ratingDistribution.forEach(rating=>{const starCode=rating.code,row=container.querySelector(`[data-star="${starCode}"]`);if(row){const percentage=totalCount>0?(rating.value/totalCount*100).toFixed(1):0,fillBar=row.querySelector(".distribution-fill"),countSpan=row.querySelector(".distribution-count");if(fillBar&&(fillBar.style.width=`${percentage}%`),countSpan){const formattedCount=this.formatNumber(rating.value);countSpan.textContent=formattedCount}}})})}formatNumber(num){return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g," ")}formatRating(rating){const rounded=Math.round(rating*10)/10;return rounded%1===0?rounded.toFixed(0):rounded.toFixed(1)}updateStars(starsContainers,rating){const fullStars=Math.floor(rating),decimal=rating-fullStars,hasHalfStar=decimal>=.3&&decimal<=.7;starsContainers.forEach(container=>{let starsHtml="";for(let i=1;i<=5;i++)i<=fullStars?starsHtml+='<svg fill="none" focusable="false" width="14" height="14" class="icon icon--rating-star rating__star rating__star--full" viewBox="0 0 14 13"><path d="M7 0L8.6458 4.73475L13.6574 4.83688L9.66296 7.86525L11.1145 12.6631L7 9.8L2.8855 12.6631L4.33704 7.86525L0.342604 4.83688L5.3542 4.73475L7 0Z" fill="currentColor"></path></svg>':i===fullStars+1&&hasHalfStar?starsHtml+='<svg fill="none" focusable="false" width="14" height="14" class="icon icon--rating-star-half rating__star rating__star--half" viewBox="0 0 14 13"><path d="M7 0L8.6458 4.73475L13.6574 4.83688L9.66296 7.86525L11.1145 12.6631L7 9.8V0Z" fill="currentColor"></path></svg>':starsHtml+='<svg fill="none" focusable="false" width="14" height="14" class="icon icon--rating-star rating__star rating__star--empty" viewBox="0 0 14 13"><path d="M7 0L8.6458 4.73475L13.6574 4.83688L9.66296 7.86525L11.1145 12.6631L7 9.8L2.8855 12.6631L4.33704 7.86525L0.342604 4.83688L5.3542 4.73475L7 0Z" fill="currentColor"></path></svg>';container.innerHTML=starsHtml})}
1async init(){const containers=document.querySelectorAll("[data-review-container]:not([data-stats-initialized])"),containersBySku=new Map,mainModelCode=await this.extractModelCode();containers.forEach(container=>{let sku=container.dataset.sku;!sku&&mainModelCode&&(sku=mainModelCode),sku&&(containersBySku.has(sku)||containersBySku.set(sku,[]),containersBySku.get(sku).push(container))});for(const[sku,skuContainers]of containersBySku){const stats=await this.fetchStats(sku);stats&&stats.count>0?(skuContainers.forEach(container=>this.updateContainer(container,stats)),mainModelCode&&sku==mainModelCode&&this.updateMainProductGlobals(stats)):skuContainers.forEach(container=>container.style.display="none")}if(mainModelCode&&!containersBySku.has(mainModelCode)&&!this.mainGlobalsInitialized){const stats=await this.fetchStats(mainModelCode);stats&&stats.count>0?this.updateMainProductGlobals(stats):this.hideMainProductGlobals()}}}window.ProductReviewStats=ProductReviewStats2}if(typeof window.productReviewStatsInstance>"u"){window.productReviewStatsInstance=new ProductReviewStats;const initStats=()=>{window.productReviewStatsInstance.init()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initStats):initStats()}
2//# sourceMappingURL=/cdn/shop/t/15/assets/product-review-stats.js.map?v=138805267357488784861774245880

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.