Realiza tu autodiagnóstico gratis
(function(){
var root=document.getElementById("aenor-modulo"); if(!root) return;
var field=root.querySelector(".m-field"), fill=root.querySelector(".m-fill"), pct=root.querySelector(".m-pct"), result=root.querySelector(".m-result");
var reduce=window.matchMedia&&matchMedia("(prefers-reduced-motion: reduce)").matches;
var mobile=window.matchMedia("(max-width:767px)");
/* Medición: dataLayer + envío directo a GA4 (sin depender de GTM) */
window.dataLayer=window.dataLayer||[];
function track(ev,x){ var p={event:ev,banner_name:"modulo_autodiagnostico_iso9001",banner_location:"bloque_promo",link_url:undefined}; for(var k in x) p[k]=x[k]; window.dataLayer.push(p);
var g={send_to: location.hostname==="mkt.aenor.com" ? "G-GVHYC4090R" : "G-2F4YLNH7V0"}; for(var j in p){ if(j!=="event" && p[j]!==undefined) g[j]=p[j]; }
(window.gtag || function(){ window.dataLayer.push(arguments); })("event", ev, g); }
/* ---- Campo de píxeles ---- */
var SHAPES={
bars: ["00000006","00000006","00000556","00000556","00445556","22445556","22445556"],
check: ["00000006","00000060","00000600","60006000","06060000","00600000"],
right: ["0006000","0000600","3445666","0000600","0006000"]
};
var cols=0, rows=0, cells=[];
function build(){
var w=root.clientWidth, h=root.clientHeight; if(!w||!h) return false;
var px=mobile.matches?12:16, gap=mobile.matches?4:5;
var c=Math.floor((w-gap)/(px+gap)), r=Math.floor((h-gap)/(px+gap));
if(c===cols&&r===rows) return true;
cols=c; rows=r; field.style.setProperty("--m-px",px+"px"); field.style.setProperty("--m-gap",gap+"px");
field.style.gridTemplateColumns="repeat("+c+","+px+"px)"; field.innerHTML=""; cells=[];
for(var i=0;i=rows||cc>=cols) continue;
var b=cells[rr*cols+cc]; b.style.transitionDelay=(c*45+r*12)+"ms"; b.dataset.v=String(v); b.dataset.s="1";
}
}
/* ---- Ciclo del módulo (como el original: 0→100 %, resultado listo, cada 5 s) sincronizado con los píxeles ---- */
var timers=[], amb=null, running=false, raf=0;
function later(fn,ms){ timers.push(setTimeout(fn,ms)); }
function count(){ var t0=performance.now(); cancelAnimationFrame(raf);
(function step(t){ var s=Math.min((t-t0)/1600,1), e=1-Math.pow(1-s,3); var v=Math.round(e*100); pct.textContent=v+"%"; pct.classList.toggle("done",v===100); if(s<1) raf=requestAnimationFrame(step); })(t0); }
function cycle(){
timers.forEach(clearTimeout); timers=[];
fill.style.transition="none"; fill.style.width="0"; void fill.offsetWidth; fill.style.transition="";
result.classList.remove("show"); pct.textContent="0%"; pct.classList.remove("done"); draw(null);
var m=mobile.matches; // en móvil el texto ocupa todo el ancho: solo el fondo de píxeles, sin formas
later(function(){ fill.style.width="100%"; count(); if(!m) draw("bars"); },300);
later(function(){ result.classList.add("show"); if(!m) draw("check"); },2200);
later(function(){ if(!m) draw("right"); },3400);
later(cycle,5000);
}
function start(){ if(running||!build()) return; running=true; ambient(); cycle(); amb=setInterval(ambient,1100); }
function stop(){ running=false; timers.forEach(clearTimeout); timers=[]; clearInterval(amb); cancelAnimationFrame(raf); }
build();
if(reduce){ ambient(); fill.style.width="100%"; pct.textContent="100%"; pct.classList.add("done"); result.classList.add("show"); if(!mobile.matches) draw("right"); }
else{
var seen=false, vis=false;
new IntersectionObserver(function(es){ vis=es[0].isIntersecting; if(vis&&!seen){ seen=true; track("banner_view"); } vis&&!document.hidden?start():stop(); },{threshold:.2}).observe(root);
document.addEventListener("visibilitychange",function(){ document.hidden?stop():(vis&&start()); });
}
var rt; window.addEventListener("resize",function(){ clearTimeout(rt); rt=setTimeout(function(){ var c=cols,r=rows; build(); if(c!==cols||r!==rows){ if(running){ stop(); start(); } else { ambient(); if(reduce) draw("right"); } } },150); });
root.querySelector(".m-cta").addEventListener("click",function(){ track("banner_click",{link_url:this.href}); });
})();
¿Está tu empresa preparada para la nueva ISO 9001:2026?
Descúbrelo en sólo 5 minutos a través de este test de autodiagnóstico gratuito.
Hacer test