diff options
| author | Brian Cully <bjc@spork.org> | 2025-07-28 08:52:51 -0400 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-07-28 08:52:51 -0400 |
| commit | 77f5e81d0a1adc497040eaa89095635f3de3924e (patch) | |
| tree | 4ad6a00edf5cfe3c5c2bf0090ba80f8d13c143cc /string.mjs | |
| parent | 2d12e407ccac850dd2e1ce133a2f335677a2ef29 (diff) | |
| download | chords-77f5e81d0a1adc497040eaa89095635f3de3924e.tar.gz chords-77f5e81d0a1adc497040eaa89095635f3de3924e.zip | |
attach octave values to frets
sometimes just do the simple thing
Diffstat (limited to 'string.mjs')
| -rw-r--r-- | string.mjs | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -68,6 +68,7 @@ export default class extends HTMLElement { console.debug('String#fretClicked', this, e); console.debug(' -- note', e.target.note); this.setAttribute('value', e.target.getAttribute('value')); + this.setAttribute('octave', e.target.getAttribute('octave')); } render() { @@ -81,11 +82,13 @@ export default class extends HTMLElement { this.zot(); const chromIndex = chromaticScale.indexOf(this.getAttribute('tonic')); + let octave = this.getAttribute('tonic-octave'); const tmpl = this.querySelector('template'); this.querySelectorAll('slot[name="open"]').forEach(s => { const note = chromaticScale[chromIndex] s.setAttribute('value', note); + s.setAttribute('octave', octave); s.textContent = note; s.parentNode.onclick = this.fretClicked.bind(this); }) @@ -103,6 +106,10 @@ export default class extends HTMLElement { } else { s.checked = false; } + if (value === 'C') { + octave++; + } + s.setAttribute('octave', octave); s.parentNode.onclick = this.fretClicked.bind(this); }) tmpl.parentNode.insertBefore(item, tmpl); |
