原文
';
if(q.hint){
h += '' + x + ' ';
}).join('');
root.querySelector('[data-unsure]').classList.toggle('is-on', flags.has('UNSURE'));
resEl.dataset.flags = Array.from(flags).join(',');
resEl.dataset.share = R.share;
quizEl.style.display = 'none';
resEl.classList.add('is-on');
prog.style.width = '100%';
}
backBtn.addEventListener('click', function(){
if(idx > 0){
idx--;
renderQ();
}
});
nextBtn.addEventListener('click', function(){
if(idx maxW && line){
ctx.fillText(line,x,yy);
line = words[i];
yy += lh;
} else {
line = t;
}
}
ctx.fillText(line,x,yy);
return yy;
}
root.querySelector('[data-cta-share]').addEventListener('click', function(){
var key = resEl.dataset.key || 'A';
var R = RESULTS[key];
var W = 1200;
var H = 630;
var s = 2;
var cv = document.createElement('canvas');
cv.width = W * s;
cv.height = H * s;
var ctx = cv.getContext('2d');
ctx.scale(s,s);
var ff = "'Sofia Pro',system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif";
var bg = ctx.createLinearGradient(0,0,W,H);
bg.addColorStop(0,'#f7f2fe');
bg.addColorStop(1,'#ece6fb');
ctx.fillStyle = bg;
ctx.fillRect(0,0,W,H);
ctx.fillStyle = '#7b4df3';
rounded(ctx,64,64,W-128,H-128,28);
ctx.fill();
ctx.textBaseline = 'alphabetic';
ctx.fillStyle = '#ffffff';
ctx.font = '800 30px ' + ff;
ctx.fillText('AXIPRO',108,148);
ctx.fillStyle = 'rgba(255,255,255,.82)';
ctx.font = '600 17px ' + ff;
ctx.fillText('THE EU AI ACT · ARE YOU IN SCOPE?',108,178);
var chipTxt = R.badge.replace('Result · ','').toUpperCase();
ctx.font = '800 16px ' + ff;
var cw = ctx.measureText(chipTxt).width + 44;
ctx.fillStyle = TONE_FILL[R.tone];
rounded(ctx,108,212,cw,42,21);
ctx.fill();
ctx.fillStyle = '#ffffff';
ctx.fillText(chipTxt,130,239);
ctx.fillStyle = '#ffffff';
ctx.font = '900 52px ' + ff;
var endY = wrapText(ctx,'“' + R.share + '”',108,330,W-216,62);
ctx.fillStyle = 'rgba(255,255,255,.85)';
ctx.font = '500 26px ' + ff;
ctx.fillText('The EU AI Act lands 2 August. Where do you stand?',108,endY+58);
ctx.fillStyle = '#ffffff';
ctx.font = '700 22px ' + ff;
ctx.textAlign = 'right';
ctx.fillText(DIAG_URL,W-108,H-96);
ctx.textAlign = 'left';
var a = document.createElement('a');
a.download = 'axipro-ai-act-scope-' + key.toLowerCase() + '.png';
a.href = cv.toDataURL('image/png');
a.click();
});
renderQ();
});
})();
' + q.hint + '
'; } h += ''; q.opts.forEach(function(o,i){ var on = sel.indexOf(i) >= 0; h += ''; }); h += '
'; h += 'Why we ask: ' + q.help + '
'; mount.innerHTML = h; Array.prototype.forEach.call(mount.querySelectorAll('.axp-opt'), function(btn){ btn.addEventListener('click', function(){ pick(q, parseInt(btn.dataset.oi,10)); }); }); prog.style.width = ((idx) / QUESTIONS.length * 100) + '%'; progTxt.textContent = 'Question ' + (idx + 1) + ' of ' + QUESTIONS.length; backBtn.disabled = idx === 0; nextBtn.disabled = sel.length === 0; nextBtn.textContent = idx === QUESTIONS.length - 1 ? 'See my result' : 'Next'; } function pick(q, oi){ var sel = answers[q.id] || []; if(!q.multi){ answers[q.id] = [oi]; } else { var isNone = !!q.opts[oi].none; if(isNone){ sel = [oi]; } else { sel = sel.filter(function(i){ return !q.opts[i].none; }); var at = sel.indexOf(oi); if(at >= 0){ sel.splice(at,1); } else { sel.push(oi); } } answers[q.id] = sel; } renderQ(); } function collectFlags(){ var flags = new Set(); QUESTIONS.forEach(function(q){ (answers[q.id] || []).forEach(function(i){ q.opts[i].flags.forEach(function(f){ flags.add(f); }); }); }); return flags; } function showResult(){ var flags = collectFlags(); var key = window.axpComputeResult(flags); var R = RESULTS[key]; resEl.dataset.tone = R.tone; resEl.dataset.key = key; root.querySelector('[data-res-badge]').textContent = R.badge; root.querySelector('[data-res-head]').textContent = R.head; root.querySelector('[data-res-sum]').textContent = R.sum; root.querySelector('[data-res-list]').innerHTML = R.list.map(function(x){ return '