Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
document.addEventListener('DOMContentLoaded', function() {
const originalRadio = document.getElementById('original');
const otherRadio = document.getElementById('other');
const wordSpans = document.querySelectorAll('.words-practice');
const answerInputs = document.querySelectorAll('.answer-input');
const originalWords = [];
const translations = [];
wordSpans.forEach(span => {
originalWords.push(span.textContent);
});
answerInputs.forEach(input => {
translations.push(input.dataset.answer);
});
function handleLanguageChange() {
answerInputs.forEach(input => {
input.value = '';
input.classList.remove('correct', 'incorrect');
input.removeAttribute('readonly');
input.style.pointerEvents = '';
});
const checkIcons = document.querySelectorAll('.check-icon i');
checkIcons.forEach(icon => {
icon.style.display = 'none';
icon.className = 'fa-solid fa-sharp fa-check';
});
if (otherRadio.checked) {
wordSpans.forEach((span, index) => {
span.textContent = translations[index];
});
answerInputs.forEach((input, index) => {
input.dataset.answer = originalWords[index];
});
} else {
wordSpans.forEach((span, index) => {
span.textContent = originalWords[index];
});
answerInputs.forEach((input, index) => {
input.dataset.answer = translations[index];
});
}
}
originalRadio.addEventListener('change', handleLanguageChange);
otherRadio.addEventListener('change', handleLanguageChange);
});