2 Commits

5 changed files with 97 additions and 9 deletions
+4 -4
View File
@@ -4,10 +4,10 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>График прогрессии (просмотр)</title>
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="styles/components.css">
<link rel="stylesheet" href="styles/workout.css">
<link rel="stylesheet" href="styles/modal.css">
<link rel="stylesheet" href="styles/main.css?v=2">
<link rel="stylesheet" href="styles/components.css?v=2">
<link rel="stylesheet" href="styles/workout.css?v=2">
<link rel="stylesheet" href="styles/modal.css?v=2">
<style>
.chart-page { max-width: 760px; margin: 0 auto; padding: 16px; }
.chart-page h2 { margin: 14px 0 2px; }
+23
View File
@@ -26,12 +26,29 @@ export function showSettings() {
? state.workoutTypes.map(wt => `<option value="${wt.name}">${wt.name}</option>`).join('')
: '<option value="">(нет типов)</option>';
const goal = state.goal === 'endurance' ? 'endurance' : 'strength';
screen.innerHTML = `
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:20px;">
<h2>⚙️ Настройки</h2>
<button class="btn btn-small btn-secondary" onclick="App.backToMain()">← Назад</button>
</div>
<!-- 0. ЦЕЛЬ ТРЕНИРОВОК -->
<div class="card mb-10">
<h3>🎯 Цель тренировок</h3>
<p class="text-muted text-small mb-10">
По цели графики определяют прогресс и откат: «Сила» — по максимальному весу за тренировку,
«Выносливость» — по суммарному объёму (вес × повторы).
</p>
<div style="display:flex; gap:10px;">
<button class="btn big-touch ${goal === 'strength' ? 'btn-primary' : 'btn-secondary'}"
onclick="SettingsLogic.setGoal('strength')">💪 Сила</button>
<button class="btn big-touch ${goal === 'endurance' ? 'btn-primary' : 'btn-secondary'}"
onclick="SettingsLogic.setGoal('endurance')">🏃 Выносливость</button>
</div>
</div>
<!-- КНОПКА ОБНОВЛЕНИЯ СПРАВОЧНИКОВ -->
<div class="card mb-10" style="background: rgba(187, 134, 252, 0.1); border-color: var(--primary);">
<div style="display:flex; justify-content:space-between; align-items:center;">
@@ -750,6 +767,12 @@ window.SettingsLogic = {
show: showSettings,
refreshDicts, // <-- ДОБАВИЛИ В ЭКСПОРТ
setGoal(goal) {
state.goal = goal === 'endurance' ? 'endurance' : 'strength';
saveState();
showSettings();
},
// Metric Types
showAddMetricTypeModal,
submitMetricType,
+33 -5
View File
@@ -28,14 +28,26 @@ export function showChartDialog(exerciseName, clientId = null) {
const dayTop = p => byWeight ? p.maxWeight : Math.max(...p.sets.map(val), 0);
const dayTopReps = p => byWeight ? p.topReps : 0;
// Прогресс вершины относительно предыдущей тренировки
// Цель из настроек: «Сила» — по максимальному весу (тот же вес и больше
// повторов — тоже прогресс, но суммарный объём не учитывается);
// «Выносливость» — по суммарному объёму вес × повторы. По умолчанию — сила.
const goal = state.goal === 'endurance' ? 'endurance' : 'strength';
const volume = p => p.sets.reduce((a, s) => a + (s.weight || 0) * (s.reps || 0), 0);
const cls = i => {
if (i === 0) return 'chart-flat';
if (goal === 'endurance') {
const cur = volume(points[i]), prev = volume(points[i - 1]);
if (cur > prev) return 'chart-up';
if (cur < prev) return 'chart-down';
return 'chart-flat';
}
const cur = dayTop(points[i]), prev = dayTop(points[i - 1]);
if (cur > prev) return 'chart-up';
if (cur < prev) return 'chart-down';
if (byWeight && dayTopReps(points[i]) > dayTopReps(points[i - 1])) return 'chart-up';
if (byWeight && dayTopReps(points[i]) < dayTopReps(points[i - 1])) return 'chart-down';
// Тот же максимальный вес: больше повторов — лучше, меньше — хуже
if (dayTopReps(points[i]) > dayTopReps(points[i - 1])) return 'chart-up';
if (dayTopReps(points[i]) < dayTopReps(points[i - 1])) return 'chart-down';
return 'chart-flat';
};
const classes = points.map((_, i) => cls(i));
@@ -99,7 +111,17 @@ export function showChartDialog(exerciseName, clientId = null) {
showModal(`
<div class="modal-content modal-fullscreen">
<div class="modal-header"><span class="modal-title">📈 ${escapeHtml(exerciseName)}</span></div>
<div class="chart-sub chart-legend-top">линия — рабочий максимум «вес × повторы»: <b class="chart-up">зелёный — прогресс</b> (вес выше или тот же вес и больше повторов), <b class="chart-down">красный — откат</b>; тусклые точки — остальные подходы, ×N — их число</div>
<div class="chart-legend-big">
<span class="lg-line">— линия: максимум</span>
<span class="lg-up">зелёный: прогресс</span>
<span class="lg-down">красный: откат</span>
<button class="lg-info" onclick="CM.toggleChartHint(this)">ⓘ</button>
</div>
<div class="chart-hint" style="display:none">${
goal === 'endurance'
? 'Прогресс и откат считаются по <b>суммарному объёму</b> (вес × повторы за тренировку). Цель: «🏃 Выносливость» — сменить на «💪 Сила» можно в ⚙️ Настройках. Тусклые точки — остальные подходы, ×N под датой — их число.'
: 'Прогресс — <b>максимальный вес</b> за тренировку вырос (или тот же вес и больше повторов), откат — упал. Суммарный объём за тренировку не учитывается. Цель: «💪 Сила» — сменить на «🏃 Выносливость» можно в ⚙️ Настройках. Тусклые точки — остальные подходы, ×N под датой — их число.'
}</div>
<svg class="chart-svg" viewBox="0 0 ${W} ${H}">
<line x1="${padL}" y1="${y(vMin).toFixed(1)}" x2="${W - padR}" y2="${y(vMin).toFixed(1)}" class="chart-axis"/>
<line x1="${padL}" y1="${y(vMax).toFixed(1)}" x2="${W - padR}" y2="${y(vMax).toFixed(1)}" class="chart-axis"/>
@@ -126,6 +148,12 @@ export function showChartDialog(exerciseName, clientId = null) {
`);
}
// Пояснение к легенде — по тапу на ⓘ (на телефоне наведение не работает)
export function toggleChartHint(btn) {
const hint = btn.closest('.chart-legend-big')?.nextElementSibling;
if (hint) hint.style.display = hint.style.display === 'none' ? 'block' : 'none';
}
// Клик с кнопки в карточке: имя берём из data-атрибута (без экранирования в JS-строке)
export function showChartFromBtn(btn) {
const name = btn.dataset.ex;
@@ -133,4 +161,4 @@ export function showChartFromBtn(btn) {
showChartDialog(name, w ? w.client_id : null);
}
window.CM = { showChartDialog, showChartFromBtn };
window.CM = { showChartDialog, showChartFromBtn, toggleChartHint };
+3
View File
@@ -27,6 +27,9 @@ function freshState() {
mode: "personal",
currentClientId: null,
goal: "strength",
deletedWorkouts: [],
};
}
+34
View File
@@ -196,3 +196,37 @@ textarea { resize: vertical; min-height: 60px; }
line-height: 1.45;
margin: 2px 2px 10px;
}
/* Броская легенда графика: три коротких чипа + ⓘ с пояснением */
.chart-legend-big {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 14px;
font-size: 19px;
font-weight: 700;
margin: 2px 2px 8px;
}
.lg-line { color: #fff; }
.lg-up { color: #3ddc55; }
.lg-down { color: #ff5a5a; }
.lg-info {
width: 32px;
height: 32px;
border-radius: 50%;
border: 1.5px solid #777;
background: transparent;
color: #ccc;
font-size: 16px;
font-weight: 700;
line-height: 1;
}
.chart-hint {
font-size: 14.5px;
line-height: 1.5;
color: #d5d5d5;
background: rgba(255, 255, 255, 0.07);
border-radius: 12px;
padding: 10px 14px;
margin: 0 2px 10px;
}