Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with an empty name in custom notation #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions javascripts/jtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ function jtabChord (token) {
this.chordName = parts[0];
this.cagedPos = parts[1];
} else if (this.isCustom){
var parts = this.fullChordName.match( /\[(.+?)\]/ );
var parts = this.fullChordName.match( /\[(.*?)\]/ );
if(parts){
this.chordName = parts[1];
} else {
Expand Down Expand Up @@ -447,7 +447,7 @@ jtabChord.prototype.setCustomChordArray = function(){
};

jtabChord.prototype.parseCustomChordArrayFromToken = function() {
notes = this.fullChordName.replace(/(\%|\[.+\])/g, '');
notes = this.fullChordName.replace(/(\%|\[.*?\])/g, '');
pairs = notes.split('.');
if (pairs.length < 6){
this.isValid = false;
Expand Down
10 changes: 10 additions & 0 deletions jtab-unittest.html
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ <h1>jTab - Unit Tests</h1>
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},

testCustomChord_Empty_Name: function() { with(this) {
var token = "%0/0.2/2.3/2.1/1.0/0.0/0[]";

var modelChordArray = [ 0, [0,0], [2,2], [3,2], [1,1], [0,0], [0,0]]
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCustom, "jtabChord('" + token + "') should be custom chord" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},


testCustomChord_E_fingering: function() { with(this) {
var token = "%0/0.2/2.3/2.1/1.0/0.0/0[E]";
Expand Down