summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@spork.org>2025-03-10 12:27:55 -0400
committerBrian Cully <bjc@spork.org>2025-03-10 12:27:55 -0400
commit9f0be08d005a0838af793dab8658b3cab8868c65 (patch)
tree834337ccf9122537fe218755d0755f3d2ded01a2
parent33e376806164072f94cdf9a682262db19ff590d3 (diff)
downloadchords-9f0be08d005a0838af793dab8658b3cab8868c65.tar.gz
chords-9f0be08d005a0838af793dab8658b3cab8868c65.zip
normalize note names for hover matching
-rw-r--r--key-picker.mjs10
1 files changed, 7 insertions, 3 deletions
diff --git a/key-picker.mjs b/key-picker.mjs
index 3b4a378..a1739fa 100644
--- a/key-picker.mjs
+++ b/key-picker.mjs
@@ -1,4 +1,4 @@
-import { MajorScale, MinorScale, chromaticScale } from "./scale.mjs";
+import { MajorScale, MinorScale, Note, chromaticScale } from "./scale.mjs";
function scaleFrom(tonic, scale) {
switch (scale) {
@@ -12,7 +12,7 @@ function scaleFrom(tonic, scale) {
}
function handleNoteEnter(e) {
- const n = e.target.innerText;
+ const n = Note.fromString(e.target.innerText).toString();
// todo: this should be delegated. the key selector shouldn't know
// about the fretboard at all.
document.querySelectorAll(`#fretboard [x-data-note="${n}"]`).forEach(elt => {
@@ -21,7 +21,7 @@ function handleNoteEnter(e) {
})
}
function handleNoteLeave(e) {
- const n = e.target.innerText;
+ const n = Note.fromString(e.target.innerText).toString();
// ibid.
document.querySelectorAll(`#fretboard [x-data-note="${n}"]`).forEach(elt => {
console.debug('wow! found elt', elt);
@@ -67,5 +67,9 @@ function handleFormChanged(e) {
export default function KeyPicker(form) {
console.debug('KeyPicker()', form);
form.onchange = handleFormChanged;
+ form.querySelectorAll('.notes li').forEach(elt => {
+ elt.onmouseenter = handleNoteEnter;
+ elt.onmouseleave = handleNoteLeave;
+ })
formChanged(form);
}