rating data: ' + response.message); } } catch (e) { console.error('Error parsing rating data: ' + e.message); } } }; xhr.send(); } // 更新评分显示 function updateRatingDisplay() { // 更新平均分和评分人数 averageRatingEl.textContent = ratingData.average.toFixed(1); ratingCountEl.textContent = ratingData.total + ' People Rated'; // 更新统计信息 totalRatingsEl.textContent = ratingData.total; averageScoreEl.textContent = ratingData.average.toFixed(1); // 计算五星好评率 var fiveStarPercent = ratingData.total > 0 ? (ratingData.distribution[5] / ratingData.total * 100).toFixed(1) : 0; fiveStarPercentEl.textContent = fiveStarPercent + '%'; // 更新评分分布条 updateRatingBars(); } // 更新评分分布条 function updateRatingBars() { ratingBarsEl.innerHTML = ''; for (var i = 5; i >= 1; i--) { var percentage = ratingData.total > 0 ? (ratingData.distribution[i] / ratingData.total * 100).toFixed(1) : 0; var barItem = document.createElement('div'); barItem.className = 'rating-bar-item'; barItem.innerHTML = '
' + i + ' Points
' + '
' + '
' + '
' + '
' + percentage + '%
'; ratingBarsEl.appendChild(barItem); } } // 显示消息 function showMessage(text, type) { messageEl.textContent = text; messageEl.className = 'rating-message ' + type; // 3秒后隐藏消息 setTimeout(function() { messageEl.textContent = ''; messageEl.className = 'rating-message'; }, 3000); } // 初始化 - 在页面加载完成后执行 document.addEventListener('DOMContentLoaded', function() { console.log('Rating system initialized'); console.log('Article ID: ' + articleId); setupEventListeners(); loadRatingData(); });

Previous and next:

Prev:Allen Bradley 1746-IV32 SLC 500 Digital Input Module

Next:Allen Bradley 1746-N2B SLC 500 Slot Filler

Related Tags:

Allen Bradley 1746-N2

Related Products

Copyright © 2018-2025 Qunlebu Co., Ltd. All Rights Reserved. Excellent PLC GLB PLC MTS PLC

WhatsApp

+8613620394314