diff --git a/app/app.js b/app/app.js index 078a56b..e13b56a 100644 --- a/app/app.js +++ b/app/app.js @@ -1133,6 +1133,7 @@ function stepperHTML(id, val, step, label) { `; } function bindSteppers(root) { + root.querySelectorAll('.step input').forEach(inp => inp.addEventListener('focus', () => setTimeout(() => inp.select(), 0))); root.querySelectorAll('[data-st]').forEach(b => b.addEventListener('click', () => { const inp = root.querySelector('#' + b.dataset.for); const v = (parseFloat(inp.value) || 0) + parseFloat(b.dataset.st); @@ -1250,10 +1251,10 @@ function renderActive(app) {
${esc(A.name)}
-
0:00 ยท ${doneSets}/${totalSets} sets
+
0:00 ยท ${doneSets}/${totalSets} sets
-
+
${entry ? renderExerciseCard(entry, cur, A.entries.length) : `
๐ŸŽฏ
Freestyle workout โ€” add your first exercise.
`}
@@ -1265,6 +1266,7 @@ function renderActive(app) {
+
`; @@ -1315,14 +1317,14 @@ function renderExerciseCard(entry, idx, total) { ${last ? `
Last time (${fmtDate(last.d)}): ${last.sets.map(s => fmtNum(s.w) + 'ร—' + s.r).join(', ')}
` : ''} ${hint}
+
Weight (${S.unit})Reps
${entry.sets.map((s, i) => `
${i + 1}
- -
- +
+
-
+
@@ -1332,8 +1334,19 @@ function renderExerciseCard(entry, idx, total) {
`; } +function updateWorkoutHeader() { + const A = S.active; if (!A) return; + const total = A.entries.reduce((n, e) => n + e.sets.length, 0); + const done = setsDoneActive(); + const c = $('#wo-count'); if (c) c.textContent = done + '/' + total; + const p = $('#wo-prog'); if (p) p.style.width = (total ? done / total * 100 : 0) + '%'; +} function bindExerciseCard(app, entry) { const A = S.active; + // tapping a number field selects its content so typing replaces instead of appending ("060") + app.querySelectorAll('.setrow input').forEach(inp => { + inp.addEventListener('focus', () => setTimeout(() => inp.select(), 0)); + }); bindMediaToggle($('#wo-media'), EXIDX[entry.id]); const info = $('#wo-info'); if (info) info.onclick = () => exerciseDetailSheet(EXIDX[entry.id]); @@ -1345,20 +1358,24 @@ function bindExerciseCard(app, entry) { save(); route(); toast('Weights bumped to ' + fmtNum(w) + ' ' + S.unit + ' ๐Ÿ’ช'); }; app.querySelectorAll('[data-win]').forEach(inp => inp.addEventListener('change', () => { - entry.sets[+inp.dataset.win].w = Math.max(0, parseFloat(inp.value) || 0); save(); + const v = Math.max(0, parseFloat(inp.value) || 0); + entry.sets[+inp.dataset.win].w = v; inp.value = v; save(); // normalize display ("060" -> "60") })); app.querySelectorAll('[data-rin]').forEach(inp => inp.addEventListener('change', () => { - entry.sets[+inp.dataset.rin].r = Math.max(0, Math.round(parseFloat(inp.value) || 0)); save(); + const v = Math.max(0, Math.round(parseFloat(inp.value) || 0)); + entry.sets[+inp.dataset.rin].r = v; inp.value = v; save(); })); app.querySelectorAll('[data-sw]').forEach(b => b.addEventListener('click', () => { const s = entry.sets[+b.dataset.si]; - s.w = Math.max(0, Math.round((s.w + parseFloat(b.dataset.sw)) * 100) / 100); - save(); app.querySelector(`[data-win="${b.dataset.si}"]`).value = s.w; + const inp = app.querySelector(`[data-win="${b.dataset.si}"]`); + s.w = Math.max(0, Math.round(((parseFloat(inp.value) || 0) + parseFloat(b.dataset.sw)) * 100) / 100); + save(); inp.value = s.w; })); app.querySelectorAll('[data-sr]').forEach(b => b.addEventListener('click', () => { const s = entry.sets[+b.dataset.si]; - s.r = Math.max(0, s.r + parseInt(b.dataset.sr)); - save(); app.querySelector(`[data-rin="${b.dataset.si}"]`).value = s.r; + const inp = app.querySelector(`[data-rin="${b.dataset.si}"]`); + s.r = Math.max(0, Math.round(parseFloat(inp.value) || 0) + parseInt(b.dataset.sr)); + save(); inp.value = s.r; })); app.querySelectorAll('[data-ck]').forEach(b => b.addEventListener('click', () => { const i = +b.dataset.ck; @@ -1369,13 +1386,16 @@ function bindExerciseCard(app, entry) { beep(1040, .12); vibrate(30); const allDoneHere = entry.sets.every(x => x.done); const isLastEx = A.cur >= A.entries.length - 1; - if (!(allDoneHere && isLastEx)) startRest(S.restSec); - if (allDoneHere && !isLastEx) toast('Exercise done โœ“ โ€” Next โ€บ'); - if (allDoneHere && isLastEx) toast('All sets done โ€” Finish ๐Ÿ'); + // rest timer only BETWEEN sets of an exercise โ€” not once it's finished (the recap sheet takes over) + if (!allDoneHere) startRest(S.restSec); + else { stopRest(); toast(isLastEx ? 'All sets done โ€” Finish ๐Ÿ' : 'Exercise done โœ“'); } if (allDoneHere && !entry.asked) { entry.asked = true; askTop = true; } } save(); - route(); + // in-place update โ€” no full re-render, so the GIF keeps playing and nothing flickers + b.classList.toggle('on', s.done); + b.closest('.setrow').classList.toggle('done', s.done); + updateWorkoutHeader(); if (askTop) { const maxW = Math.max(0, ...entry.sets.map(x => x.w || 0), entry.target.weight || 0, (S.exWeights[entry.id] || {}).w || 0); if (maxW > 0) topWeightSheet(entry); @@ -1392,31 +1412,39 @@ function bindExerciseCard(app, entry) { /* end-of-exercise weight confirmation: tracks the working weight, highest ever entered becomes next time's default */ function topWeightSheet(entry) { + const A = S.active; const ex = EXIDX[entry.id]; if (!ex) return; const maxSet = Math.max(0, ...entry.sets.filter(s => s.done).map(s => s.w || 0)); const prevBest = Math.max((S.exWeights[entry.id] || {}).w || 0, bestWeightFor(entry.id)); const def = Math.max(maxSet, prevBest) || entry.target.weight || 0; + const isLastEx = A && A.cur >= A.entries.length - 1; const m = openModal(` -

โœ“ ${esc(ex.n)}

-
Exercise done! How much weight did you work with?
The highest weight becomes your default next time.
+

โœ… ${esc(ex.n)} done

+
Confirm the weight you worked with โ€” your highest becomes the default next time.
${S.unit}
- ${prevBest > 0 ? `
Previous best: ${fmtNum(prevBest)} ${S.unit}${maxSet > prevBest ? ' โ€” new record! ๐Ÿ†' : ''}
` : ''} - + ${prevBest > 0 ? `
Previous best: ${fmtNum(prevBest)} ${S.unit}${maxSet > prevBest ? ' โ€” new record! ๐Ÿ†' : ''}
` : '
'} +
- `); - const inp = m.el.querySelector('#tw-in'); - setTimeout(() => { inp.focus(); inp.select(); }, 250); - m.el.querySelector('#tw-save').onclick = () => { + `); + const save2 = advance => { const v = parseFloat(inp.value); if (!isFinite(v) || v < 0) { toast('Enter a valid weight'); return; } entry.topW = v; const cur = S.exWeights[entry.id]; S.exWeights[entry.id] = { w: Math.max(v, cur ? cur.w : 0), d: todayISO() }; save(); m.close(); - toast('Tracked โ€” next time starts at ' + fmtNum(S.exWeights[entry.id].w) + ' ' + S.unit + ' ๐Ÿ“ˆ'); + if (advance && A) { + if (isLastEx) finishWorkout(); + else { A.cur = Math.min(A.entries.length - 1, A.cur + 1); save(); route(); } + } else { + toast('Tracked โ€” next time starts at ' + fmtNum(S.exWeights[entry.id].w) + ' ' + S.unit + ' ๐Ÿ“ˆ'); + } }; - m.el.querySelector('#tw-skip').onclick = () => m.close(); + const inp = m.el.querySelector('#tw-in'); + setTimeout(() => { inp.focus(); inp.select(); }, 250); + m.el.querySelector('#tw-save').onclick = () => save2(true); + m.el.querySelector('#tw-skip').onclick = () => save2(false); } function finishWorkout() { diff --git a/app/index.html b/app/index.html index d144674..51cceff 100644 --- a/app/index.html +++ b/app/index.html @@ -13,7 +13,7 @@ - +
๐Ÿ‹๏ธ
@@ -45,7 +45,7 @@
- - + + diff --git a/app/style.css b/app/style.css index 8c10c55..1635c5a 100644 --- a/app/style.css +++ b/app/style.css @@ -39,7 +39,8 @@ input,select,textarea{font:inherit;color:var(--txt)} img{max-width:100%} a{color:var(--acc)} -#app{padding:calc(var(--sat) + 10px) var(--pad) calc(96px + var(--sab)); max-width:560px; margin:0 auto} +/* bottom padding clears the tab bar AND its raised center button */ +#app{padding:calc(var(--sat) + 10px) var(--pad) calc(124px + var(--sab)); max-width:560px; margin:0 auto} /* ---------- header ---------- */ .hdr{display:flex;align-items:center;justify-content:space-between;margin:6px 0 16px} @@ -139,7 +140,7 @@ a{color:var(--acc)} .step{display:flex;align-items:center;gap:2px;background:var(--bg2);border:1px solid var(--line);border-radius:12px} .step button{width:38px;height:44px;font-size:1.25rem;color:var(--mut);flex:none} .step input{width:58px;text-align:center;background:none;border:none;font-size:1.05rem;font-weight:700;outline:none; - -moz-appearance:textfield} + -moz-appearance:textfield;appearance:textfield} .step input::-webkit-inner-spin-button{display:none} /* ---------- workout ---------- */ @@ -149,11 +150,20 @@ a{color:var(--acc)} .exmedia img{width:100%;height:340px;object-fit:contain;display:block} .exmedia .gifhint{position:absolute;right:10px;bottom:10px;background:rgba(0,0,0,.62);color:#fff; border-radius:99px;padding:4px 11px;font-size:.72rem;font-weight:600} +.sethead{display:flex;align-items:center;gap:9px;padding-bottom:2px; + font-size:.66rem;color:var(--dim);font-weight:700;text-transform:uppercase;letter-spacing:.05em} +.sethead .n-sp{width:26px;flex:none} +.sethead .w-sp{flex:1.4;text-align:center} +.sethead .r-sp{flex:1;text-align:center} +.sethead .ck-sp{width:44px;flex:none} .setrow{display:flex;align-items:center;gap:9px;padding:9px 0;border-bottom:1px solid var(--bg2)} .setrow:last-child{border-bottom:none} .setrow .n{width:26px;height:26px;border-radius:50%;background:var(--bg2);color:var(--mut); display:flex;align-items:center;justify-content:center;font-size:.78rem;font-weight:700;flex:none} -.setrow .prev{width:74px;font-size:.72rem;color:var(--dim);flex:none;line-height:1.2} +.setrow .step.w{flex:1.4;min-width:0} +.setrow .step.r{flex:1;min-width:0} +.setrow .step button{width:32px;flex:none} +.setrow .step input{width:100%;min-width:0} .setrow.done .n{background:var(--acc);color:#111} .setrow.done{opacity:.55} .ck{width:44px;height:44px;border-radius:12px;background:var(--bg2);border:1px solid var(--line); diff --git a/app/sw.js b/app/sw.js index fcd1466..3c71bb7 100644 --- a/app/sw.js +++ b/app/sw.js @@ -1,6 +1,6 @@ /* GymLog service worker โ€” network-first for app shell, cache-first for media */ -const CACHE = 'gymlog-v12'; -const SHELL = ['./', 'index.html', 'style.css?v=12', 'app.js?v=12', 'data.js?v=12', 'manifest.json']; +const CACHE = 'gymlog-v13'; +const SHELL = ['./', 'index.html', 'style.css?v=13', 'app.js?v=13', 'data.js?v=13', 'manifest.json']; self.addEventListener('install', e => { e.waitUntil(caches.open(CACHE).then(c => c.addAll(SHELL)).then(() => self.skipWaiting()));