diff options
| author | Brian Cully <bjc@spork.org> | 2025-05-12 11:41:58 -0400 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-05-12 11:41:58 -0400 |
| commit | 6c8074201d89a480f9b021f61cc6ff2eae7bb283 (patch) | |
| tree | 6c0342ae66163a78dc903d60281ef8d98dc9cbb5 /main.mjs | |
| parent | baacc2cb11f7a87c326f0df21d606da459d02483 (diff) | |
| download | chords-6c8074201d89a480f9b021f61cc6ff2eae7bb283.tar.gz chords-6c8074201d89a480f9b021f61cc6ff2eae7bb283.zip | |
js: put save event back
Diffstat (limited to 'main.mjs')
| -rw-r--r-- | main.mjs | 25 |
1 files changed, 10 insertions, 15 deletions
@@ -2,16 +2,6 @@ import Fretboard, { fretToNote } from './fretboard.mjs'; import KeyPicker from './key-picker.mjs'; import History from './history.mjs'; -function memoize(fn) { - let val = undefined; - return function () { - if (val === undefined) { - val = fn(); - } - return val; - } -} - function notes(form) { const strings = ['string1', 'string2', 'string3', 'string4', 'string5', 'string6']; const formData = new FormData(form); @@ -19,15 +9,20 @@ function notes(form) { return strings.map((klass) => fretToNote(form, klass, formData.get(klass))); } -function onSave(form) { - console.debug('we done saved', form, notes(form)); -} - function init() { - console.debug('App#init', this); + console.debug('init()', this); Fretboard.register(); KeyPicker.register(); History.register(); + + // todo: maybe just attach the listener to document? + document.querySelectorAll(Fretboard.name).forEach(f => { + f.addEventListener(f.saveEvent, e => { + document.querySelectorAll(History.name).forEach(h => { + h.add(e.detail); + }); + }); + }); } document.addEventListener('DOMContentLoaded', init); |
