summaryrefslogtreecommitdiffstats
path: root/key-picker.mjs
diff options
context:
space:
mode:
authorBrian Cully <bjc@spork.org>2025-07-26 14:55:53 -0400
committerBrian Cully <bjc@spork.org>2025-07-26 14:55:53 -0400
commit2a9b6ef0be04b5b5cacc47922e19c05d190d6ade (patch)
treee07e9648891b065cb8c12cea563386a9b92264c7 /key-picker.mjs
parent18b63657328a619a638688e5a85c9c1da2b196c1 (diff)
downloadchords-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 'key-picker.mjs')
-rw-r--r--key-picker.mjs11
1 files changed, 6 insertions, 5 deletions
diff --git a/key-picker.mjs b/key-picker.mjs
index b24422d..b3f871c 100644
--- a/key-picker.mjs
+++ b/key-picker.mjs
@@ -17,7 +17,7 @@ function scaleFrom(tonic, scale) {
function handleNoteEnter(e) {
const elt = e.target;
- const n = Note.fromString(elt.innerText).toString();
+ const n = Note.fromString(elt.textContent).toString();
// todo: this should be delegated. the key selector shouldn't know
// about the fretboard at all.
elt.classList.add('hover');
@@ -28,7 +28,7 @@ function handleNoteEnter(e) {
function handleNoteLeave(e) {
const elt = e.target;
- const n = Note.fromString(elt.innerText).toString();
+ const n = Note.fromString(elt.textContent).toString();
// ibid.
elt.classList.remove('hover');
document.querySelectorAll(`#fretboard [x-data-note="${n}"]`).forEach(elt => {
@@ -37,7 +37,7 @@ function handleNoteLeave(e) {
}
function noteClicked(elt, justClear=false) {
- const n = Note.fromString(elt.innerText).toString();
+ const n = Note.fromString(elt.textContent).toString();
const count = Number(elt.getAttribute('x-data-clicked')) || 0;
const next = (count + 1) % 4;
elt.classList.remove(`click${count}`);
@@ -71,7 +71,8 @@ function formChanged(form) {
const formData = new FormData(form);
const scale = scaleFrom(formData.get('tonic'), formData.get('scale'));
['tonic', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh'].forEach((c, i) => {
- Array.from(form.getElementsByClassName(c)).forEach(elt => elt.innerText = scale[i]);
+ Array.from(form.getElementsByClassName(c)).forEach(elt =>
+ elt.textContent = scale[i]);
});
function suffixFromIndex(i) {
@@ -94,7 +95,7 @@ function formChanged(form) {
Array.from(form.getElementsByClassName('chords')).forEach(list => {
const items = availableScales.map(s => {
const elt = document.createElement('li');
- elt.innerText = s;
+ elt.textContent = s;
return elt;
});
list.replaceChildren();