import Fretboard, { fretToNote } from './fretboard.mjs'; import KeyPicker from './key-picker.mjs'; import History from './history.mjs'; function notes(form) { const strings = ['string1', 'string2', 'string3', 'string4', 'string5', 'string6']; const formData = new FormData(form); console.debug('notes', form, formData); return strings.map((klass) => fretToNote(form, klass, formData.get(klass))); } function init() { 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);