From a8909dc99523240ce238d0e124d02b22333bb61b Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sun, 9 Mar 2025 13:34:10 -0400 Subject: html: add classes to fret tds and trs, rejigger --- fretboard.mjs | 10 +++++----- index.html | 52 +++++++++++++++++++++++++++++++++------------------- main.css | 30 +++++++++++++++++++++++++----- 3 files changed, 63 insertions(+), 29 deletions(-) diff --git a/fretboard.mjs b/fretboard.mjs index 7db359e..23f8cc8 100644 --- a/fretboard.mjs +++ b/fretboard.mjs @@ -46,13 +46,13 @@ function fretToNote(stringName, fretName) { function formChanged(form) { const formData = new FormData(form); - form.querySelectorAll('p').forEach(p => { - const val = formData.get(p.className) - const note = fretToNote(p.className, val); + form.querySelectorAll('tbody .selected').forEach(elt => { + const val = formData.get(elt.parentNode.className) + const note = fretToNote(elt.parentNode.className, val) || ''; if (isAccidental(note)) { - p.innerText = `${note} / ${alternateAccidental(note)}`; + elt.innerText = `${note} / ${alternateAccidental(note)}`; } else { - p.innerText = note; + elt.innerText = note; } }); } diff --git a/index.html b/index.html index a73af92..99258e2 100644 --- a/index.html +++ b/index.html @@ -12,70 +12,84 @@ - - - - - - - + + + + + + + + + - + - + + + - + - + + + - + - + + + - + - + + + - + - + + + - + - + + +
openfret 1fret 2fret 3fret 4fret 5selectedopen°°°°selected
E

A

D

G

B

E

diff --git a/main.css b/main.css index 8706203..f716cf5 100644 --- a/main.css +++ b/main.css @@ -3,18 +3,38 @@ body { background-color: white; } -thead { - display: none; } -#fretboard .open { +#fretboard table { + border-collapse: collapse; +} + +#fretboard thead { + text-align: center; +} +#fretboard thead .fret3, +#fretboard thead .fret5, +#fretboard thead .fret7 { + font-weight: bold; +} + +#fretboard tbody .open { font-weight: bold; } -#fretboard p { +#fretboard td:not(:last-child) { + border-right: 1px solid black; +} + +#fretboard tbody tr { + border-top: 1px solid black; +} + +#fretboard tbody .selected { font-style: italic; + text-align: center; } -tr.muted { +#fretboard .muted { color: grey; } -- cgit v1.3