diff --git a/czytanie.html b/czytanie.html new file mode 100644 index 0000000..7bf6514 --- /dev/null +++ b/czytanie.html @@ -0,0 +1,53 @@ + + +
+ + +Nie udało się wczytać tekstów.
' + }) + + customStartBtn.addEventListener('click', () => { + const txt = customInput.value.trim() + if (!txt) return + startReading('Własny', txt) + }) + + // ── Start reading ───────────────────────────────────────────────────────── + function startReading(title, text) { + yOffset = 0 + speedIdx = 0 + clearInterval(autoTimer) + autoTimer = null + + readTitleEl.textContent = title + readTextEl.textContent = text + readTextEl.style.transform = 'translateY(0)' + speedBtn.textContent = SPEED_LABELS[0] + + listWrap.classList.add('hidden') + readWrap.classList.remove('hidden') + + // measure real line height after layout + requestAnimationFrame(() => { + requestAnimationFrame(() => { + const cs = getComputedStyle(readTextEl) + const lhVal = cs.lineHeight + lineH = (lhVal === 'normal') + ? parseFloat(cs.fontSize) * 1.35 + : parseFloat(lhVal) + + maxOffset = Math.max(0, readTextEl.offsetHeight - readViewport.offsetHeight) + updateNextBtn() + }) + }) + } + + // ── Back to list ────────────────────────────────────────────────────────── + readBackBtn.addEventListener('click', () => { + const active = yOffset > 0 || autoTimer !== null + if (active && !confirm('Wrócić do listy tekstów?')) return + clearInterval(autoTimer) + autoTimer = null + readWrap.classList.add('hidden') + listWrap.classList.remove('hidden') + }) + + // ── Speed selector ──────────────────────────────────────────────────────── + speedBtn.addEventListener('click', () => { + clearInterval(autoTimer) + autoTimer = null + speedIdx = (speedIdx + 1) % SPEEDS_MS.length + speedBtn.textContent = SPEED_LABELS[speedIdx] + if (SPEEDS_MS[speedIdx] > 0 && yOffset < maxOffset) { + autoTimer = setInterval(advanceLine, SPEEDS_MS[speedIdx]) + } + }) + + // ── Manual line advance ─────────────────────────────────────────────────── + nextLineBtn.addEventListener('click', advanceLine) + + // ── Core scroll logic ───────────────────────────────────────────────────── + function advanceLine() { + if (yOffset >= maxOffset) { + stopAutoAtEnd() + return + } + yOffset = Math.min(yOffset + lineH, maxOffset) + readTextEl.style.transform = `translateY(${-yOffset}px)` + updateNextBtn() + if (yOffset >= maxOffset) stopAutoAtEnd() + } + + function stopAutoAtEnd() { + if (autoTimer !== null) { + clearInterval(autoTimer) + autoTimer = null + speedIdx = 0 + speedBtn.textContent = SPEED_LABELS[0] + } + updateNextBtn() + } + + function updateNextBtn() { + nextLineBtn.disabled = yOffset >= maxOffset + } +})() diff --git a/dyktanda.json b/dyktanda.json new file mode 100644 index 0000000..ffa19bf --- /dev/null +++ b/dyktanda.json @@ -0,0 +1,22 @@ +[ + { + "name": "Wiosenna wycieczka", + "text": "W sobotę Krzyś i Jurek pojechali z mamą do lasu. Wśród dużych drzew rosły żółte kwiaty i czerwone grzyby. Chłopcy słuchali śpiewu ptaków i szumu strumyka. Później zjedli bułki, jabłka i gorącą herbatę." + }, + { + "name": "Na podwórku", + "text": "Hania huśtała się na huśtawce obok wysokiego płotu. Jej koleżanka Róża jeździła na różowym rowerze. Na chodniku bawiły się trzy małe kotki. Wieczorem dziewczynki wróciły do domu bardzo wesołe." + }, + { + "name": "W kuchni babci", + "text": "Babcia upiekła pyszne drożdżowe bułeczki z różą i jabłkami. W dużym garnku gotowała się zupa jarzynowa. Henio pomagał kroić marchewkę i ogórki. Po obiedzie wszyscy chrupali kruche ciasteczka." + }, + { + "name": "Zimowy poranek", + "text": "W grudniu spadł puszysty śnieg i zrobiło się chłodno. Przed szkołą dzieci lepiły dużego bałwana. Grześ rzucał śnieżkami, a Hela ciągnęła sanki. Po zabawie wszyscy pili gorącą czekoladę." + }, + { + "name": "W zoo", + "text": "W warszawskim zoo Zuzia zobaczyła żyrafę i małego żubra. Obok wybiegów chodziły pawie i hałaśliwe papugi. Pan przewodnik opowiadał ciekawostki o zwierzętach. Na końcu wycieczki dzieci kupiły pamiątkowe magnesy." + } +] diff --git a/dzielenie.html b/dzielenie.html index 4e8f7d1..d02f7f4 100644 --- a/dzielenie.html +++ b/dzielenie.html @@ -8,12 +8,7 @@