diff options
| author | Brian Cully <bjc@spork.org> | 2025-07-26 14:55:53 -0400 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-07-26 14:55:53 -0400 |
| commit | 2a9b6ef0be04b5b5cacc47922e19c05d190d6ade (patch) | |
| tree | e07e9648891b065cb8c12cea563386a9b92264c7 /string.mjs | |
| parent | 18b63657328a619a638688e5a85c9c1da2b196c1 (diff) | |
| download | chords-2a9b6ef0be04b5b5cacc47922e19c05d190d6ade.tar.gz chords-2a9b6ef0be04b5b5cacc47922e19c05d190d6ade.zip | |
first stab at fretboard player.
need to handle actual chord positions so everything isn't in 4, but
otherwise works?
Diffstat (limited to 'string.mjs')
| -rw-r--r-- | string.mjs | 53 |
1 files changed, 2 insertions, 51 deletions
@@ -12,55 +12,6 @@ function dots(i) { } } -/* - this.querySelectorAll('.open').forEach(elt => { - elt.onclick = this.openClicked.bind(this); - }); - this.querySelectorAll('input[type="radio"]').forEach(elt => { - elt.onmousedown = this.fretMousedown.bind(this); - elt.onclick = this.fretClicked.bind(this); - }); - - - #mousedownVal; - fretMousedown(e) { - // at mousedown time, the form hasn't yet been changed. to support - // deselecting elements, we need to know what the previous - // selection was, so store it here. - // - // it'd be nice to be able to do this just in the click handler. - this.#mousedownVal = e.target.checked; - } - - openClicked(e) { - const elt = e.target.parentNode; - if (elt.classList.contains('muted')) { - elt.classList.remove('muted'); - elt.querySelectorAll('input[type="radio"]').forEach(input => { - input.disabled = false; - }) - } else { - elt.classList.add('muted'); - elt.querySelectorAll('input[type="radio"]').forEach(input => { - input.checked = false; - input.disabled = true; - }) - } - this.formChanged(); - } - - fretClicked(e) { - const elt = e.target; - // if this element was selected at mousedown time, deselect it - // now. - if (this.#mousedownVal) { - elt.checked = false; - // doesn't get called automatically. - this.formChanged(); - } - } - */ - export default class extends HTMLElement { // TODO: probably not worth observing frets since everything just // gets re-rendered when they change. @@ -135,7 +86,7 @@ export default class extends HTMLElement { this.querySelectorAll('slot[name="open"]').forEach(s => { const note = chromaticScale[chromIndex] s.setAttribute('value', note); - s.innerText = note; + s.textContent = note; s.parentNode.onclick = this.fretClicked.bind(this); }) @@ -160,7 +111,7 @@ export default class extends HTMLElement { this.querySelectorAll('slot[name="selected"]').forEach(s => { const note = this.getAttribute('value'); console.debug(' -- setting selected', note); - s.innerText = note; + s.textContent = note; }) } } |
