N=["C","C#/Db","D","D#/Eb","E","F","F#/Gb","G","G#/Ab","A","A#/Bb","B"];K=[];V=[2,2,1,2,2,2];L=12;H="innerHTML";M="Major";R="m";r=6;for(j=0;V;j++){a=[];a.push(N[r]+" "+M);b=[];c=r;b.push(N[c]);for(i=0;i<6;i++){c+=V[i];if(c>L-1){c=c-L}e=(i==2||i==3)?"":R;if(i==5){e="m°"}b.push(N[c]+e)}a.push(b);K.push(a);r+=7;if(r>L-1){r=r-L}if(j>10){break}}D=document;B=D.getElementsByTagName("body")[0];function C(d){return D.createElement(d)}function G(d){return D.getElementById(d)}function A(d,g){d.appendChild(g)}function U(){x=s.selectedIndex;u=G(R);w=G("r");v=G("p");u[H]=w[H]=v[H]="";k=K[x][1];p=x-3;if(p<0){p=L+p}p=K[p][1];j=7;for(i=0;i<j;i++){l=C("li");l[H]=k[i];A(u,l);m=i+5;if(m>j-1){m-=j}l=C("li");l[H]=k[m];A(w,l);l=C("li");l[H]=p[m];A(v,l)}}f=C("form");s=C("select");s.onchange=function(){U()};for(i=0;i<L;i++){o=C("option");o.text=K[i][0];if(i==6){o.selected=true}A(s,o)}A(f,s);A(B,f);z=C("div");E=" key";O='<ol id="';P='"></ol>';z[H]="Chords:<br/>"+M+E+O+"m"+P+"Minor"+E+O+"r"+P+"Parallel Minor"+O+"p"+P;A(B,z);U();
/*
* Copywright 2010, Christian Bonham v1.1
* 1k javascript contest entry: minifies to 1018 bytes, written in 24hours.
* Pick a key signature, will tell you the chords in the associated keys.
*/
N=['C','C#/Db','D','D#/Eb','E','F','F#/Gb','G','G#/Ab','A','A#/Bb','B'];
K=[]; // This will be Keys
V=[2,2,1,2,2,2]; // intervals
L=12; // the hard coded length of N
H='innerHTML';
M='Major'
R='m';
r=6; // start on F#
for(j=0;V;j++) { // v is just truthy
a=[]; // newkey
a.push(N[r]+' '+M);
b=[]; // newchord
c=r; // c = chord, r = root of key
b.push(N[c]);
for (i=0;i<6;i++) { // 6, because first chord is outside loop
c+=V[i]; // increment the note by the appropriate interval
if(c>L-1){c=c-L} // wrap the array
e=(i==2||i==3)?'':R; // minor chords get the m: Em
if(i==5){e='m°'}
b.push(N[c]+e);
}
a.push(b);
K.push(a);
r+=7; // next key
if(r>L-1){r=r-L} // lloop the array
if(j>10){break} // we are done.
}
D=document;
B=D.getElementsByTagName('body')[0];
function C(s){return D.createElement(s)}
function G(s){return D.getElementById(s)}
function A(p,c){p.appendChild(c)}
function U(){
x=s.selectedIndex;
u=G(R); // get the major ul: R happens to be 'm'
w=G('r'); // get the relative minor ul
v=G('p'); // get the parallel minor ul
u[H]=w[H]=v[H]=''; // set the innerHTML to ''
k=K[x][1]; // the array of chords
p=x-3; // the parallel minor should be 3 'prior'
if(p<0){p=L+p} // L+p because p is negative here
p=K[p][1]; // the array of chords for the parallel minor
j=7; // k.length: should be 7
for (i=0;i<j;i++) {
l=C('li'); // create an LI
l[H]=k[i]; // set the text to the chord
A(u,l); // append to the ul
m = i+5; // the minor chord is +5
if (m>j-1){m-=j}
l=C('li'); // create an LI
l[H]=k[m]; // set the text to the minor chord
A(w,l); // append to the ul
l=C('li'); // create an LI
l[H]=p[m]; // set the text to the parallel minor chord
A(v,l); // append to the ul
}
}
f=C('form');
s=C('select');
s.onchange=function(){U()};
for (i=0;i<L;i++){
o=C('option');
o.text=K[i][0];
if(i==6){o.selected=true}
A(s,o);
}
A(f,s);
A(B,f);
z=C('div');
E=' key';
O='<ol id="';
P='"></ol>';
z[H]='Chords:<br/>'+M+E+O+'m'+P+'Minor'+E+O+'r'+P+'Parallel Minor'+O+'p'+P;
A(B,z);
U();