Skip to content

Commit 6f2e181

Browse files
bgeurtenclaude
andcommitted
v0.8.8 (4/4): why-comments on three non-obvious functions
Three functions did clever things without explaining why. Comments added in the spirit of existing ones on exerciseSeries / ldShifts. - rankBodyNames: documents the score tiers so the next reader doesn't have to guess what 0/1/2/3 mean. - reconstructInterval: explains that it's the inverse of unrollIntervalBlocks and the assumption that all work/rest rounds are identical (because the UI only lets the user enter one work template + one rest template). - openExerciseInfo: explains the synchronous-window.open trick to dodge popup blockers, the placeholder + fill pattern, and the fallback to a direct deep-link when the popup is blocked. No code changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 085f3b3 commit 6f2e181

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

gym-tracker.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,11 @@
593593
for (const arr of groups.values()) arr.sort((a, b) => a.date.localeCompare(b.date));
594594
return groups;
595595
}
596-
// Autocomplete source for the name field: user's own names first, then the
597-
// starter list (anything not already in user's set).
596+
// Autocomplete source for the body-metric name field: user's own names first,
597+
// then the starter list (anything not already in the user's set).
598+
// Score tiers (mirroring rankExercises): startsWith=2, word-boundary prefix=1,
599+
// includes=0, no-match=-1. Empty query returns score 3 so a freshly-opened
600+
// dropdown shows everything before the user types.
598601
function rankBodyNames(q) {
599602
const query = q.trim().toLowerCase();
600603
const user = new Set();
@@ -833,6 +836,12 @@
833836
return byPreset;
834837
}
835838

839+
// Inverse of unrollIntervalBlocks: given a flat list of imported CSV rows
840+
// for one cardio session (warmup, work×N, rest×N, cooldown), rebuild the
841+
// nested interval shape used in-app. We assume every work round has the
842+
// same minutes/level (and likewise for rest), since that's what the UI lets
843+
// the user enter — first work row sets the work template, count is
844+
// derived from how many work rows arrived.
836845
function reconstructInterval(blocks) {
837846
const c = { mode: "interval" };
838847
const warmup = blocks.find(b => b.phase === "warmup");
@@ -1042,10 +1051,15 @@ <h2 id="flatgym-instr-heading" style="display:none">Instructions</h2>
10421051
</body></html>`;
10431052
}
10441053

1054+
// Open the reference widget in a new tab. The tab is opened SYNCHRONOUSLY
1055+
// inside the click event so the popup blocker treats it as user-initiated;
1056+
// we then write a placeholder document (so users see something immediately)
1057+
// and asynchronously fetch the full dataset to fill in instructions and chips.
1058+
// If the popup is blocked outright (return value falsy), we degrade to a
1059+
// plain deep-link to the source repo folder.
10451060
async function openExerciseInfo(id, name) {
10461061
const w = window.open("", "_blank");
10471062
if (!w) {
1048-
// Popup blocked — fall back to a direct deep-link.
10491063
window.open(exerciseTreeUrl(id), "_blank", "noopener");
10501064
return;
10511065
}

0 commit comments

Comments
 (0)