`).join('');
grid.classList.add('loaded');
}, 100);
}
function setupListeners() {
const sInput = document.getElementById('searchInput');
const fCont = document.getElementById('filterContainer');
if(sInput) sInput.oninput = (e) => { state.search = e.target.value; render(); };
if(fCont) {
fCont.onclick = (e) => {
const btn = e.target.closest('.filter-btn');
if (btn) {
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active-filter'));
btn.classList.add('active-filter');
state.filter = btn.dataset.cat;
render();
}
};
}
}
// Quiz Logic
window.startQuiz = () => {
state.score = 0; state.qIdx = 0;
state.quizPool = [...verbData].sort(() => 0.5 - Math.random()).slice(0, 10);
document.getElementById('quizIntro').classList.add('hidden');
document.getElementById('quizBox').classList.remove('hidden');
nextQuestion();
};
function nextQuestion() {
if(state.qIdx >= 10) return showResults();
const v = state.quizPool[state.qIdx];
const isV2 = Math.random() > 0.5;
const correctStr = isV2 ? v.v2 : v.v3;
const correct = correctStr.split(' ')[0].replace(/[^a-zA-Z]/g, "");
let opts = [correct];
while(opts.length < 4) {
let r = verbData[Math.floor(Math.random()*verbData.length)];
let oStr = isV2 ? r.v2 : r.v3;
let o = oStr.split(' ')[0].replace(/[^a-zA-Z]/g, "");
if(!opts.includes(o)) opts.push(o);
}
opts.sort(() => 0.5 - Math.random());
document.getElementById('quizBox').innerHTML = `
`;
}
const init = () => {
if(document.getElementById('verbGrid')) { setupListeners(); render(); }
else { setTimeout(init, 500); }
};
init();
})();
Question ${state.qIdx+1}/10
Score: ${state.score}
"${v.main}"-এর ${isV2 ? 'V2 (Past)' : 'V3 (Participle)'} রূপ কোনটি?
${opts.map(o => ``).join('')}
`;
}
window.checkAnswer = (s, c) => { if(s === c) state.score++; state.qIdx++; nextQuestion(); };
function showResults() {
document.getElementById('quizBox').innerHTML = `
Result! 🎉
${state.score} / 10