summaryrefslogtreecommitdiffstats
path: root/string.mjs
diff options
context:
space:
mode:
authorBrian Cully <bjc@spork.org>2025-07-28 16:29:50 -0400
committerBrian Cully <bjc@spork.org>2025-07-28 16:29:50 -0400
commit21e0744d3d21ecae21e61718de4ac353ce19c28a (patch)
treeed876f0c4a1f93b5e0f8b2b29b516bbfc489fba9 /string.mjs
parent9620d3750c54b21c3da0460cea117b57fbeb9eac (diff)
downloadchords-21e0744d3d21ecae21e61718de4ac353ce19c28a.tar.gz
chords-21e0744d3d21ecae21e61718de4ac353ce19c28a.zip
add realtime note selection
Diffstat (limited to 'string.mjs')
-rw-r--r--string.mjs17
1 files changed, 14 insertions, 3 deletions
diff --git a/string.mjs b/string.mjs
index 2e496be..7bbfd69 100644
--- a/string.mjs
+++ b/string.mjs
@@ -23,6 +23,8 @@ export default class extends HTMLElement {
customElements.define(this.name, this);
}
+ changedEvent = 'x-string-changed';
+
// TODO: this is a horrible hack, but i don't know how to make
// each string's input unique. maybe wrap them in their own form?
myName() {
@@ -43,10 +45,7 @@ export default class extends HTMLElement {
zot() {
console.debug('String#zot', this);
- const tmpl = this.querySelector('template');
- console.log(' -- tmpl', tmpl);
this.querySelectorAll('input[slot="fret"]').forEach(elt => {
- console.debug(' -- del', elt, parent);
// TODO: this is precisely what i was trying to avoid: the
// code has to know exactly what the template looks like.
elt.parentNode.parentNode.removeChild(elt.parentNode);
@@ -66,6 +65,16 @@ export default class extends HTMLElement {
});
}
+ postChangedEvent() {
+ console.debug('String#postChangedEvent', this);
+ const event = new CustomEvent(this.changedEvent, {
+ bubbles: true,
+ cancelable: true,
+ detail: this
+ });
+ this.dispatchEvent(event);
+ }
+
muteClicked(e) {
console.debug('String#muteClicked', this, e);
if (this.getAttribute('value') !== 'x') {
@@ -77,6 +86,7 @@ export default class extends HTMLElement {
this.classList.remove('muted');
}
+ this.postChangedEvent();
this.updateSelected();
}
@@ -107,6 +117,7 @@ export default class extends HTMLElement {
}
this.setAttribute('value', v);
this.setAttribute('octave', o);
+ this.postChangedEvent();
this.updateSelected();
}