dspickes/Nashy — pull request #1 by dspickes (2014-07-03 17:10:15+00:00)
Title: Cleanup and condense the transposition algorithm

I fleshed out my jsfiddle for you. For reference: http://jsfiddle.net/5NZ5v/3/. Feel free to change any of the variable or property names to better suit your domain language - e.g. using "Degree" rather than "Position" to describe the relative difference between keys.

You'll still need the change the input key strings to be formatted like "D" and "D#" rather than "d" and "dsharp", but I think that may be easier to read in your html as well?

Also, you should consider namespacing the whole thing to allow for cleaner usage. Like, try wrapping the whole thing in var Nashy = (function(){ /* Privately accessible stuff goes here as variables. */ return { /* Publicly accessible functions go here as properties. */ }; }()). Your usage in your outer file would then become Nashy.() - such as Nashy.ProcessText( text ); or Nashy.Transpose( chord );. This would make it more of a library and give you some separation from your html page as a frontend app.

Anyways, your mileage may vary. This is probably a bit long for a merge comment. Hope this helps.