1(function() { 2 document.querySelectorAll('.stars-rating').forEach(rating => { 3 let postId = rating.dataset.postid; 4 5 rating.addEventListener('click', function(e) { 6 if(e.target.classList.contains('star') && !localStorage.getItem('voted_' + postId)) { 7 let score = e.target.dataset.rating; 8 9 fetch('/wp-json/generateperf/vote', { 10 method: 'POST', 11 headers: { 12 'Content-Type': 'application/json' 13 }, 14 body: JSON.stringify({postId, score}) 15 }) 16 .then(response => { 17 if(response.ok) { 18 return response.json(); 19 } 20 }) 21 .then(data => { 22 if(data.success) { 23 localStorage.setItem('voted_' + postId, true); 24 updateStars(rating, score); 25 updateVoteInfo(postId, generateperf_user_ratings.saved); 26 } else { 27 updateVoteInfo(postId, generateperf_user_ratings.error); 28 } 29 }) 30 .catch(error => { 31 updateVoteInfo(postId, generateperf_user_ratings.error); 32 }); 33 } 34 }); 35 }); 36 37 function updateStars(rating, score) { 38 rating.querySelectorAll('.star').forEach((star, index) => { 39 star.classList.toggle('active', index < score); 40 }); 41 } 42 43 function updateVoteInfo(postId, message) { 44 let voteInfoElem = document.querySelector('.vote-info'); 45 if (voteInfoElem) { 46 voteInfoElem.textContent = message; 47 } 48 } 49})();
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.