Добавить
Короткое и понятное поле.
diff --git a/script.js b/script.js
index f83cd89..4b85838 100644
--- a/script.js
+++ b/script.js
@@ -8,27 +8,49 @@ const state = {
],
phrases: [
{ id: 1, text: "Мне вода", situation: "завтрак", status: "показываю" },
- { id: 2, text: "Мама иди", situation: "вечер", status: "говорю" }
+ { id: 2, text: "Мама иди", situation: "вечер", status: "говорю" },
+ { id: 3, text: "Хочу ещё", situation: "обед", status: "слышит" }
],
tasks: [
- { id: 1, title: "Повторить 3 слова за завтраком", duration: 5, done: true },
- { id: 2, title: "Игра «назови звук»", duration: 10, done: false }
- ],
- goals: [
- { id: 1, title: "Назвать 10 предметов вокруг", progress: 45 },
- { id: 2, title: "Сказать «хочу ещё»", progress: 70 }
+ { id: 1, title: "Повторить 3 слова за завтраком", section: "phrases", duration: 5, done: true },
+ { id: 2, title: "Игра «назови звук»", section: "activity", duration: 7, done: false },
+ { id: 3, title: "Артикуляционная игра перед зеркалом", section: "articulation", duration: 3, done: false }
],
journal: [
- { id: 1, date: "2026-11-10", text: "Повторили названия еды. Сам сказал «яблоко», два раза." }
+ { id: 1, date: "2026-11-10", section: "phrases", text: "Повторили названия еды. Сам сказал «яблоко», два раза." }
+ ],
+ comprehension: [
+ { id: 1, title: "Покажи пальчиком предмет", section: "comprehension" },
+ { id: 2, title: "Принеси игрушку", section: "comprehension" }
+ ],
+ activity: [
+ { id: 1, title: "Звуки животных", section: "activity" },
+ { id: 2, title: "Привет и пока", section: "activity" }
+ ],
+ articulation: [
+ { id: 1, title: "Широкая улыбка", section: "articulation" },
+ { id: 2, title: "Губы Трубочка", section: "articulation" }
+ ],
+ games: [
+ { id: 1, title: "Кукла просит пить", section: "games" },
+ { id: 2, title: "Пальчики-барабанщики", section: "games" }
]
};
function el(id) { return document.getElementById(id); }
function esc(s) { return String(s ?? "").replace(/[&<>"']/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c])); }
function statusPill(status) {
+ if (!status) return `
новое`;
const variant = { "слышит": "info", "понятно": "info", "говорю": "success", "показываю": "default", "не видно": "danger" }[status] || "default";
return `
${esc(status)}`;
}
+function renderMiniList(id, items, subtitle, emptyText) {
+ const node = el(id);
+ if (!node) return;
+ node.innerHTML = (items || []).slice(0, 4).map(item => `
+
${esc(item.text || item.title || "")}
${esc(item.situation || item.tip || subtitle || "")}
${esc(subtitle || "")}
+ `).join("") || `
${esc(emptyText || "Пока пусто.")}
`;
+}
async function api(payload) {
try {
@@ -59,12 +81,30 @@ async function loadData() {
return;
}
} catch (_) {}
- await api({ kind: "sync", child: state.child, words: state.words, phrases: state.phrases, tasks: state.tasks, goals: state.goals, journal: state.journal });
+ await api({ kind: "sync", ...state });
render();
}
function render() {
- el("child-line").textContent = `${state.child.name || "Ребёнок"}, ${state.child.age || "возраст"}. ${state.child.note || ""}`;
+ const child = state.child || { name: "Ребёнок", age: "", note: "" };
+ el("child-line").textContent = `${child.name || "Ребёнок"}, ${child.age || "возраст"}. ${child.note || ""}`;
+ renderMiniList("words-mini", state.words, "новые слова", "Добавь первое слово.");
+ renderMiniList("phrases-mini", state.phrases, "короткие фразы", "Добавь первую фразу.");
+ renderMiniList("comprehension-today", state.comprehension, "сейчас пробуем", "Добавь короткую игру.");
+ renderMiniList("activity-today", state.activity, "маленькие шаги", "Добавь звук или приветствие.");
+ renderMiniList("articulation-today", state.articulation, "играем с языком", "Добавь артикуляционную игру.");
+ renderMiniList("games-today", state.games, "игровая деятельность", "Добавь игру дня.");
+ const phraseGames = [
+ "Театр из игрушек: кукла просит пить",
+ "Повторение фразы на кухне",
+ "Песенка с «хочу ещё!»"
+ ];
+ renderMiniList("phrase-games", phraseGames.map((t, i) => ({ title: t })), "игры", "Добавь игру.");
+ const recentJournal = state.journal.slice(0, 2).map(j => ({ title: j.text, situation: j.date, section: j.section }));
+ renderMiniList("recent-journal", recentJournal, "наблюдения", "Запиши первую заметку.");
+ const done = state.tasks.filter(t => t.done).length;
+ const total = Math.max(state.tasks.length, 1);
+ el("today-progress").style.width = `${(done / total) * 100}%`;
el("words-tbody").innerHTML = state.words.map(w => `
| ${esc(w.text)} |
@@ -87,23 +127,6 @@ function render() {
`).join("") || `Добавь одно короткое занятие на сегодня.
`;
- el("goals-list").innerHTML = state.goals.map(g => `
-
-
${esc(g.title)}
${g.progress || 0}%
-
-
- `).join("") || `Добавь цель месяца.
`;
-
- const done = state.tasks.filter(t => t.done).length;
- const heard = state.words.filter(w => w.status !== "слышит").length;
- el("home-stats").innerHTML = `
- ${done} из ${state.tasks.length}
занятий сегодня
- ${heard} из ${state.words.length}
слов уже откликается
- ${state.journal.length}
записей в журнале
- `;
-
- const last = state.journal[0] || null;
- el("journal-last").innerHTML = last ? `${esc(last.date || "")}
${esc(last.text || "")}
` : `Добавь первую короткую заметку после занятия.
`;
el("journal-list").innerHTML = state.journal.slice(1).map(j => `${esc(j.date || "")}
${esc(j.text || "")}
`).join("") || `Следующие записи появятся здесь.
`;
}
@@ -123,7 +146,7 @@ window.toggleTask = async function (id, done) {
};
function persist() {
- return api({ kind: "sync", child: state.child, words: state.words, phrases: state.phrases, tasks: state.tasks, goals: state.goals, journal: state.journal });
+ return api({ kind: "sync", ...state });
}
function openDrawer(key) {
@@ -132,9 +155,8 @@ function openDrawer(key) {
child: { title: "Ребёнок", sub: "Данные для плана и наблюдений", html: `` },
word: { title: "Новое слово", sub: "Одно слово или короткий звук", html: `` },
phrase: { title: "Новая фраза", sub: "Короткая конструкция из 2-3 слов", html: `` },
- task: { title: "Занятие на день", sub: "Короткая и понятная задача", html: `` },
- goal: { title: "Цель месяца", sub: "На что смотрим в течение месяца", html: `` },
- journal: { title: "Запись в журнал", sub: "Что получилось и что попробовать завтра", html: `` }
+ task: { title: "Занятие на день", sub: "Короткая и понятная задача", html: `` },
+ journal: { title: "Запись в журнал", sub: "Что получилось и что попробовать завтра", html: `` }
};
const preset = presets[key] || presets.word;
el("drawer").hidden = false;
@@ -147,9 +169,8 @@ async function saveDrawer(key, data) {
if (key === "child") state.child = { ...state.child, name: data.name, age: data.age, note: data.note };
if (key === "word") state.words.unshift({ id: Date.now(), text: data.text, group: data.group, status: data.status, tip: data.tip });
if (key === "phrase") state.phrases.unshift({ id: Date.now(), text: data.text, situation: data.situation, status: data.status });
- if (key === "task") state.tasks.unshift({ id: Date.now(), title: data.title, duration: Number(data.duration || 5), done: data.done === "1" });
- if (key === "goal") state.goals.unshift({ id: Date.now(), title: data.title, progress: Number(data.progress || 0) });
- if (key === "journal") state.journal.unshift({ id: Date.now(), date: data.date || new Date().toISOString().slice(0, 10), text: data.text });
+ if (key === "task") state.tasks.unshift({ id: Date.now(), title: data.title, section: data.section || "activity", duration: Number(data.duration || 5), done: data.done === "1" });
+ if (key === "journal") state.journal.unshift({ id: Date.now(), date: data.date || new Date().toISOString().slice(0, 10), text: data.text, section: data.section || "" });
render();
toast("Сохранено");
await persist();
diff --git a/server.js b/server.js
index dc255e1..604652e 100644
--- a/server.js
+++ b/server.js
@@ -10,7 +10,11 @@ const EMPTY = {
phrases: [],
tasks: [],
goals: [],
- journal: []
+ journal: [],
+ comprehension: [],
+ activity: [],
+ articulation: [],
+ games: []
};
function load() {
@@ -54,8 +58,12 @@ const server = http.createServer(async (req, res) => {
data.tasks = payload.tasks || data.tasks;
data.goals = payload.goals || data.goals;
data.journal = payload.journal || data.journal;
+ data.comprehension = payload.comprehension || data.comprehension;
+ data.activity = payload.activity || data.activity;
+ data.articulation = payload.articulation || data.articulation;
+ data.games = payload.games || data.games;
} else {
- for (const key of ["child", "words", "phrases", "tasks", "goals", "journal"]) {
+ for (const key of ["child", "words", "phrases", "tasks", "goals", "journal", "comprehension", "activity", "articulation", "games"]) {
if (payload[key] !== undefined) data[key] = payload[key];
}
}