summaryrefslogtreecommitdiffstats
path: root/main.mjs
blob: f0e4ed8dd4bc18a589e14f6a51a98a9f6e4249ff (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
29
30
31
32
33
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);
    console.debug('notes', form, formData);
    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);

    Fretboard.register();
    KeyPicker.register();
    History.register();
}
document.addEventListener('DOMContentLoaded', init);