document.addEventListener(„DOMContentLoaded“, function(){
const werte = [„Achtsamkeit“,“Authentizität“,“Bildung“,“Dankbarkeit“,“Empathie“,
„Erfolg“,“Fairness“,“Freiheit“,“Freundschaft“,“Gesundheit“,“Gerechtigkeit“,
„Humor“,“Liebe“,“Mut“,“Nachhaltigkeit“,“Offenheit“,“Respekt“,“Vertrauen“,“Verantwortung“,“Zuversicht“];
const quiz = document.getElementById(„wertequiz“);
if(!quiz) return;
quiz.innerHTML = `
Finde deine wichtigsten Werte
Wähle bis zu 10 Werte aus:
`;
const selected=[], scores={};
const container=document.getElementById(„values“);
werte.forEach(w=>{
const btn=document.createElement(„button“);
btn.textContent=w;
btn.style.cssText=“padding:6px 10px;border:1px solid #aaa;border-radius:6px;cursor:pointer;background:#fff;“;
btn.onclick=()=>{
if(selected.includes(w)){
selected.splice(selected.indexOf(w),1);
btn.style.background=“#fff“;
} else if(selected.length<10){
selected.push(w);
btn.style.background="#b4e2a8";
}
document.getElementById("toStep2").disabled=selected.length{
document.getElementById(„step1″).style.display=“none“;
document.getElementById(„step2″).style.display=“block“;
startComparison();
};
let i=0,j=1;
function startComparison(){
selected.forEach(v=>scores[v]=0);
showComparison();
}
function showComparison(){
if(i>=selected.length-1){showResults();return;}
if(j>=selected.length){i++;j=i+1;showComparison();return;}
const c=document.getElementById(„compare“);
c.innerHTML=` oder `;
document.getElementById(„a“).onclick=()=>{scores[selected[i]]++;j++;showComparison();};
document.getElementById(„b“).onclick=()=>{scores[selected[j]]++;j++;showComparison();};
}
function showResults(){
document.getElementById(„step2″).style.display=“none“;
document.getElementById(„step3″).style.display=“block“;
const sorted=Object.entries(scores).sort((a,b)=>b[1]-a[1]).slice(0,3);
document.getElementById(„results“).innerHTML=sorted.map(([w])=>`
`).join(„“);
}
});