1(function(){ 2'use strict'; 3const l10n=window.wpPostRatingsL10n||{}; 4const inFlight=new Set(); 5function vote(control, rating){ 6const postId=Number(control.dataset.postId); 7if(! postId||! rating){ 8return; 9} 10if(inFlight.has(postId)){ 11window.alert(l10n.textWait); 12return; 13} 14const container=document.getElementById('wp-postratings-' + postId); 15if(! container){ 16return; 17} 18const nonce=container.dataset.nonce||container.getAttribute('data-nonce'); 19inFlight.add(postId); 20container.setAttribute('aria-busy', 'true'); 21const body=new URLSearchParams(); 22body.append('action', 'wp_postratings'); 23body.append('pid', postId); 24body.append('rate', rating); 25body.append('wp_postratings_' + postId + '_nonce', nonce); 26function finish(html){ 27if('string'===typeof html){ 28container.innerHTML=html; 29} 30container.removeAttribute('aria-busy'); 31inFlight.delete(postId); 32} 33window 34.fetch(l10n.ajaxUrl, { 35method: 'POST', 36credentials: 'same-origin', 37headers: { 38'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 39}, 40body: body.toString(), 41}) 42.then(function(response){ 43return response.text(); 44}) 45.then(finish) 46.catch(function(){ 47finish(); 48}); 49} 50function start(){ 51document.addEventListener('change', function(event){ 52const input=event.target.closest('.wp-postratings-scale input[type="radio"]'); 53if(! input){ 54return; 55} 56const control=input.closest('.wp-postratings-vote'); 57if(control){ 58vote(control, Number(input.value)); 59}}); 60document.addEventListener('click', function(event){ 61const button=event.target.closest('.wp-postratings-updown button'); 62if(! button){ 63return; 64} 65event.preventDefault(); 66const control=button.closest('.wp-postratings-vote'); 67if(control){ 68vote(control, Number(button.dataset.rating)); 69}}); 70} 71if('loading'===document.readyState){ 72document.addEventListener('DOMContentLoaded', start); 73}else{ 74start(); 75}}());
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.