PageSourceSearch

https://ceutaturismo.com/assets/js/v1042-valoracion-global.js?v=1042.0

js ceutaturismo.com collected 2026-10-04 22:31:45 UTC 2,731 bytes, 20 lines download raw bytes

1(function(){
2 'use strict';
3 var root=document.getElementById('ct1042Rating'); if(!root)return;
4 var toggle=root.querySelector('.ct1042-ratingbar-toggle'),panel=root.querySelector('#ct1042RatingPanel'),form=root.querySelector('#ct1042Form'),status=root.querySelector('#ct1042Status');
5 var avg=root.querySelector('[data-rating-average]'),count=root.querySelector('[data-rating-count]'),useful=root.querySelector('[data-rating-useful]'),starsText=root.querySelector('[data-rating-stars]');
6 var endpoint='/api/valorar-ceutaturismo.php';
7 function stars(v){if(!v)return '☆☆☆☆☆';var n=Math.round(v),s='';for(var i=1;i<=5;i++)s+=i<=n?'★':'☆';return s;}
8 function render(stats){
9  if(!stats||!stats.count){avg.textContent='—';starsText.textContent='☆☆☆☆☆';count.textContent='SÉ DE LOS PRIMEROS EN VALORAR';useful.textContent='—';return;}
10  avg.textContent=String(stats.average).replace('.',',')+'/5';starsText.textContent=stars(stats.average);count.textContent=stats.count+' '+(stats.count===1?'VALORACIÓN REAL':'VALORACIONES REALES');useful.textContent=stats.useful_percent+'%';
11 }
12 toggle.addEventListener('click',function(){var open=toggle.getAttribute('aria-expanded')==='true';toggle.setAttribute('aria-expanded',String(!open));panel.hidden=open;if(!open){var first=form.querySelector('input[name="stars"]');if(first)window.setTimeout(function(){first.focus();},80);}});
13 fetch(endpoint,{credentials:'same-origin'}).then(function(r){return r.json();}).then(function(j){if(j.ok)render(j.stats);}).catch(function(){});
14 form.addEventListener('submit',function(e){
15  e.preventDefault();status.textContent='';var fd=new FormData(form),data={stars:Number(fd.get('stars')||0),usefulness:String(fd.get('usefulness')||''),comment:String(fd.get('comment')||''),website:String(fd.get('website')||''),lang:document.documentElement.lang||'es'};
16  if(!data.stars){status.textContent='Selecciona de 1 a 5 estrellas.';return;}if(!data.usefulness){status.textContent='Indica si la guía te ha resultado útil.';return;}
17  var btn=form.querySelector('button[type="submit"]');btn.disabled=true;btn.textContent='ENVIANDO…';
18  fetch(endpoint,{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json'},body:JSON.stringify(data)}).then(function(r){return r.json().then(function(j){return {status:r.status,data:j};});}).then(function(res){if(res.data.stats)render(res.data.stats);status.textContent=res.data.message||res.data.error||'Gracias por tu valoración.';if(res.data.ok)form.reset();}).catch(function(){status.textContent='No se ha podido enviar ahora. Inténtalo de nuevo en unos minutos.';}).finally(function(){btn.disabled=false;btn.textContent='ENVIAR VALORACIÓN →';});
19 });
20})();

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.