diff --git a/czytanie.html b/czytanie.html new file mode 100644 index 0000000..7bf6514 --- /dev/null +++ b/czytanie.html @@ -0,0 +1,53 @@ + + + + + + Czytanie + + + + + +
+ +
+
+

📖 Czytanie

+ +
+

Wybierz tekst

+
+
+ +
+

Własny tekst

+ + +
+
+
+
+ + + + + + + + diff --git a/czytanie.js b/czytanie.js new file mode 100644 index 0000000..608d026 --- /dev/null +++ b/czytanie.js @@ -0,0 +1,126 @@ +// Nauka Czytania +;(function () { + // ms between line advances for each speed level (0 = manual) + const SPEEDS_MS = [0, 3500, 2000, 1000] + const SPEED_LABELS = ['⏸', '▶', '▶▶', '▶▶▶'] + + let yOffset = 0 + let lineH = 80 // recalculated after render + let maxOffset = 0 + let speedIdx = 0 + let autoTimer = null + + const listWrap = document.getElementById('list-wrap') + const readWrap = document.getElementById('read-wrap') + const textList = document.getElementById('text-list') + const customInput = document.getElementById('custom-input') + const customStartBtn = document.getElementById('custom-start-btn') + const readBackBtn = document.getElementById('read-back-btn') + const readTitleEl = document.getElementById('read-title') + const speedBtn = document.getElementById('speed-btn') + const readViewport = document.getElementById('read-viewport') + const readTextEl = document.getElementById('read-text') + const nextLineBtn = document.getElementById('next-line-btn') + + // ── Load text list from dyktanda.json ──────────────────────────────────── + fetch('dyktanda.json') + .then(r => r.json()) + .then(data => { + data.forEach(item => { + const btn = document.createElement('button') + btn.className = 'reading-item' + btn.textContent = item.name + btn.addEventListener('click', () => startReading(item.name, item.text)) + textList.appendChild(btn) + }) + }) + .catch(() => { + textList.innerHTML = '

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 @@
diff --git a/index.html b/index.html index 03239fe..8d1b623 100644 --- a/index.html +++ b/index.html @@ -3,157 +3,50 @@ - Trening Matematyczny - Dodawanie/Odejmowanie + Edu — Główne Menu - -
-
-

Matma Trening

-
-

Wybierz działania

-
- - - - -
-
- -
-

Tryb gry

-
- - -
-

Wybierz co najmniej jedno działanie, a następnie tryb, aby rozpocząć.

-
- -
-

Historia - -

- -
- -
-

- Ustawienia - -

