Add ?string= param to T1 note-prompter

T1 previously picked the string only from localStorage (default low E).
Accept an optional ?string= URL param (1 = high e … 6 = low E) so wiki
deep-links can pin the string explicitly; invalid values fall back to the
stored/default string.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-23 12:05:36 +02:00
parent 71531eabcd
commit 3708a3268a
2 changed files with 11 additions and 2 deletions
+2 -1
View File
@@ -102,7 +102,8 @@ Optional query parameters override the stored/default settings:
| Param | Applies to | Example |
|------------|-----------------------|----------------|
| `bpm` | click-track drills | `?bpm=66` |
| `bpm` | click-track drills, T1 | `?bpm=66` |
| `string` | T1 (1 = high e … 6 = low E) | `?string=6` |
| `variant` | drills with variants | `?variant=2-3-2` |
| `key` | T2, T4 | `?key=D` |
| `root` | T3, T5, T6 | `?root=A` |
+9 -1
View File
@@ -15,7 +15,15 @@
}
let { drill, params }: Props = $props()
const initString = () => storage.getNumber(`${drill.code}:string`, 5)
// URL uses guitar string numbering (1 = high e … 6 = low E); internal index is 0 = high e … 5 = low E.
function stringFromParam(): number | null {
const q = params.get('string')
if (q === null) return null
const n = Number(q)
if (Number.isInteger(n) && n >= 1 && n <= 6) return n - 1
return null
}
const initString = () => stringFromParam() ?? storage.getNumber(`${drill.code}:string`, 5)
const initRandom = () => storage.getString(`${drill.code}:order`, 'seq') === 'rand'
let stringIdx = $state(initString())