summaryrefslogtreecommitdiffstats
path: root/main.mjs
blob: 5f49097a3d7f25bdba40f7dcab5e7699d2bee66b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);