Giriş yapılıyor...

Limitsiz İngilizce

0%
1 / 25
, flashcards[j]] =
0%
1 / 25
, flashcards[i]]; } function renderCard(el, d){ if(!el) return; if(!d){ el.innerHTML=""; return; } el.innerHTML = ''+ '

'+d.word+'

'+ '

'+d.meaning+'

'+ ''; } function updateCounter(){ if(!counterBox) return; counterBox.textContent = (Math.min(currentIndex + 1, runTotal)) + " / " + runTotal; } function updateProgress(){ if(!progressBar || !progressText) return; const pct = runTotal ? Math.min(100, ((Math.min(currentIndex + 1, runTotal)) / runTotal) * 100) : 100; progressBar.style.width = pct + "%"; progressText.textContent = Math.round(pct) + "%"; } function showCards(){ renderCard(activeCard, flashcards[0]); renderCard(nextCard, flashcards[1] || flashcards[0]); updateProgress(); updateCounter(); } function saveLearnedWord(word){ if(!word || !ajaxUrl) return; fetch(ajaxUrl,{ method:"POST", headers:{"Content-Type":"application/x-www-form-urlencoded"}, body:"action=save_learned_word&word="+encodeURIComponent(word)+"&set="+encodeURIComponent(setKey) }); } function finishSet(){ completed = true; // progress 100% if(progressBar && progressText){ progressBar.style.width = "100%"; progressText.textContent = "100%"; } if(counterBox){ counterBox.textContent = runTotal + " / " + runTotal; } renderCard(activeCard, doneCard); if(nextCard) nextCard.innerHTML = ""; if(activeCard) activeCard.classList.add("gold-frame"); // ana kontrolleri kapat if(listenBtn) listenBtn.style.display = "none"; if(knowBtn) knowBtn.style.display = "none"; if(dontKnowBtn) dontKnowBtn.style.display = "none"; const pw = document.getElementById("progress-wrap"); if(pw) pw.style.display = "none"; if(counterBox) counterBox.style.display = "none"; if(doneBtns) doneBtns.style.display = "flex"; } function nextCardFlow(){ if(locked || completed) return; locked = true; // son kart güvenliği if(currentIndex === flashcards.length - 1){ if(flashcards[currentIndex]) saveLearnedWord(flashcards[currentIndex].word); } currentIndex++; if(currentIndex >= flashcards.length){ finishSet(); locked = false; return; } if(activeCard && nextCard){ activeCard.innerHTML = nextCard.innerHTML; } if(nextCard){ if(flashcards[currentIndex+1]){ renderCard(nextCard, flashcards[currentIndex+1]); } else { nextCard.innerHTML = ""; } } updateCounter(); updateProgress(); const a = activeCard ? activeCard.querySelector("audio") : null; if(a){ a.currentTime=0; a.play().catch(()=>{}); } setTimeout(()=>locked=false,150); } function slideCard(dir){ if(completed) return; // ✅ son kart ise, ses “gesture” anında çalsın if(currentIndex === flashcards.length - 1){ playSuccess(); } if(dir==="right" && flashcards[currentIndex]){ saveLearnedWord(flashcards[currentIndex].word); } if(overlay){ overlay.style.opacity=1; overlay.style.background = dir==="right" ? "rgba(34,197,94,0.4)" : "rgba(239,68,68,0.4)"; } if(swipeText){ swipeText.textContent = dir==="right" ? "BİLİYORUM ✅" : "BİLMİYORUM ❌"; } if(activeCard){ activeCard.style.transition="transform .2s ease"; activeCard.style.transform="translateX("+(dir==="right"?innerWidth:-innerWidth)+"px)"; } setTimeout(()=>{ nextCardFlow(); if(activeCard){ activeCard.style.transition="none"; activeCard.style.transform="translateX(0)"; } if(overlay) overlay.style.opacity=0; },200); } if(listenBtn){ listenBtn.onclick = function(){ const a = activeCard ? activeCard.querySelector("audio") : null; if(a){ a.currentTime=0; a.play().catch(()=>{}); } }; } if(knowBtn){ knowBtn.onclick = function(){ if (flashcards[currentIndex]) saveLearnedWord(flashcards[currentIndex].word); slideCard("right"); if(ajaxUrl){ fetch(ajaxUrl, { method:"POST", headers:{ "Content-Type":"application/x-www-form-urlencoded" }, body:"action=flash_add_xp" }); fetch(ajaxUrl, { method:"POST", headers:{ "Content-Type":"application/x-www-form-urlencoded" }, body:"action=li_add_task_progress" }) .then(() => { if (window.refreshDailyTask) window.refreshDailyTask(); }); } }; } if(dontKnowBtn){ dontKnowBtn.onclick = function(){ slideCard("left"); }; } const repeatBtn = document.getElementById("repeat-btn"); if(repeatBtn){ repeatBtn.onclick = function(){ flashcards.length=0; (window.flashcardsFullSet || []).forEach(x=>flashcards.push(x)); currentIndex=0; completed=false; locked=false; if(activeCard) activeCard.classList.remove("gold-frame"); if(listenBtn) listenBtn.style.display="inline-block"; if(knowBtn) knowBtn.style.display="inline-block"; if(dontKnowBtn) dontKnowBtn.style.display="inline-block"; const pw = document.getElementById("progress-wrap"); if(pw) pw.style.display="block"; if(counterBox) counterBox.style.display="block"; if(doneBtns) doneBtns.style.display="none"; renderCard(activeCard, flashcards[0]); renderCard(nextCard, flashcards[1] || flashcards[0]); updateProgress(); updateCounter(); }; } // ✅ Sonraki set (scope içinde) const nextBtn = document.getElementById("next-btn"); if(nextBtn){ nextBtn.onclick = function () { const s = setKey; let next = ""; if (s.includes("-")) { const p = s.split("-"); const base = p[0]; const idx = parseInt(p[1], 10); next = base + "-" + (idx + 1); } else { next = s + "-2"; } if (!window.allSets || !window.allSets[next]) { alert("Bu setin devamı henüz eklenmedi."); return; } const pageNo = next.includes("-") ? next.split("-")[1] : "1"; window.location.href = "/ingilizce-25-kelime-set-" + pageNo + "/"; }; } // ✅ başlangıç (tek kez) if(!flashcards.length){ finishSet(); } else { showCards(); } });