summaryrefslogtreecommitdiff
path: root/static/main.js
blob: 4fcb1bdb5202ad4d89e2e2e9a71b84de3cb57c8a (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
var colors = ['red', 'green', 'blue', 'grey']
var stats = document.getElementById("stats")

function generateFretMarkers(chordMap, counts) {
    var chordCount = 0;
    for (const [chord, notes] of Object.entries(chordMap)) {
        for (let i = 0; i < notes.length; i++) {
            var fret = document.getElementById(notes[i]);
            var fretMarker = document.createElement("div");
            fretMarker.style.backgroundColor = colors[chordCount]

            if (counts[notes[i]] == 2) {
                fretMarker.style.width = "50%"
            }

            if (counts[notes[i]] == 3) {
                fretMarker.style.width = "33%"
            }

            if (counts[notes[i]] == 4) {
                fretMarker.style.width = "25%"
            }

            fret.appendChild(fretMarker)
        }
    stats.innerHTML += '<button style="height:20px; width:20px; background-color:' + colors[chordCount] + ';"></button>' + chord + '     ';
    chordCount++
    }
}