From 77f5e81d0a1adc497040eaa89095635f3de3924e Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 28 Jul 2025 08:52:51 -0400 Subject: attach octave values to frets sometimes just do the simple thing --- string.mjs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'string.mjs') diff --git a/string.mjs b/string.mjs index d2f0461..03cf720 100644 --- a/string.mjs +++ b/string.mjs @@ -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); -- cgit v1.3