Skip to content

Commit e4be80a

Browse files
custom shape labels
1 parent f7250c6 commit e4be80a

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

public/index.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ <h2 class="mt-30 ml-100">PentaShapes</h2>
2727

2828
Scale:
2929
<select id="scale-select">
30+
<option value="">-- Choose a scale --</option>
3031
<option value="roots">Roots</option>
3132
<option value="chromatic">Chromatic</option>
32-
<option value="penta_min" selected>Pentatonic Minor</option>
33+
<option value="penta_min">Pentatonic Minor</option>
3334
<option value="penta_maj">Pentatonic Major</option>
3435
<option value="blues">Blues</option>
3536
<option value="major" disabled>Major</option>
@@ -49,23 +50,23 @@ <h2 class="mt-30 ml-100">PentaShapes</h2>
4950
<div class="mt-15">
5051
<label class="custom-checkbox">
5152
<input type="checkbox" id="shape_1" value="shape_1" class="shape-checkbox" disabled onclick="shapeClick()">
52-
<span class="checkmark"></span> Shape 1
53+
<span class="checkmark"></span> <span name="shape_label">Shape 1</span>
5354
</label>
5455
<label class="custom-checkbox">
5556
<input type="checkbox" id="shape_2" value="shape_2" class="shape-checkbox" disabled onclick="shapeClick()">
56-
<span class="checkmark"></span> Shape 2
57+
<span class="checkmark"></span> <span name="shape_label">Shape 2</span>
5758
</label>
5859
<label class="custom-checkbox">
5960
<input type="checkbox" id="shape_3" value="shape_3" class="shape-checkbox" disabled onclick="shapeClick()">
60-
<span class="checkmark"></span> Shape 3
61+
<span class="checkmark"></span> <span name="shape_label">Shape 3</span>
6162
</label>
6263
<label class="custom-checkbox">
6364
<input type="checkbox" id="shape_4" value="shape_4" class="shape-checkbox" disabled onclick="shapeClick()">
64-
<span class="checkmark"></span> Shape 4
65+
<span class="checkmark"></span> <span name="shape_label">Shape 4</span>
6566
</label>
6667
<label class="custom-checkbox">
6768
<input type="checkbox" id="shape_5" value="shape_5" class="shape-checkbox" disabled onclick="shapeClick()">
68-
<span class="checkmark"></span> Shape 5
69+
<span class="checkmark"></span> <span name="shape_label">Shape 5</span>
6970
</label>
7071
</div>
7172

public/js/main.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,26 @@ for (var i = 0; i < notes.e_low.length; i++) {
1919

2020
$('#scale-select').change(function() {
2121
$('#reset-button').click();
22+
23+
// Set custom shape labels if available
24+
var selectedScaleName = $(this).val();
25+
var selectedScale = scales[selectedScaleName];
26+
if (selectedScale && selectedScale.shape_labels) {
27+
$('span[name="shape_label"]').each(function(index) {
28+
$(this).parent().show();
29+
let shape_label = selectedScale.shape_labels[index];
30+
if (!shape_label) {
31+
$(this).parent().hide();
32+
return;
33+
}
34+
$(this).text(shape_label);
35+
});
36+
}
2237
});
2338

39+
// Auto select penta_min
40+
$('#scale-select').val('penta_min').change();
41+
2442
$('#reset-button').click(function() {
2543
deactivateNotes();
2644
showAllNotes();
@@ -98,7 +116,7 @@ function renderShapes(string, index) {
98116

99117
$("#root-note").removeClass('info-message');
100118
$('#reset-button').removeAttr('disabled');
101-
119+
102120
deactivateNotes();
103121
hideNotes();
104122

public/js/scales.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ const scales = (() => {
4646

4747
// https://www.jazz-guitar-licks.com/medias/images/minor-pentatonic-scale-guitar-shapes.png
4848
const penta_min = {
49+
shape_labels: [
50+
'Shape 1 (E)',
51+
'Shape 2 (D)',
52+
'Shape 3 (C)',
53+
'Shape 4 (A)',
54+
'Shape 5 (G)'
55+
],
4956
e_low: {
5057
shape_1: [
5158
{ string: 'e_high', offset: 0, label: '1' },
@@ -140,6 +147,13 @@ const scales = (() => {
140147

141148
// https://www.jazz-guitar-licks.com/medias/images/major-pentatonic-scale-guitar-shapes.png
142149
const penta_maj = {
150+
shape_labels: [
151+
'Shape 1 (E)',
152+
'Shape 2 (D)',
153+
'Shape 3 (C)',
154+
'Shape 4 (A)',
155+
'Shape 5 (G)'
156+
],
143157
e_low: {
144158
shape_1: [
145159
{ string: 'e_high', offset: 2, label: '2' },
@@ -234,6 +248,11 @@ const scales = (() => {
234248

235249
// https://www.guitartricks.com/assets/news_images/GT-Diagrams-BBKingBox_comparison.gif
236250
const blues = {
251+
shape_labels: [
252+
'Pattern 1',
253+
'Albert King Box',
254+
'BB King Box'
255+
],
237256
e_low: {
238257
shape_1: [
239258
{ string: 'e_high', offset: 3, label: '♭3' },

0 commit comments

Comments
 (0)