@@ -35,7 +35,7 @@
|
|||||||
const summaryScore = document.getElementById('summary-score')
|
const summaryScore = document.getElementById('summary-score')
|
||||||
const summaryBackBtn = document.getElementById('summary-back-btn')
|
const summaryBackBtn = document.getElementById('summary-back-btn')
|
||||||
const dykScroll = document.getElementById('dyk-scroll')
|
const dykScroll = document.getElementById('dyk-scroll')
|
||||||
const progressBar = document.getElementById('dyk-progress-bar-inner')
|
let progressBar = null
|
||||||
|
|
||||||
// ── Load texts ────────────────────────────────────────────────────────────
|
// ── Load texts ────────────────────────────────────────────────────────────
|
||||||
fetch('json/dyktanda.json')
|
fetch('json/dyktanda.json')
|
||||||
@@ -53,6 +53,20 @@
|
|||||||
textList.innerHTML = '<p style="color:var(--muted)">Nie udało się wczytać tekstów.</p>'
|
textList.innerHTML = '<p style="color:var(--muted)">Nie udało się wczytać tekstów.</p>'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Poczekaj na dynamiczne załadowanie progress bara
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
// progress bar jest ładowany przez loadComponent w dyktando.html
|
||||||
|
const checkProgressBar = () => {
|
||||||
|
const el = document.getElementById('dyk-progress-bar-inner')
|
||||||
|
if (el) {
|
||||||
|
progressBar = el
|
||||||
|
} else {
|
||||||
|
setTimeout(checkProgressBar, 50)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkProgressBar()
|
||||||
|
})
|
||||||
|
|
||||||
customStartBtn.addEventListener('click', () => {
|
customStartBtn.addEventListener('click', () => {
|
||||||
const txt = customInput.value.trim()
|
const txt = customInput.value.trim()
|
||||||
if (!txt) return
|
if (!txt) return
|
||||||
@@ -98,7 +112,7 @@
|
|||||||
textDisplay.classList.remove('hidden')
|
textDisplay.classList.remove('hidden')
|
||||||
choicesEl.classList.remove('hidden')
|
choicesEl.classList.remove('hidden')
|
||||||
progressEl.textContent = ''
|
progressEl.textContent = ''
|
||||||
progressBar.style.width = '0%'
|
if (progressBar) progressBar.style.width = '0%'
|
||||||
|
|
||||||
listWrap.classList.add('hidden')
|
listWrap.classList.add('hidden')
|
||||||
playWrap.classList.remove('hidden')
|
playWrap.classList.remove('hidden')
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
const problemEl = document.getElementById('problem')
|
const problemEl = document.getElementById('problem')
|
||||||
const answerEl = document.getElementById('answer')
|
const answerEl = document.getElementById('answer')
|
||||||
const feedbackEl = document.getElementById('feedback')
|
const feedbackEl = document.getElementById('feedback')
|
||||||
const progressInner = document.getElementById('progress-inner')
|
let progressInner = null
|
||||||
const progressLabel = document.getElementById('progress-label')
|
const progressLabel = document.getElementById('progress-label')
|
||||||
const summaryText = document.getElementById('summary-text')
|
const summaryText = document.getElementById('summary-text')
|
||||||
const totalInput = document.getElementById('total-input')
|
const totalInput = document.getElementById('total-input')
|
||||||
@@ -99,7 +99,10 @@
|
|||||||
|
|
||||||
function updateBar() {
|
function updateBar() {
|
||||||
const pct = st.total > 0 ? Math.round((st.solved / st.total) * 100) : 0
|
const pct = st.total > 0 ? Math.round((st.solved / st.total) * 100) : 0
|
||||||
progressInner.style.width = pct + '%'
|
if (!progressInner) {
|
||||||
|
progressInner = document.getElementById('progress-inner')
|
||||||
|
}
|
||||||
|
if (progressInner) progressInner.style.width = pct + '%'
|
||||||
progressLabel.textContent = `${st.solved}/${st.total}`
|
progressLabel.textContent = `${st.solved}/${st.total}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user