- -
-
- -
-
-
- -
-
-
Trening
-
-
-
0
-
-
-
- -
- -
- -
- -
-
-
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
-
- - -
-
- - - - - - + + diff --git a/mnozenie.html b/mnozenie.html index 3da5fff..e927987 100644 --- a/mnozenie.html +++ b/mnozenie.html @@ -8,12 +8,7 @@
diff --git a/nav.js b/nav.js index afeb52c..3893853 100644 --- a/nav.js +++ b/nav.js @@ -1,18 +1,17 @@ -// Shared hamburger menu toggle +// Back-to-hub button with active-task confirmation (function () { document.addEventListener('DOMContentLoaded', () => { - const btn = document.getElementById('hamburger-btn') - const menu = document.getElementById('hamburger-menu') - if (!btn || !menu) return - btn.addEventListener('click', (e) => { - e.stopPropagation() - menu.classList.toggle('open') - }) - document.addEventListener('click', () => menu.classList.remove('open')) - // mark active link - const current = location.pathname.split('/').pop() || 'index.html' - menu.querySelectorAll('a').forEach(a => { - if (a.getAttribute('href') === current) a.classList.add('active') + const backBtn = document.getElementById('back-to-hub') + if (!backBtn) return + + backBtn.addEventListener('click', (e) => { + const playScreen = document.getElementById('play-screen') + const taskActive = playScreen && !playScreen.classList.contains('hidden') + if (taskActive) { + e.preventDefault() + const ok = confirm('Masz aktywne zadanie. Czy na pewno chcesz wyjść do menu?') + if (ok) window.location.href = backBtn.getAttribute('href') + } }) }) })() diff --git a/styles.css b/styles.css index 7298880..3170fb4 100644 --- a/styles.css +++ b/styles.css @@ -65,16 +65,6 @@ body{ .app-footer{font-size:12px;color:var(--muted);text-align:center;padding:10px 0;width:100%;max-width:420px} -/* ── Hamburger nav ── */ -.nav-wrap{position:relative;width:100%;max-width:420px;display:flex;justify-content:flex-end;padding:6px 8px 0} -.hamburger-btn{background:var(--card);border:1px solid #e6e9ef;border-radius:10px;padding:8px 12px;font-size:20px;cursor:pointer;line-height:1;box-shadow:0 2px 8px rgba(16,24,40,0.07)} -.hamburger-menu{display:none;position:absolute;top:46px;right:8px;background:var(--card);border:1px solid #e6e9ef;border-radius:14px;box-shadow:0 8px 24px rgba(16,24,40,0.13);z-index:100;min-width:210px;overflow:hidden} -.hamburger-menu.open{display:block} -.hamburger-menu a{display:flex;align-items:center;gap:10px;padding:14px 18px;text-decoration:none;color:#111;font-size:16px;border-bottom:1px solid #f0f0f3} -.hamburger-menu a:last-child{border-bottom:none} -.hamburger-menu a:hover,.hamburger-menu a.active{background:#f0f4ff;color:var(--accent)} -.hamburger-menu a .nav-icon{font-size:20px;width:24px;text-align:center} - /* ── Shared learn-page styles ── */ .learn-title{margin:20px 16px 0;font-size:22px;font-weight:700;text-align:center} .learn-subtitle{text-align:center;color:var(--muted);font-size:14px;margin:4px 16px 12px} @@ -92,9 +82,49 @@ body{ .screen{max-height:94vh} } +/* ── Back-to-hub button ── */ +.nav-wrap{position:relative;width:100%;max-width:420px;display:flex;justify-content:flex-start;padding:6px 8px 0} +.back-to-hub{display:inline-flex;align-items:center;gap:6px;padding:8px 14px;background:var(--card);border:1px solid #e6e9ef;border-radius:10px;font-size:15px;font-weight:600;color:var(--accent);text-decoration:none;box-shadow:0 2px 8px rgba(16,24,40,0.07);cursor:pointer} +.back-to-hub:hover{background:#f0f4ff} + +/* ── Hub page ── */ +.hub-screen{padding-bottom:20px} +.hub-logo{font-size:26px;padding:20px 0 4px} +.hub-group{padding:14px 18px} +.hub-group-title{font-size:15px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:0 0 12px} +.hub-cards{display:flex;flex-direction:column;gap:10px} +.hub-card{display:flex;align-items:center;gap:14px;padding:14px 16px;border-radius:12px;border:1px solid #e6e9ef;background:white;text-decoration:none;color:#111;font-size:17px;font-weight:500;transition:background .15s,box-shadow .15s} +.hub-card:hover{background:#f0f4ff;box-shadow:0 4px 14px rgba(43,108,176,0.12);color:var(--accent)} +.hub-card-icon{font-size:22px;width:32px;text-align:center;flex-shrink:0} +.hub-card-label{flex:1} +.hub-card-badge{font-size:11px;font-weight:600;padding:3px 8px;border-radius:20px;background:#f3f4f6;color:var(--muted)} +.hub-card--disabled{opacity:.55;cursor:default;pointer-events:none} + /* Mobile-specific: ensure the app fills viewport and screens scroll vertically */ @media (max-width:480px){ body{padding:0} .app-wrap{max-width:100%;height:100vh} .screen{height:100vh;max-height:none;border-radius:0;overflow:auto;-webkit-overflow-scrolling:touch} } + +/* ── Czytanie — list screen ── */ +.reading-list{display:flex;flex-direction:column;gap:8px} +.reading-item{width:100%;padding:14px 16px;border-radius:10px;border:1px solid #e6e9ef;background:white;text-align:left;font-size:16px;font-family:inherit;cursor:pointer} +.reading-item:hover,.reading-item:active{background:#f0f4ff;color:var(--accent)} +.custom-input{width:100%;min-height:100px;padding:10px 12px;border-radius:10px;border:1px solid #e6e9ef;font-size:15px;font-family:inherit;resize:vertical;margin-bottom:10px;display:block} + +/* ── Czytanie — reading screen ── */ +.read-wrap{position:fixed;inset:0;background:white;display:flex;flex-direction:column;z-index:50} +.read-wrap.hidden{display:none} + +.read-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 12px;padding-top:max(10px,env(safe-area-inset-top));background:white;border-bottom:1px solid #e6e9ef;flex-shrink:0} +.read-nav-btn{padding:8px 14px;border-radius:10px;border:1px solid #e6e9ef;background:white;font-size:15px;font-weight:600;cursor:pointer;white-space:nowrap;flex-shrink:0} +.read-nav-btn:hover{background:#f0f4ff;color:var(--accent)} +.read-speed-btn{min-width:52px;text-align:center;letter-spacing:.05em} +.read-title-text{flex:1;text-align:center;font-size:15px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#111} + +.read-viewport{flex:1;overflow:hidden;padding:20px 20px 0;position:relative} +.read-text{font-size:clamp(52px,16vw,82px);font-weight:700;line-height:1.35;word-break:break-word;overflow-wrap:break-word;hyphens:auto;color:#111;transition:transform .32s cubic-bezier(.4,0,.2,1);will-change:transform} + +.next-line-btn{position:absolute;bottom:max(24px,calc(env(safe-area-inset-bottom) + 12px));right:20px;width:64px;height:64px;border-radius:50%;background:var(--accent);color:white;font-size:26px;border:none;box-shadow:0 4px 20px rgba(43,108,176,.38);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:opacity .2s} +.next-line-btn:disabled{opacity:.3;cursor:default} diff --git a/testy.html b/testy.html new file mode 100644 index 0000000..b99a3ff --- /dev/null +++ b/testy.html @@ -0,0 +1,154 @@ + + + + + + Testy Matematyczne + + + + +
+
+

Matma Trening

+ +
+

Wybierz działania

+
+ + + + +
+
+ +
+

Tryb gry

+
+ + +
+

Wybierz co najmniej jedno działanie, a następnie tryb, aby rozpocząć.

+
+ +
+

Historia + +

+ +
+ +
+

+ Ustawienia + +

+ +
+
+ +
+
+
+ +
+
+
Trening
+
+
+
0
+
+
+
+ +
+ +
+ +
+ +
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+ + +
+
+ +
Version: (loading)
+ + + + + +