-
Notifications
You must be signed in to change notification settings - Fork 0
/
capo.js
65 lines (33 loc) · 1.6 KB
/
capo.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<script>
var match;
var chords = ['C', 'C#', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'Ab', 'A', 'Bb', 'B', 'C', 'Db', 'D', 'D#', 'E', 'F', 'Gb', 'G', 'G#', 'A', 'A#', 'C'];
var chordRegex = /C#|D#|F#|G#|A#|Db|Eb|Gb|Ab|Bb|C|D|E|F|G|A|B/g;
$('#transposeUp, #transposeUp1').click(function() {
$('.c').each(function() {
var currentChord = $(this).text();
var output = "";
var parts = currentChord.split(chordRegex);
var index = 0;
while (match = chordRegex.exec(currentChord)) {
var chordIndex = chords.indexOf(match[0]);
output += parts[index++] + chords[chordIndex + 1];
}
output += parts[index];
$(this).text(output);
});
});
$('#transposeDown, #transposeDown1').click(function() {
$('.c').each(function() {
var currentChord = $(this).text();
var output = "";
var parts = currentChord.split(chordRegex);
var index = 0;
while (match = chordRegex.exec(currentChord)) {
var chordIndex = chords.indexOf(match[0], 1);
output += parts[index++] + chords[chordIndex - 1];
}
output += parts[index];
$(this).text(output);
});
});
</script>