diff --git a/index.html b/index.html index 1bdffc8..83d42e9 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,11 @@ .item .i-sub { font-size: var(--kt-ai-text-2xs); color: var(--kt-ai-fg-muted); } .item .i-end { margin-left: auto; display: flex; align-items: center; gap: var(--kt-ai-space-3); flex: 0 0 auto; } + /* группа физзанятий и подпункты */ + .item.group { background: var(--kt-ai-bg-soft); border: 1px solid var(--kt-ai-border); } + .item.group.done { border-color: var(--kt-ai-primary); } + .task.child { margin-left: var(--kt-ai-space-6); padding: var(--kt-ai-space-2) var(--kt-ai-space-4); } + /* сегмент-кнопки отметки оценок */ .seg-sm { display: inline-flex; gap: 2px; background: var(--kt-ai-bg-soft); border: 1px solid var(--kt-ai-border); border-radius: var(--kt-ai-radius-lg); padding: 2px; } .seg-sm .s { min-width: 30px; height: 24px; display: inline-grid; place-items: center; border: none; background: transparent; border-radius: var(--kt-ai-radius-md); font-size: var(--kt-ai-text-2xs); font-weight: var(--kt-ai-weight-medium); color: var(--kt-ai-fg-muted); cursor: pointer; padding: 0 5px; } diff --git a/script.js b/script.js index 780d0be..612ea0a 100644 --- a/script.js +++ b/script.js @@ -14,6 +14,10 @@ const LESSONS = [ const SPORT = [ { id: "training", name: "Дзюдо", sub: "Секция, 1,5 часа", pts: 10, done: false }, + { id: "phys", type: "group", name: "Физические занятия", sub: "Подтягивания и отжимания, 3 подхода", pts: 10, children: [ + { id: "pullups", name: "Подтягивания", sub: "3 подхода" }, + { id: "pushups", name: "Отжимания", sub: "3 подхода" } + ] }, { id: "walk", name: "Активность", sub: "Прогулка 6000+ шагов", pts: 5, done: false }, { id: "sleep", name: "Сон", sub: "Выспался ≥ 8 часов", pts: 5, done: false } ]; @@ -59,7 +63,10 @@ function load() { const d = JSON.parse(raw); if (!d || d.day !== todayStr()) return; if (Array.isArray(d.lessons)) lessons = d.lessons; - if (Array.isArray(d.sport)) sport = d.sport.map((s) => ({ ...s, pts: (SPORT.find((x) => x.id === s.id) || {}).pts, done: !!s.done })); + if (Array.isArray(d.sport)) sport = d.sport.map((s) => { + const tmpl = SPORT.find((x) => x.id === s.id) || {}; + return { ...s, pts: tmpl.pts, done: !!s.done, children: tmpl.children ? (s.children ? s.children.map((c) => ({ ...c, done: !!c.done })) : tmpl.children.map((c) => ({ ...c }))) : undefined }; + }); if (Array.isArray(d.home)) home = d.home.map((t) => ({ ...t, pts: (HOME.find((x) => x.id === t.id) || {}).pts, done: !!t.done })); if (Array.isArray(d.routine)) routine = d.routine.map((r) => ({ ...r, pts: (ROUTINE.find((x) => x.id === r.id) || {}).pts, done: !!r.done })); } catch (e) {} @@ -111,9 +118,43 @@ function renderLessons() { } function renderSport() { + syncSportGroups(); const box = document.getElementById("sport-list"); box.innerHTML = ""; sport.forEach((s) => { + if (s.type === "group") { + const doneCount = s.children.filter((c) => c.done).length; + const row = el(` +