import { MajorScale, MinorScale, chromaticScale } from "./scale.mjs"; function scaleFrom(tonic, diatonic) { switch (diatonic) { case 'major': return MajorScale(tonic); case 'minor': return MinorScale(tonic); default: throw new Error('how this happen') } } function formChanged(form) { const formData = new FormData(form); const scale = scaleFrom(formData.get('tonic'), formData.get('diatonic')); ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh'].forEach((c, i) => { Array.from(form.getElementsByClassName(c)).forEach(elt => elt.innerText = scale[i]); }); } function handleFormChanged(e) { formChanged(e.target.form); } export default function KeyPicker(form) { console.debug('KeyPicker()', form); form.onchange = handleFormChanged; formChanged(form); }