diff options
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); |
