diff --git a/PlayerModel.js b/PlayerModel.js
new file mode 100644
index 0000000..56353f2
--- /dev/null
+++ b/PlayerModel.js
@@ -0,0 +1,181 @@
+// JavaScript Document
+
+var PS_STOPPED = "STOPPED";
+var PS_PLAYING = "PLAYING";
+var PS_PAUSED = "PS_PAUSED";
+var DIR_FWD = "FORWARD";
+var DIR_BACK = "BACKWARD";
+
+var PlayerModel = {
+
+ "aNoteGroupDivs" : []
+ ,
+ "prevNG" : ""
+ ,
+
+ "i" : 0
+ ,
+
+ "playState" : PS_STOPPED
+ ,
+
+ "looper" : "" //setInterval
+ ,
+
+ "playSpeed" : 2000
+
+ ,
+
+ "setNoteGroupDivs" : function(arr){
+ this["aNoteGroupDivs"] = arr; // array of cNoteGroup divs in ngDashbaord
+ }
+ ,
+ "getNoteGroupDivs" : function(){
+ return this["aNoteGroupDivs"];
+ }
+ ,
+ "setPrevNG" : function(ng){
+ this["prevNG"] = ng;
+ }
+ ,
+ "getPrevNG" : function(){
+ return this["prevNG"];
+ }
+ ,
+ "setPlaystate" : function(st){
+ this["playState"] = st;
+ }
+ ,
+ "getPlaystate" : function(){
+ return this["playState"];
+ }
+ ,
+ "setLooper" : function(interval){
+ this["looper"] = interval;
+ }
+ ,
+ "getLooper" : function(){
+ return this["looper"];
+ }
+ ,
+ "setPlaySpeed" : function(speed){
+ this["playSpeed"] = Number(speed);
+ if(this["playState"] == PS_PLAYING){
+ clearInterval(this["looper"]);
+ this["looper"] = setInterval(function(){animateNotegroups();},Number(speed));
+ }
+ }
+ ,
+ "getPlaySpeed" : function(){
+ return this["playSpeed"];
+ }
+ ,
+ "getNextNG" : function(){
+ var arr = this.aNoteGroupDivs;
+ var ng = arr[this.i];
+ this.prevNG = ng;
+ this.i = (this.i +1) % this.aNoteGroupDivs.length;
+ return ng;
+ }
+ ,
+ "getNextNGBack" : function(){
+ var arr = this.aNoteGroupDivs;
+ this.prevNG = arr[this.i];
+ this.i = ((this.i - 1) + this.aNoteGroupDivs.length) % this.aNoteGroupDivs.length;
+ var ng = arr[this.i];
+ return ng;
+ }
+ ,
+
+ "reloadNotegroups" : function(ngDiv){
+ this["aNoteGroupDivs"] = ngDiv.children().toArray();
+ // strip out playing css?
+ this["i"] = 0;
+ this["prevNG"] = this.aNoteGroupDivs[this.aNoteGroupDivs.length -1];
+ }
+
+}
+
+
+
+var ctl_stopPlayer = function(){
+ mPlayer.setPlaystate(PS_STOPPED);
+ clearInterval(mPlayer.getLooper());
+ //remove all playing css in notegroups?
+ var arr = mPlayer.getNoteGroupDivs();
+ for(var ng in mPlayer.getNoteGroupDivs()){
+ if($(arr[ng]).hasClass("playing") ){
+ $(arr[ng]).removeClass("playing");
+ }
+ }
+ $('#dashPlayStop').val("Play");
+ }
+
+var ctl_playPlayer = function(){
+ if($('#ngDashboard').children().length > 1){
+ if(mPlayer.getPlaystate()!=PS_PAUSED){
+ mPlayer.reloadNotegroups($('#ngDashboard'));
+ //animateNotegroups(true);
+ }
+ if(mPlayer.getPlaystate()==PS_PAUSED){
+ //animateNotegroups(true);
+ }
+ mPlayer.setPlaystate(PS_PLAYING);
+ $('#dashPlayStop').val("Stop");
+ if(mPlayer.i == 0){
+ animateNotegroups(true); // animate once to start instantly; true == forward
+ }
+ mPlayer.setLooper(setInterval(function(){animateNotegroups(true);},mPlayer.getPlaySpeed()));
+ } else {
+ ctl_stopPlayer();
+ }
+ }
+
+var ctl_pausePlayer = function(dir){
+ PS_PAUSED.direction = dir;
+ mPlayer.setPlaystate(PS_PAUSED);
+ clearInterval(mPlayer.getLooper());
+ $('#dashPlayStop').val("Play");
+ }
+
+var ctl_backPlayer = function(){
+ var wasPlaySt = mPlayer.getPlaystate();
+ ctl_pausePlayer(DIR_BACK);
+ //mPlayer.setPlaystate(PS_PAUSEDBACK);
+
+ animateNotegroups(false);
+
+ }
+
+var ctl_fwdPlayer= function(){
+ var wasPlaySt = mPlayer.getPlaystate();
+ ctl_pausePlayer(DIR_FWD);
+ //mPlayer.setPlaystate(PS_PAUSEDFWD);
+
+ animateNotegroups(true);
+
+ }
+
+var animateNotegroups = function(goForward){
+ if(goForward){
+ var prvNg = mPlayer.getPrevNG();
+ if(prvNg != "" && $(prvNg).hasClass("playing") ){
+ $(prvNg).removeClass("playing");
+ }
+ var ng = $(mPlayer.getNextNG());
+ ng.addClass("playing");
+ var abDivArrID = ng.context.attributes["notegroup"].value.split('_');
+ set_notes_per_notegroup(abDivArrID[0], abDivArrID[1], abDivArrID[2]);
+ } else {
+ var ng = $(mPlayer.getNextNGBack());
+ ng.addClass("playing");
+ var abDivArrID = ng.context.attributes["notegroup"].value.split('_');
+ set_notes_per_notegroup(abDivArrID[0], abDivArrID[1], abDivArrID[2]);
+
+ var prvNg = mPlayer.getPrevNG();
+ if(prvNg != "" && $(prvNg).hasClass("playing") ){
+ $(prvNg).removeClass("playing");
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/README.creole b/README.creole
index 6bf2994..2a88716 100644
--- a/README.creole
+++ b/README.creole
@@ -13,3 +13,26 @@ Here are some examples:
* [[http://eliasdorneles.github.com/Fretboard-Studies/#strings=5:0,8:2;5:0,8:0;5:2,7:0;5:0,7:0;5:0,7:0;5:0,8:2&diagram_title=C%20major%20pentatonic|C major pentatonic scale]]
If you want to help, or have ideas or suggestions, feel free to drop me an email: eliasdorneles (at) gmail com
+
+
+= Fretboard Studies v.2 =
+
+I added some thing to Elias's fretboard.
+
+There is a note painter which paints wherever the mouse is until turned off.
+
+There are also "fretpainters" at the bottom which will paint all the notes in a fret.
+
+You can show the note names or the note intervals relative to the selected root.
+
+There is a root pull-down and a set Root mode with the next mouse click.
+
+There is also a notegroups browser which will replace any painted notes with scales or arpeggios (and update the root). I haven't figured out the best way to present chords yet.
+
+The paint by Interval color mode will continue to paint with this note group.
+
+You can drag the notegroups to the notegroup dashboard. From there you can single click to convert painted notes to the new notegroup. These notegroup "buttons" can be resorted and double-clicked to trash.
+
+There are also Player controls which will cycle through the notes relative to the speed spinner.
+
+The generate link works pretty much the same.
diff --git a/ScaleDictionary.js b/ScaleDictionary.js
new file mode 100644
index 0000000..8959be5
--- /dev/null
+++ b/ScaleDictionary.js
@@ -0,0 +1,410 @@
+// JavaScript Document
+
+// for get enharmonic
+var FLATTED = -1;
+var NATURAL = 0;
+var SHARPED = 1;
+
+var CHROMFLAT = ['C', 'D♭', 'D', 'E♭', 'E', 'F', 'G♭', 'G', 'A♭', 'A', 'B♭', 'B'];
+var CHROMSHARP = ['C', 'C♯', 'D', 'D♯', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'A♯', 'B'];
+
+
+kC = {"name" : "C", "safename" : "Cnatural", "baseScale" : CHROMFLAT, "fromC" : 0};
+kDflat = {"name" : "D♭", "safename" : "Dflat", "baseScale" : CHROMFLAT, "fromC" : 1};
+kD = {"name" : "D", "safename" : "Dnatural", "baseScale" : CHROMSHARP, "fromC" : 2};
+kEflat = {"name" : "E♭", "safename" : "Eflat", "baseScale" : CHROMFLAT, "fromC" : 3};
+kE = {"name" : "E", "safename" : "Enatural", "baseScale" : CHROMSHARP, "fromC" : 4};
+kF = {"name" : "F", "safename" : "Fnatural", "baseScale" : CHROMSHARP, "fromC" : 5};
+kGflat = {"name" : "G♭", "safename" : "Gflat", "baseScale" : CHROMFLAT, "fromC" : 6};
+kG = {"name" : "G", "safename" : "Gnatural", "baseScale" : CHROMSHARP, "fromC" : 7};
+kAflat = {"name" : "A♭", "safename" : "Aflat", "baseScale" : CHROMFLAT, "fromC" : 8};
+kA = {"name" : "A", "safename" : "Anatural", "baseScale" : CHROMSHARP, "fromC" : 9};
+kBflat = {"name" : "B♭", "safename" : "Bflat", "baseScale" : CHROMFLAT, "fromC" : 10};
+kB = {"name" : "B", "safename" : "Bnatural", "baseScale" : CHROMFLAT, "fromC" : 11};
+kCsharp = {"name" : "C♯", "safename" : "Csharp", "baseScale" : CHROMSHARP, "fromC" : 1};
+kFsharp = {"name" : "F♯", "safename" : "Fsharp", "baseScale" : CHROMSHARP, "fromC" : 6};
+kGsharp = {"name" : "G♯", "safename" : "Gsharp","baseScale" : CHROMSHARP, "fromC" : 8};
+
+// dict keys collects above objects
+var dictKeys = {
+ "Cnatural" : kC,
+ "Dflat" : kDflat,
+ "Dnatural" : kD,
+ "Eflat" : kEflat,
+ "Enatural" : kE,
+ "Fnatural" : kF,
+ "Gflat" : kGflat,
+ "Gnatural" : kG,
+ "Aflat" : kAflat,
+ "Anatural" : kA,
+ "Bflat" : kBflat,
+ "Bnatural" : kB,
+ "Csharp" : kCsharp,
+ "Fsharp" : kFsharp,
+ "Gsharp" : kGsharp };
+
+var INTS_FLATS = ['R', '♭9', '9', '♭3', '3', '11', '♭5', '5', '♭13', '13', '♭7', '7'];
+var INTS_SHARP4 = ['R', '♭9', '9', '♭3', '3', '11', '♯11', '5', '♭13', '13', '♭7', '7'];
+var INTS_SHARP4AUG = ['R', '♭9', '9', '♭3', '3', '11', '♯11', '5', '+5', '13', '♭7', '7'];
+var INTS_DIM = ['R', '♭9', '9', '♭3', '3', '11', '♯4', '5', '+5', '♭♭7', '♭7', '7'];
+var INTS_SUPERLOCRIAN = ['R', '♭9', '9', '♭3', '♭4', '11', '♭5', '5', '♭13', '13', '♭7', '7'];
+
+var _ROOT = {
+ 'SEMI' : 0,
+ 'INT' : 'R',
+ 'CLR' : 'i__ROOT'
+ }
+
+var FLATNINE = {
+ 'SEMI' : 1,
+ 'INT' : '♭9',
+ 'CLR' : 'i_flatnine'
+ }
+
+var NINE = {
+ 'SEMI' : 2,
+ 'INT' : '9',
+ 'CLR' : 'i_flatnine'
+ }
+
+var SHARPNINE = {
+ 'SEMI' : 3,
+ 'INT' : '♯11',
+ 'CLR' : 'i_sharpnine'
+ }
+
+var FLATTHREE = {
+ 'SEMI' : 3,
+ 'INT' : '♭3',
+ 'CLR' : 'i_third'
+ }
+
+var THIRD = {
+ 'SEMI' : 4,
+ 'INT' : '3',
+ 'CLR' : 'i_third'
+ }
+
+var DIMELEVEN = {
+ 'SEMI' : 4,
+ 'INT' : '♭11',
+ 'CLR' : 'i_fourth'
+ }
+
+var ELEVEN = {
+ 'SEMI' : 5,
+ 'INT' : '11',
+ 'CLR' : 'i_fourth'
+ }
+
+var SHARPELEVEN = {
+ 'SEMI' : 6,
+ 'INT' : '♯11',
+ 'CLR' : 'i_fourth'
+ }
+
+var FLATFIVE = {
+ 'SEMI' : 6,
+ 'INT' : '♭5',
+ 'CLR' : 'i_fifth'
+ }
+
+var FIFTH = {
+ 'SEMI' : 7,
+ 'INT' : '5',
+ 'CLR' : 'i_fifth'
+ }
+
+var AUGFIVE = {
+ 'SEMI' : 8,
+ 'INT' : '♯5',
+ 'CLR' : 'i_fifth'
+ }
+
+var FLATTHIRTEEN = {
+ 'SEMI' : 8,
+ 'INT' : '♭13',
+ 'CLR' : 'i_sixth'
+ }
+
+var THIRTEEN = {
+ 'SEMI' : 9,
+ 'INT' : '13',
+ 'CLR' : 'i_sixth'
+ }
+
+var AUGTHIRTEEN = {
+ 'SEMI' : 10,
+ 'INT' : '♯13',
+ 'CLR' : 'i_sixth'
+ }
+
+var FLATSEVEN = {
+ 'SEMI' : 10,
+ 'INT' : '♭7',
+ 'CLR' : 'i_seventh'
+ }
+
+var SEVENTH = {
+ 'SEMI' : 11,
+ 'INT' : '7',
+ 'CLR' : 'i_seventh'
+ }
+
+var TX = {
+ // tone outside of scale, inherit semitone and int
+ 'SEMI' : -1,
+ 'INT' : '',
+ 'CLR' : 'white'
+ }
+
+var TI = {
+ // tone in scale, inherit semitone and int
+ 'SEMI' : -1,
+ 'INT' : '',
+ 'CLR' : 'black'
+ }
+
+// Scale Formulas
+var IF_IONIAN = [_ROOT, TX, TI, TX, THIRD, TI, TX, FIFTH, TX, TI, TX, SEVENTH];
+var IF_LYDIAN = [_ROOT, TX, TI, TX, THIRD, TX, SHARPELEVEN, FIFTH, TX, TI, TX, SEVENTH];
+var IF_MIXOLYDIAN = [_ROOT, TX, TI, TX, THIRD, TI, TX, FIFTH, TX, TI, FLATSEVEN, TX];
+var IF_DORIAN = [_ROOT, TX, TI, FLATTHREE, TX, TI, TX, FIFTH, TX, TI, FLATSEVEN, TX];
+var IF_AEOLIAN = [_ROOT, TX, TI, FLATTHREE, TX, TI, TX, FIFTH, FLATTHIRTEEN, TX, FLATSEVEN, TX];
+var IF_PHRYGIAN = [_ROOT, FLATNINE, TX, FLATTHREE, TX, TI, TX, FIFTH, FLATTHIRTEEN, TX, FLATSEVEN, TX];
+var IF_LOCRIAN = [_ROOT, FLATNINE, TX, FLATTHREE, TX, TI, FLATFIVE, TX, FLATTHIRTEEN, TX, FLATSEVEN, TX];
+
+
+// scales
+/// guide = ["ROOT", "FLAT_NINE","NINE","FLAT_THREE","THIRD","ELEVEN","FLAT_FIVE","FIFTH","FLAT_THIRTEEN","THIRTEEN","FLAT_SEVEN","SEVENTH"];
+
+var INTCLR_IONIAN = ["i_root", "white","black","white","i_third","black","white","i_fifth","white","black","white","i_seventh"];
+var INTCLR_LYDIAN = ["i_root", "white","black","white","i_third","white","black","i_fifth","white","black","white","i_seventh"];
+var INTCLR_MIXOLYDIAN = ["i_root", "white","black","white","i_third","black","white","i_fifth","white","black","i_seventh","white"];
+var INTCLR_DORIAN = ["i_root", "white","black","i_third","white","black","white","i_fifth","white","black","i_seventh","white"];
+var INTCLR_AEOLIAN = ["i_root", "white","black","i_third","white","black","white","i_fifth","black","white","i_seventh","white"];
+var INTCLR_PHRYGIAN = ["i_root","black","white","i_third","white","black","white","i_fifth","black","white","i_seventh","white"];
+var INTCLR_LOCRIAN = ["i_root","black","white","i_third","white","black","i_fifth","white","black","white","i_seventh","white"];
+var INTCLR_AEOLIAN = ["i_root", "white","black","i_third","white","black","white","i_fifth","black","white","i_seventh","white"];
+var INTCLR_SYMDIM = ["i_root", "black","white","i_third","black","white","black","i_fifth","white","black","i_seventh","white"];
+var INTCLR_MINHARM = ["i_root", "white","black","i_third","white","black","white","i_fifth","black","white","white","i_seventh"];
+var INTCLR_MINMEL = ["i_root", "white","black","i_third","white","black","white","i_fifth","white","black","white","i_seventh"];
+var INTCLR_ALTERED = ["i_root", "black","white","i_third","black","white","i_fifth","white","black","white","i_seventh","white"];
+var INTCLR_LYDDOM = ["i_root", "white","black","white","i_third","white","black","i_fifth","white","black","i_seventh","white"];
+var INTCLR_PHRYGDOM = ["i_root","black","white","white","i_third","black","white","i_fifth","black","white","i_seventh","i_passing"];
+var INTCLR_LYDAUG = ["i_root", "white","black","white","i_third","white","black","i_fifth","black","white","i_seventh","white"];
+var INTCLR_PENTMIN = ["i_root", "white","white","i_third","white","black","white","i_fifth","white","white","i_seventh","white"];
+var INTCLR_PENTMAJ = ["i_root", "white","black","white","i_third","white","white","i_fifth","white","black","white","white"];
+var INTCLR_PENTDOM = ["i_root", "white","black","white","i_third","white","white","i_fifth","white","white","black","white"];
+
+
+var SC_MAJOR = { "name" : "Ionian", "intnames": INTS_FLATS, "color" : INTCLR_IONIAN };
+var SC_LYDIAN = { "name" : "Lydian", "intnames": INTS_SHARP4, "color" : INTCLR_LYDIAN };
+var SC_MIXOLYDIAN = { "name" : "Mixolydian", "intnames": INTS_FLATS, "color" : INTCLR_MIXOLYDIAN };
+var SC_DORIAN = { "name" : "Dorian", "intnames": INTS_FLATS, "color" : INTCLR_DORIAN };
+var SC_AEOLIAN = { "name" : "Aeolian", "intnames": INTS_FLATS, "color" : INTCLR_AEOLIAN };
+var SC_PHRYGIAN = { "name" : "Phrygian", "intnames": INTS_FLATS, "color" : INTCLR_PHRYGIAN };
+var SC_LOCRIAN = { "name" : "Locrian", "intnames": INTS_FLATS, "color" : INTCLR_LOCRIAN };
+var SC_DIMINISHED = { "name" : "Symmetrical Diminished", "intnames": INTS_DIM, "color" : INTCLR_SYMDIM };
+var SC_MINHARM = { "name" : "Harmonic Minor", "intnames": INTS_FLATS, "color" : INTCLR_MINHARM };
+var SC_MINMEL = { "name" : "Melodic Minor", "intnames": INTS_FLATS, "color" : INTCLR_MINMEL };
+var SC_ALTERED = { "name" : "Altered", "intnames": INTS_SUPERLOCRIAN, "color" : INTCLR_ALTERED };
+var SC_LYDIANDOM = { "name" : "Lydian Dominant", "intnames": INTS_SHARP4, "color" : INTCLR_LYDDOM };
+var SC_PHRYGDOM = { "name" : "Phrygian Dominant", "intnames": INTS_FLATS, "color" : INTCLR_PHRYGDOM };
+var SC_LYDIANAUG = { "name" : "Lydian Augmented", "intnames": INTS_SHARP4AUG, "color" : INTCLR_LYDAUG };
+var SC_MINNAT = { "name" : "Natural Minor", "intnames": INTS_FLATS, "color" : INTCLR_AEOLIAN };
+var SC_MINJAZZ = { "name" : "Jazz Minor", "intnames": INTS_FLATS, "color" : INTCLR_MINMEL };
+
+var SC_PENTMIN = { "name" : "Minor Pentatonic", "intnames": INTS_FLATS, "color" : INTCLR_PENTMIN };
+var SC_PENTMAJ = { "name" : "Major Pentatonic", "intnames": INTS_FLATS, "color" : INTCLR_PENTMAJ };
+var SC_PENTDOM = { "name" : "Dominant Pentatonic", "intnames": INTS_FLATS, "color" : INTCLR_PENTDOM };
+
+
+var dictScales = {
+ "SC_MAJOR": SC_MAJOR,
+ "SC_LYDIAN": SC_LYDIAN,
+ "SC_MIXOLYDIAN": SC_MIXOLYDIAN,
+ "SC_DORIAN": SC_DORIAN,
+ "SC_AEOLIAN": SC_AEOLIAN,
+ "SC_PHRYGIAN": SC_PHRYGIAN,
+ "SC_LOCRIAN": SC_LOCRIAN,
+ "SC_DIMINISHED": SC_DIMINISHED,
+ "SC_PENTMIN": SC_PENTMIN,
+ "SC_PENTMAJ": SC_PENTMAJ,
+ "SC_PENTDOM": SC_PENTDOM,
+ "SC_MINHARM": SC_MINHARM,
+ "SC_MINMEL": SC_MINMEL,
+ "SC_ALTERED": SC_ALTERED,
+ "SC_LYDIANDOM": SC_LYDIANDOM,
+ "SC_PHRYGDOM": SC_PHRYGDOM,
+ "SC_LYDIANAUG": SC_LYDIANAUG,
+ "SC_MINNAT": SC_MINNAT,
+ //"SC_MINJAZZ": SC_MINJAZZ
+ };
+
+var ScaleModel = {
+
+ "scale" : dictScales["SC_MAJOR"]
+ ,
+ "setScale" : function(newScale){
+ this["scale"] = dictScales[newScale];
+ }
+ ,
+ "getIntColorArr" : function(){
+ var s = this["scale"];
+ return s["color"];
+ }
+ ,
+ "getIntNamesArr" : function(){
+ var s = this["scale"];
+ return s["intnames"];
+ }
+ ,
+ "getScaleName" : function(){
+ var s = this["scale"];
+ return s["name"];
+ }
+
+
+ };
+
+
+
+
+//arps
+var INTCLR_MAJ = ["i_root", "white","white","white","i_third","white","white","i_fifth","white","white","white","white"];
+var INTCLR_MAJ7 = ["i_root", "white","white","white","i_third","white","white","i_fifth","white","white","white","i_seventh"];
+var INTCLR_DOM7 = ["i_root", "white","white","white","i_third","white","white","i_fifth","white","white","i_seventh","white"];
+var INTCLR_MIN = ["i_root", "white","white","i_third","white","white","white","i_fifth","white","white","white","white"];
+var INTCLR_MIN7 = ["i_root", "white","white","i_third","white","white","white","i_fifth","white","white","i_seventh","white"];
+var INTCLR_MIN7b5 = ["i_root", "white","white","i_third","white","white","i_fifth","white","white","white","i_seventh","white"];
+var INTCLR_DIM = ["i_root", "white","white","i_third","white","white","i_fifth","white","white","i_seventh","white","white"];
+
+var ARP_MAJ = { "name" : "maj", "intnames": INTS_FLATS, "color" : INTCLR_MAJ };
+var ARP_MAJ7 = { "name" : "maj7", "intnames": INTS_SHARP4, "color" : INTCLR_MAJ7 };
+var ARP_DOM7 = { "name" : "7", "intnames": INTS_SHARP4, "color" : INTCLR_DOM7 };
+var ARP_MIN = { "name" : "min", "intnames": INTS_FLATS, "color" : INTCLR_MIN };
+var ARP_MIN7 = { "name" : "min7", "intnames": INTS_FLATS, "color" : INTCLR_MIN7 };
+var ARP_MIN7b5 = { "name" : "min7♭5", "intnames": INTS_FLATS, "color" : INTCLR_MIN7b5 };
+var ARP_DIM = { "name" : "dim", "intnames": INTS_DIM, "color" : INTCLR_DIM };
+
+
+var dictArps = {
+ "ARP_MAJ" : ARP_MAJ,
+ "ARP_MAJ7" : ARP_MAJ7,
+ "ARP_DOM7" : ARP_DOM7,
+ "ARP_MIN" : ARP_MIN,
+ "ARP_MIN7" : ARP_MIN7,
+ "ARP_MIN7b5" : ARP_MIN7b5,
+ "ARP_DIM" : ARP_DIM
+}
+
+
+
+var CHD_MAJDROP2 = { "name" : "MAJ7", "intnames": INTS_FLATS, "color" : INTCLR_MAJ7 };
+
+var dictChords={
+ //"CHD_MAJDROP2" : CHD_MAJDROP2
+ }
+
+var FretboardModel = {
+ // model to hold current Key, Notegroup and NG type for fretboard
+ "chromNames" : CHROMFLAT,
+ "key" : kC,
+ "ng" : "SC_MAJOR",
+ "ngType" : dictScales,
+
+ "getChromNames" : function(){
+ var cn = this["chromNames"];
+ return cn;
+ },
+ "setChromNames" : function(cn){
+ this["chromNames"] = cn;
+ },
+ "getKeyObj" : function(){
+ var kObj = this["key"];
+ return kObj;
+ },
+ "getKeyTextName" : function(){
+ // return text html name for CURRENT key
+ var kObj = this["key"];
+ return kObj["name"];
+ },
+
+ "getKeySafeName" : function(){
+ // returns safename for CURRENT key
+ var kObj= this["key"];
+ return kObj["safename"];
+ },
+
+ "getKeyInt" : function(){
+ // returns int for CURRENT key
+ var kObj = this["key"];
+ return kObj["fromC"];
+ },
+ "setKey" : function(kObj){
+ this["key"] = kObj;
+ var keyInt = kObj.fromC;
+ var basescale = kObj.baseScale;
+ var newscale = new Array();
+ var arrLen = basescale.length;
+ for(var i=0, j=keyInt; i < arrLen; i++, j++){
+ if(j==arrLen){j=0};
+ var t = basescale[j];
+ newscale[i] = basescale[j];
+ }
+ // chrom names array will start with KEY as root
+ this["chromNames"] = newscale;
+ },
+
+ "getNotegroupDict" : function(){
+ // returns CURRENT ng dictionary
+ var d = this["ngType"];
+ return d;
+ },
+
+ "getNotegroup" : function(){
+ var dict = this["ngType"];
+ var ng = dict[this["ng"]];
+ return ng;
+ },
+
+ "setNotegroup" : function(ng, typeDict){
+ if(arguments.length < 2){
+ arr = ng.split('_');
+ switch(arr[0]){
+ case "SC":
+ this["ngType"] = dictScales;
+ break;
+ case "ARP":
+ this["ngType"] = dictArps;
+ break;
+ case "CHD":
+ this["ngType"] = dictArps;
+ break;
+ }
+ } else {
+ this["ngType"] = typeDict;
+ }
+
+ this["ng"] = ng;
+ },
+
+ "getNGname" : function(){
+ var dict = this["ngType"];
+ var ng = dict[this["ng"]];
+ return ng["name"];
+ },
+
+ "getNGintcolor" : function(){
+ var dict = this["ngType"];
+ var ng = dict[this["ng"]];
+ return ng["color"]; // returns array of css colors
+ },
+ "getNGintnames" : function(){
+ var dict = this["ngType"];
+ var ng = dict[this["ng"]];
+ return ng["intnames"]; // returns array of html texts
+ },
+
+};
diff --git a/boxfrets.js b/boxfrets.js
index d2fd075..7906922 100644
--- a/boxfrets.js
+++ b/boxfrets.js
@@ -1,8 +1,45 @@
/* code to handle manipulation */
var GUITAR_STRINGS;
-var COLOR = "green";
-var POSSIBLE_COLORS = ["orange", "green", "blue", "yellow", "coffee", "red", "transparent"]
+var COLOR = "lightgreen";
+//var PALLETE_COLORS = ["orange", "green", "blue", "yellow", "lightgreen", "red", "transparent"]
+//var POSSIBLE_COLORS2 = ["orange", "green", "blue", "yellow", "lightgreen", "red", "i_root", "transparent"]
+var POSSIBLE_COLORS = [
+ "i_root",
+ "i_flatnine",
+ "i_nine",
+ "i_flatthird",
+ "i_third",
+ "i_fourth",
+ "i_flatfifth",
+ "i_fifth",
+ "i_flatsixth",
+ "i_sixth",
+ "i_flatseventh",
+ "i_seventh",
+ "i_passing",
+ "orange",
+ "green",
+ "blue",
+ "yellow",
+ "lightgreen",
+ "red",
+ "black",
+ "white",
+ "transparent"];
var ERASER = false;
+var BRUSH = false;
+var SETTINGROOT = false;
+var INTERVALMODE = false;
+var COLORBYINTERVALS = false;
+
+
+var KEY = 0;
+
+//var mScale = ScaleModel;
+var mFB = FretboardModel;
+
+var mPlayer = PlayerModel;
+
var gen_fret_boxes = function(size, num_strings){
var tr = "
";
for (var i = 0; i < size; i++){
@@ -16,16 +53,17 @@ var gen_fret_boxes = function(size, num_strings){
table += "";
return table;
}
-var td_paint = function(td){
- var color = arguments.length > 1 ? arguments[1] : "coffee";
- var td = $(td);
- td.removeClass(POSSIBLE_COLORS.join(" "));
- td.addClass(color);
+var td_paint = function(td, newColor){
+ var color = arguments.length > 1 ? arguments[1] : "lightgreen";
+ var td = $(td);
+ td.removeClass(POSSIBLE_COLORS.join(" "));
+ td.addClass(color);
}
var td_clear = function(td){
td_paint(td, 'transparent');
}
var is_painted = function(td){
+ var isPainted = !$(td).hasClass('transparent');
return !$(td).hasClass('transparent');
}
function is_defined(obj){
@@ -62,6 +100,19 @@ var uri_diagram_repr = function(guitarStrings){
});
return arr.join(";");
}
+
+var getArrNotegroupsInDash = function(){
+ var str =""
+ var dash = $('#ngDashboard').children(".cNoteGroup");
+ if (dash.length > 0){
+ for (var i = 0; i < dash.length; i++)
+ {
+ str += $(dash[i]).attr("notegroup") +",";
+ }
+ }
+ str = str.replace(/,+$/, ""); // eliminate last comma
+ return str;
+ }
var create_link_from_fretboard = function(){
var href = window.location.href;
if (href.indexOf('#') > 0){
@@ -69,9 +120,17 @@ var create_link_from_fretboard = function(){
}
href += '#';
href += "strings=" + uri_diagram_repr(GUITAR_STRINGS);
+ href += "&key="+mFB.getKeyObj().safename;
+ href += "&intColor="+COLORBYINTERVALS;
+ href += "&intNames="+INTERVALMODE;
href += "&diagram_title=" + escape($('#diagram_title').val());
+ var dashGroups = getArrNotegroupsInDash();
+ if(dashGroups != ""){
+ href += "&dash="+dashGroups;
+ }
return href;
}
+
var update_link = function(){
$('#linkthis').attr('href', create_link_from_fretboard());
$('#linkquiz').attr('href', create_link_from_fretboard() + "&q=y");
@@ -107,17 +166,28 @@ function fill_from_repr(repr){
}
}
}
+
// callback for when a cell is clicked
-var td_paint_or_clear = function(td, color){
- var color = arguments.length > 1 ? arguments[1] : "coffee";
+var td_paint_or_clear = function(td){
var td = $(td);
- if (!td.hasClass('transparent') && td.hasClass(color)){
- td.removeClass(POSSIBLE_COLORS.join(" "));
- td.addClass('transparent');
+ if (!td.hasClass('transparent') && (td.hasClass(COLOR) || COLORBYINTERVALS )){
+ // make transparent
+ td.removeClass(POSSIBLE_COLORS.join(" "));
+ td.addClass('transparent');
} else {
- td.removeClass(POSSIBLE_COLORS.join(" "));
- td.addClass(color);
+ // repaint colored td
+ if(COLORBYINTERVALS)
+ {
+ var arrStringFret = getStringFret(td);
+ ctl_color_td_by_interval(arrStringFret[0],arrStringFret[1]);
+ }
+ else
+ {
+ // repaint with new pallete color
+ td_paint(td, COLOR );
+ }
}
+
}
var getFretcloneStrings = function(){
@@ -126,9 +196,20 @@ var getFretcloneStrings = function(){
for (var i = 0; i < board_strings.length; i++){
var children = board_strings[i].children;
for (var j = 0; j < children.length; j++){
- var box = {
+ // fretnote object
+ var box = {
td: children[j],
paint: function(){
+ if(SETTINGROOT){
+ // todo fix this
+ SETTINGROOT = false;
+ updateSetRootView();
+ var newNote = $(this).attr('notename');
+ // get safeName from note
+ ctl_change_key.setRoot(getKeyObjFromNoteName(newNote));
+ td_clear(this);// will paint after
+ //var newKey = $("#selKey").val(getChromaticInt(newNote, CHROMFLAT));
+ }
td_paint_or_clear(this, COLOR);
},
}
@@ -139,8 +220,17 @@ var getFretcloneStrings = function(){
$(children[j]).mouseover(function(){
if (ERASER == true){
td_clear(this);
- }
- update_link();
+ update_link();
+ } else if (BRUSH == true){
+ if(COLORBYINTERVALS){
+ var arr = (this.id).split('_');
+ ctl_color_td_by_interval(arr[1], arr[2]);
+ update_link();
+ } else {
+ td_paint(this, COLOR); // current palette color
+ update_link();
+ }
+ }
});
}
}
@@ -176,7 +266,7 @@ var check_answers = function(a_repr) {
});
for (var j = 0; j < GUITAR_STRINGS[i].length; j++){
if ($.inArray(j.toString(), marked_notes) >= 0){
- var color = is_painted(GUITAR_STRINGS[i][j].td) ? "green" : "orange";
+ var color = is_painted(GUITAR_STRINGS[i][j].td) ? "lightgreen" : "orange";
note_paint(i, [j, color]);
} else {
if (is_painted(GUITAR_STRINGS[i][j].td)){
@@ -189,56 +279,555 @@ var check_answers = function(a_repr) {
}
}
var clear_fretboard = function(){
+
for(var i = 0; i < GUITAR_STRINGS.length; i++){
for(var j = 0; j < GUITAR_STRINGS[i].length; j++){
td_clear(GUITAR_STRINGS[i][j].td);
}
}
+ ctrl_updateMessage();
}
var pick_note = function(position, offset){
if(typeof(offset)==='undefined') offset=0; // defaults to E
if(typeof(position)==='undefined') position=4; // defaults to E
- var scale = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
- return scale[(position + offset) % scale.length];
+ return mFB.getChromNames()[(position + offset) % mFB.getChromNames().length];
}
var set_notes = function(){
- //var offsets = [4, 9, 2, 7, 11, 4];
var offsets = [4, 11, 7, 2, 9, 4];
for(var i = 0; i < GUITAR_STRINGS.length; i++){
for(var j = 0; j < GUITAR_STRINGS[i].length; j++){
- $(GUITAR_STRINGS[i][j].td).find('.note').html(pick_note(j, offsets[i]));
+ var note_td = $(GUITAR_STRINGS[i][j].td);
+ var notespan = $(GUITAR_STRINGS[i][j].td).find('.note');
+ var note = pick_note(j, offsets[i]);
+
+ notespan.attr('id','ns_'+i+'_'+j );// ns_(string)_(fret)
+ note_td.attr('id','nc_'+i+'_'+j );
+ notespan.attr('notename', note );
+ note_td.attr('notename', note );
+ notespan.html($('#'+'ns_'+i+'_'+j).attr('notename'));
+ var chromFromC = (j + offsets[i]) % mFB.getChromNames().length;
+ note_td.attr('semiInts', chromFromC );
+ notespan.attr('semiInts', chromFromC );
+
+ }
+ }
+}
+
+
+var set_notespans = function(){
+
+ var offsets = [4, 11, 7, 2, 9, 4];
+ for(var i = 0; i < GUITAR_STRINGS.length; i++){
+ for(var j = 0; j < GUITAR_STRINGS[i].length; j++){
+ var ns = $('#'+'ns_'+i+'_'+j);
+ ns.attr('id','ns_'+i+'_'+j );// ns_(string)_(fret)
+ var note = ns.attr('notename');
+
+ var arrLen = mFB.getNGintnames().length;
+ var nsSemiInt = ((mFB.getNGintnames().length + Number(ns.attr("semiInts"))) - mFB.getKeyInt()) % mFB.getNGintnames().length;
+
+ if(INTERVALMODE)
+ {
+ if (nsSemiInt == 0){
+ ns.html(mFB.getChromNames()[0]);
+ }
+ else
+ {
+ ns.html(mFB.getNGintnames()[nsSemiInt]);
+ }
+
+ }
+ else
+ {
+ ns.html(mFB.getChromNames()[nsSemiInt]);
+ }
+
+ var isPainted = is_painted($('#nc_'+i+'_'+j));
+ if(COLORBYINTERVALS && is_painted($('#nc_'+i+'_'+j)) )
+ {
+
+ ctl_color_td_by_interval(i,j); //send string, fret
+ }
}
}
+ ctrl_updateMessage();
+
}
-var loadFromUrl = function(url_params){
- if (is_defined(url_params['diagram_title'])){
- $('#diagram_title').val(unescape(url_params['diagram_title']));
+
+var ctrl_updateMessage = function(){
+ if(COLORBYINTERVALS){
+ var msg = "Painting notes for "+mFB.getKeyTextName();
+ if(mFB.getNotegroupDict() != dictArps){msg += " ";}
+ msg += mFB.getNotegroup().name+"";
+ $('#message').html(msg);
+ } else{
+ $('#message').html("");
+ }
}
- if (is_defined(url_params['strings'])){
- if (is_defined(url_params['q']) && url_params['q'] == 'y'){
- COLOR = "coffee";
- $('#checkanswer').click(function(){
- check_answers(url_params['strings']);
+
+var ctl_updateIntervalMode = function(boolNewMode){
+
+ if(boolNewMode){
+ $('#modeNoteInt').attr('value', 'Intervals');
+ INTERVALMODE = true;
+ set_notespans();
+ update_link();
+ } else {
+ $('#modeNoteInt').attr('value', 'Notes');
+ INTERVALMODE = false;
+ set_notespans();
+ update_link();
+ }
+ }
+
+var ctl_populateDash = function(str){
+ var nGroups = str.split(",");
+ for(var i=0 ; i < nGroups.length; i++){
+ ctrl_addDashNotegroups(nGroups[i]);
+ }
+ }
+
+var ctrl_addDashNotegroups = function(idStr){
+ var arrID = idStr.split('_');
+ var key = arrID[0];
+ var ngType = arrID[1];
+ var ng = arrID[2]; // notegroup
+ var htmlTxt = getKeyObjFromSafeName(arrID[0]).name;
+
+ var ngBoxClrClass;
+
+ switch(ngType){
+ case "ARP":
+ htmlTxt += dictArps[ngType+'_'+ng].name;
+ ngBoxClrClass="ngboxArp";
+ break;
+ case "SC":
+ htmlTxt += ' '+dictScales[ngType+'_'+ng].name;
+ ngBoxClrClass="ngboxScale";
+ break;
+ case "CHD":
+ htmlTxt += ' '+dictChords[ngType+'_'+ng].name;
+ ngBoxClrClass="ngboxChd";
+ break;
+ }
+ var $abDiv = $("", {class: "cNoteGroup "+ngBoxClrClass, notegroup: idStr}).html(htmlTxt);
+ $abDiv.dblclick(
+ // remove abridgedDiv on doubleclick
+ function(){
+ ctl_stopPlayer();
+ $(this).remove();
+ update_link();
+ }
+ ).click(
+ // set notegroups on abridged Div click
+ function(){
+ //var abDivArrID = this.attributes["notegroup"].value.split('_');
+ set_notes_per_notegroup(arrID[0], arrID[1], arrID[2]);
+ }
+ );
+
+ if(mPlayer.getPlaystate() == PS_PLAYING){
+ ctl_stopPlayer();
+ }
+
+ $("#ngDashboard").append($abDiv); // add dragged notegroup to Dashboard
+ $("#ngDashboard").sortable({
+ stop: function( event, ui ) {mPlayer.reloadNotegroups($("#ngDashboard"))},
+ start: function( event, ui ) {ctl_stopPlayer();}
});
+ mPlayer.reloadNotegroups($("#ngDashboard"));
+ update_link();
+
+ }
+var ctl_updateColorIntMode = function(boolNewMode){
+ if(boolNewMode){
+ COLORBYINTERVALS = true;
+ $('#colorByInterval').attr('value', 'Pallete Color' );
+ // hide color pallete
$('#colorchooser').hide();
- $('#checkanswer').show();
- } else {
- fill_from_repr(url_params['strings']);
+ set_notespans();
+ update_link();
+ } else{
+ COLORBYINTERVALS = false;
+ $('#colorByInterval').attr('value', 'Color Intervals' );
+ // hide color pallete
+ $('#colorchooser').show();
+ set_notespans();
+ update_link();
+ }
+ }
+
+var ctl_color_td_by_interval = function(string, fret){
+ var nsSemiInt = ((mFB.getNGintnames().length + Number($('#ns_'+string+'_'+fret).attr("semiInts"))) - mFB.getKeyInt()) % mFB.getNGintnames().length;
+ var newColor = mFB.getNGintcolor()[Number(nsSemiInt)]; // need to be a number?
+ td_paint($('#nc_'+string+'_'+fret), newColor );
+ }
+
+var ctl_change_key = {
+ "setRoot" : function(kObj){
+ mFB.setKey(kObj);
+ if($("#selKey").val() != kObj.safename){
+ $("#selKey").val(kObj.safename);
+ }
+ set_notespans();
+ },
+ "keyChangeNotegroup" : function(kSafeName){
+ mFB.setKey(dictKeys[kSafeName]);
+ var selKeyVal = $("#selKey").val();
+ if(selKeyVal != kSafeName){
+ $("#selKey").val(kSafeName);
+ }
+ },
+ "selKeyChange" : function(selKeyVal){
+
+ mFB.setKey(dictKeys[selKeyVal]);
+ set_notespans();
+ update_link();
+ }
+
+ }
+
+var set_notes_per_notegroup = function(keySafeName, ngType, ng){
+ // if color by intervals is off, turn on and save state
+ var paletteState = !COLORBYINTERVALS;
+ COLORBYINTERVALS = true;
+ ctl_change_key.keyChangeNotegroup(keySafeName);
+ var ng = ngType+'_'+ng;
+ mFB.setNotegroup(ng);
+ set_notespans();
+ COLORBYINTERVALS = !paletteState; // keep pallete if open
+ //var msg = "Painting notes for
"+mFB.getKeyTextName();
+// if(ngType != "ARP"){msg += " ";}
+// msg += mFB.getNotegroup().name+"";
+// $('#message').html(msg);
+}
+
+var isPalleteColor = function(c){
+ for(var pc in PALLETE_COLORS){
+ if (c == pc) return true;
+ }
+ return false;
+ }
+
+var getChromaticInt = function(noteStr, chromNamesScale){
+
+ if(chromNamesScale == null){
+ chromNamesScale = mFB.getChromNames();
+ }
+ for(var i = 0; i < chromNamesScale.length; i++){
+ if (noteStr == chromNamesScale[i])
+ return i;
+ }
+}
+
+
+
+var getEnharmonic = function(noteStr){
+ // make sure more than 1 chars
+ if(noteStr.length > 1){
+ getAccTypeStr(noteStr)
+ switch(getAccTypeStr(noteStr)) {
+ case FLATTED:
+ //flat
+ enStr = acc[0]+"♭";
+ noteStr = CHROMSHARP[getChromaticInt(enStr,CHROMFLAT)];
+ break;
+ case SHARPED:
+ //sharp
+ enStr = acc[0]+"♯";
+ noteStr = CHROMFLAT[getChromaticInt(enStr,CHROMSHARP)];
+ break;
+ default:
+ //natural
+ noteStr = noteStr.charAt(0);
+ }
+ }
+
+
+ return noteStr;
+
+}
+
+var getAccTypeStr = function(noteStr){
+ var accType;
+ var acc = escape(noteStr).split('%');
+ switch(acc[1]) {
+ case 'u266D':
+ //flat
+ accType = FLATTED;
+ break;
+ case 'u266F':
+ //sharp
+ accType = SHARPED;
+ break;
+ default:
+ //natural
+ accType= NATURAL;
+ }
+
+ return accType;
+}
+
+var getKeyObjFromNoteName = function(noteStr){
+ var intFromC = getKeyObjFromUnsafeName(noteStr).fromC
+ var newKeyHtmlName = mFB.getKeyObj().baseScale[intFromC];
+ return getKeyObjFromUnsafeName(newKeyHtmlName);
+ }
+
+var getSafeNameFromNoteName = function(noteStr){
+ var intFromC = getKeyObjFromUnsafeName(noteStr).fromC
+ var newKeyHtmlName = mFB.getKeyObj().baseScale[intFromC];
+ return getKeyObjFromUnsafeName(newKeyHtmlName).safename;
+ }
+
+var getKeyObjFromSafeName = function(safenameStr){
+ var keyObj = "";
+ for(ko in dictKeys){
+ if (safenameStr == dictKeys[ko].safename){
+ keyObj = dictKeys[ko];
+ break;
+ }
+ }
+ return keyObj;
+ }
+
+var getKeyObjFromUnsafeName = function(htmlStr){
+ var keyObj = "";
+ for(ko in dictKeys){
+ if (htmlStr == dictKeys[ko].name){
+ keyObj = dictKeys[ko];
+ break;
+ }
+ }
+
+ if(keyObj == ""){
+ // likely a sharp key that needs to be a flat key = get Enharmonic
+ for(var i = 0; i < CHROMSHARP.length; i++){
+ if(htmlStr == CHROMSHARP[i]){
+ htmlStr = CHROMFLAT[i];
+ break;
+ }
+ }
+
+ for(ko in dictKeys){
+ if (htmlStr == dictKeys[ko].name){
+ keyObj = dictKeys[ko];
+ break;
+ }
+ }
+ }
+ return keyObj;
+ }
+
+var getNotespanFromTD = function(td){
+ var arr = td.attr('id').split('_');
+ return $('#ns_'+arr[1]+'_'+arr[2]);
+ }
+
+var getStringFret = function(el){
+ var aStringFret = el.attr('id').split('_');
+ aStringFret.shift();
+ return aStringFret;
+ }
+
+var updateSetRootView = function(){
+ if(SETTINGROOT){
+ $("#setRoot").addClass( 'setRootArmed' );
+ }else{
+ $("#setRoot").removeClass( 'setRootArmed' )
+ }
+ }
+
+//var populateScaleMenu = function(){
+// var scaleSel = $('#selScale');
+// var arrScales = dictScales;
+// $.each(arrScales, function(val, text) {
+// scaleSel.append(
+// $('
').val(val).html(text["name"])
+// );
+// });
+// }
+
+var populateNotegroupsUnabridged = function(){
+ var html = '
';
+ $('#notegroupsUnabridged').append(html);
+
+ html ="";
+ for(var key in dictKeys){
+ html += '
';
+ //populateKeyWithUnabridgedNotegroups();
+ html += '
';
+ html += '
';
+
+ // ~~~~~~ arpeggios
+ html += '
';
+
+ // divs
+ for(var ng in dictArps){
+ //var obj = ng;
+ html += '
';
+ html += dictKeys[key].name+dictArps[ng].name;
+ html += '
';
}
+
+
+ html += '
';
+
+ // ~~~~~~ scales
+ html += '
';
+
+ for(var ng in dictScales){
+ //var obj = ng;
+ html += '
';
+ html += dictKeys[key].name +' '+ dictScales[ng].name;
+ html += '
';
+ }
+
+
+ html += '
';
+
+
+ // ~~~~~~ chords
+ html += '
';
+ //html += dictKeys[key].name+' chords';
+ html += 'Maybe in the next update!'
+ html += '
';
+ html += '
';
+ // end of div for key
+ html += '
';
}
+ $('#notegroupsUnabridged').append(html);
+
+
+ };
+
+var makeUnabridgedDragDroppable = function(){
+ var x = null;
+ //Make element draggable
+ $(".ngUnabDiv").draggable({
+ helper: 'clone',
+ containment: 'document' ,
+ start: function(e, ui)
+ {
+ $(ui.helper).addClass("ui-draggable-helper");
+ },
+ cursor: 'move',
+ tolerance: 'fit',
+ revert: true
+ }).click(function(){
+ var arrID = this.id.split('_');
+ set_notes_per_notegroup(arrID[0], arrID[1], arrID[2]);
+ });
+
+ $("#ngDashboard").droppable({
+ accept: '.ngUnabDiv',
+ activeClass: "drop-area",
+ drop: function (e, ui) {
+ if ($(ui.draggable)[0].id != "") {
+ // on dropping unabridged div
+ var x = ui.helper.clone();
+ var helperID = ui.helper.clone().context.id;
+ ui.helper.remove();
+ ctrl_addDashNotegroups(x.context.id);
+ x.remove(); // get rid of clone
+ }
+ }
+});
+
+$("#remove-drag").droppable({
+ drop: function (event, ui) {
+ $(ui.draggable).remove();
+ },
+ hoverClass: "remove-drag-hover",
+ accept: '.remove'
+});
+
+}
+
+var onDocReady = function(){
+
}
-jQuery(function() {
+
+jQuery(document).ready(function() {
+
+ populateNotegroupsUnabridged();
+ $("#notegroupsUnabridged").tabs();
+ makeUnabridgedDragDroppable();
+ for(var key in dictKeys){
+ $("#ngTab_"+dictKeys[key].safename).tabs();
+ }
+
+ $("#notegroupsUnabridged2").tabs();
+
+ $( ".cNoteGroup" ).draggable({ addClasses: false });
+
+
$(gen_fret_boxes(19, 6)).insertAfter($('#mainfretboard'));
GUITAR_STRINGS = getFretcloneStrings();
set_notes();
+
+ // add another row onto Fretclone to serve as fretpaint buttons
+ var newRow = function(){
+ var html ="
"
+ var board_strings = $('#fretclone tr');
+
+ var children = board_strings[0].children;
+ for (var f = 0; f < children.length; f++){
+ html +=' | ';
+ }
+ html +="
"
+ return html;
+ }
+ $('#fretclone > tbody:last').append(newRow);
+
+ //populateScaleMenu(); // removed from view
- // show diagram of a C Major chord
- //show_chord([null, 1, null, 2, [3, 'red']]);
-
- //var a_minor_penta = [[5, 8], [5, 8], [5, 7], [5, 7], [5, 7], [5, 8]];
- // show diagram of an A minor penta scale form
- //show_scale(a_minor_penta);
- loadFromUrl(get_url_parameters());
+ var url_params = get_url_parameters();
+ var loadFromUrl = function(){
+ if (is_defined(url_params['intColor'])){
+ if(url_params['intColor'] == "true"){
+
+ ctl_updateColorIntMode(true);
+ }
+ }
+ if (is_defined(url_params['intNames'])){
+ if(url_params['intNames'] == "true"){
+ ctl_updateIntervalMode(true);
+ }
+ }
+ if (is_defined(url_params['key'])){
+ // key should use safename
+ ctl_change_key.keyChangeNotegroup(url_params['key']);
+ }
+ if (is_defined(url_params['dash'])){
+ var arrNotgroups = url_params['dash'];
+ ctl_populateDash(arrNotgroups);
+ }
+ if (is_defined(url_params['diagram_title'])){
+ $('#diagram_title').val(unescape(url_params['diagram_title']));
+ }
+ if (is_defined(url_params['strings'])){
+ if (is_defined(url_params['q']) && url_params['q'] == 'y'){
+ COLOR = "black";
+ $('#checkanswer').click(function(){
+ check_answers(url_params['strings']);
+ });
+ $('#colorchooser').hide();
+ $('#checkanswer').show();
+ } else {
+ fill_from_repr(url_params['strings']);
+ }
+ }
+ }
+ loadFromUrl();
update_link();
var message = $('#message');
// update link at every click on a note...
@@ -255,27 +844,163 @@ jQuery(function() {
message.html('');
})
- // set up eraser and clear buttons:
- $('#eraser').toggle(function(){
- ERASER = true;
- $(this).removeClass('blank').addClass('white');
- message.html('
Eraser activated!Mouseover the marks to erase them')
- }, function(){
- $(this).removeClass('white').addClass('blank');
- ERASER = false;
- message.html('')
+ // set up fret painters which paint or erase fret
+ $('.fretpainter').click(function(){
+ //get the corresponding fret
+ var fret = this.id.split('_')[1];
+ var fpainted = false;
+ for(var s = 0; s < GUITAR_STRINGS.length; s++){
+ var nc = $('#'+'nc_'+s+'_'+fret);
+ if(is_painted(nc)){
+ fpainted = true;
+ break;
+ }
+ }
+
+
+ for(var s = 0; s < GUITAR_STRINGS.length; s++){
+ if(fpainted){
+ td_clear($('#'+'nc_'+s+'_'+fret));
+ } else{
+ var ns = $('#'+'nc_'+s+'_'+fret);
+ if(COLORBYINTERVALS){
+ ctl_color_td_by_interval(s,fret)
+ } else
+ {
+ td_paint($('#'+'nc_'+s+'_'+fret), COLOR);
+ }
+
+ }
+ }
+
+ })
+
+ // set up eraser brush and clear buttons:
+ $('#brush').click(function(){
+ var iteration=$(this).data('iteration')||1
+ switch ( iteration) {
+ case 1:
+ BRUSH = true;
+ ERASER = false;
+ $(this).removeClass('blank').addClass('white');
+ //message.html('
Brush activated!Mouseover the marks to paint them');
+ break;
+ case 2:
+ $(this).removeClass('white').addClass('blank');
+ BRUSH = false;
+ //message.html('')
+ break;
+ }
+ iteration++;
+ if (iteration>2) iteration=1
+ $(this).data('iteration',iteration)
});
+
+ $('#eraser').click(function(){
+ var iteration=$(this).data('iteration')||1
+ switch ( iteration) {
+ case 1:
+ ERASER = true;
+ BRUSH = false;
+ $(this).removeClass('blank').addClass('white');
+ //message.html('
Eraser activated!Mouseover the marks to erase them');
+ break;
+ case 2:
+ $(this).removeClass('white').addClass('blank');
+ ERASER = false;
+ //message.html('')
+ break;
+ }
+ iteration++;
+ if (iteration>2) iteration=1
+ $(this).data('iteration',iteration)
+ });
+
+
+
$('#clear').click(function(){
message.html('');
clear_fretboard(); update_link();
});
+
+ $('#modeNoteInt').click(function(){
+ if(INTERVALMODE == true){
+ ctl_updateIntervalMode(false);
+ } else{
+ ctl_updateIntervalMode(true);
+ }
+
+ });
+
+ $('#colorByInterval').click(function(){
+ if(COLORBYINTERVALS){
+ ctl_updateColorIntMode(false);
+ } else {
+ ctl_updateColorIntMode(true);
+ }
+
+
+ });
+
+ $('#setRoot').click(function(){
+ if(!SETTINGROOT){
+ SETTINGROOT=true;
+ } else {
+ SETTINGROOT=false;
+ }
+ updateSetRootView();
+ });
+
+ $('#selKey').change(function(){
+ ctl_change_key.selKeyChange($('#selKey').val());
+
+ });
+
+ // dash player controls
+ $('#dashPlayStop').click(function(){
+ if (mPlayer.getPlaystate() == PS_PLAYING){
+ ctl_stopPlayer();
+ } else {
+ ctl_playPlayer();
+ }
+ });
+
+ $('#dashBack').click(function(){
+ ctl_backPlayer();
+
+ });
+
+ $('#dashFwd').click(function(){
+ ctl_fwdPlayer();
+ });
+
+
+ $('#dashSpeed').change(function(){
+ var timerSpeed = Math.round(1000 * 60 / $('#dashSpeed').val() );
+ mPlayer.setPlaySpeed(timerSpeed);
+ });
+
+ // removed from view
+// $('#selScale').change(function(){
+// var newScale = $('#selScale').val();
+// //var key = $('#selKey').val();
+// mFB.setNotegroup(newScale, dictScales);
+//// mScale.setScale(newScale);
+//// A_INTERVAL_COLOR = mScale.getIntColorArr();
+//// A_INTERVAL_NAMES = mScale.getIntNamesArr();
+// set_notespans();
+// });
// set up example links
$('#examples ul li a').click(function(){
- clear_fretboard();
- loadFromUrl(get_url_parameters($(this).attr('href')));
- update_link();
+ url_params = get_url_parameters($(this).attr('href'));
+ clear_fretboard(); update_link();
+ loadFromUrl();
});
- // TODO: fix quiz behavior (do not show note names in quiz mode), and show message on check answer
- // TODO: find a way to show enarmonics
+
+
+
+
+ // TODO: generate jTab
+ // TODO: show chord in standard notation
});
diff --git a/fretboard.css b/fretboard.css
new file mode 100644
index 0000000..77f28ea
--- /dev/null
+++ b/fretboard.css
@@ -0,0 +1,253 @@
+@charset "utf-8";
+/* CSS Document */
+
+* { margin:0; padding:0; border-spacing:0; }
+body { font-family:sans-serif; font-size:100%; }
+table#mainfretboard { position:absolute; top:120px; left:50px; border:1px solid red; }
+table#mainfretboard tr td { border:1px solid black; font-size: 28px; width:46px; height:34px; text-align:center; }
+/* fretclone sits at z of 1 over main fretboard */
+table#fretclone { position:absolute; top:100px; left:-5px; border-spacing:8px; }
+table#fretclone tr td { margin: 0 2px; display:inline-block; border:2px solid transparent; background-color:transparent; font-size:18px; font-weight:bold; width:40px;height:24px; text-align:center; z-index:1; border-radius: 5px; }
+table#fretclone tr td:hover { cursor:pointer; border-color: black !important; border-style: dotted !important; }
+
+
+a:focus { outline: thin dotted #333; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; }
+a:hover, a:active { outline: 0; }
+a { color: #0088cc; text-decoration: none; }
+a:hover { color: #005580; text-decoration: underline; }
+/*a:hover { color: #FF0000; text-decoration: underline; }*/
+
+/* interval colorings */
+.i_root { background-color:#f2a87d !important; border-color:#400d14 !important; color:#400d14 !important; }
+.i_flatnine { background-color:#FFF !important; border-color:#f7f900 !important; color:#333333 !important; }
+.i_nine { background-color:#FFF !important; border-color:#f7f900 !important; color:#333333 !important; }
+.i_flatnine { background-color:#FFF !important; border-color:#f7f900 !important; color:#333333 !important; }
+.i_sharpnine { background-color:#000 !important; border-color:#80c0f9 !important; color:#FFF !important; }
+.i_flatthird { background-color:#000 !important; border-color:#80c0f9 !important; color:#FFF !important; }
+.i_third { background-color:#000 !important; border-color:#80c0f9 !important; color:#FFF !important; }
+.i_eleven {}
+.i_sharpeleven {}
+.i_flatfifth { background-color:#000 !important; border-color:#c5f1a8 !important; color:#FFF !important; }
+.i_fifth { background-color:#000 !important; border-color:#c5f1a8 !important; color:#FFF !important; }
+.i_augfifth { background-color:#000 !important; border-color:#c5f1a8 !important; color:#FFF !important; }
+.i_flatsixth { background-color:#FFF !important; border-color:#80c0f9 !important; color:#333333 !important; }
+.i_sixth { background-color:#FFF !important; border-color:#80c0f9 !important; color:#333333 !important; }
+.i_flatseventh { background-color:#000 !important; border-color:#ccc7fa !important; color:#FFF !important; }
+.i_seventh { background-color:#000 !important; border-color:#ccc7fa !important; color:#FFF !important; }
+.i_passing { background-color:#ffffff !important; border-color:#333 !important; color:#111111 !important; }
+
+/* pallete colorings */
+.black { background-color:#000 !important; border-color:#000 !important; color:#FFF !important; }
+.orange { background-color:#ffbb67 !important; border-color:#543d22 !important; color:#333 !important; }
+.green { background-color:#669999 !important; border-color:#003333 !important; color:#003333 !important; }
+.blue { background-color:#333745 !important; border-color:#afcded !important; color:#afcded !important; }
+.yellow { background-color:#f6f792 !important; border-color:#4c4c2d !important; color:#4c4c2d !important; }
+.lightgreen { background-color:#daede2 !important; border-color:#000000 !important; color:#000000 !important; }
+.red { background-color:#ea2e49 !important; border-color:#400d14 !important; color:#400d14 !important; }
+.blank { background-color:#dddddd !important; border-color:#333333 !important; color:#333333 !important; }
+.white { background-color:#ffffff !important; border-color:#FFF !important; color:#111111 !important; }
+
+
+.transparent { background-color:transparent !important; border-color:transparent !important; color:transparent !important }
+
+table#fretclone tr .fretpainter {background-color:#CFCFCF !important; border-color:#FFF !important; color:#4c4c2d !important; height:4px !important; border-radius:0px !important;}
+
+div#main { height:280px; margin:10px; width: 940px; }
+#diagram_title { font-size:25px; font-weight:bold; margin:15px; display:block; padding:4px; border:0; width:100%; }
+
+div.h_ctrl_cnt{ padding:10px; margin:0px 10px 0px 10px; }
+div.h_ctrl { display:inline; margin-right: 12px; }
+
+
+
+.setRootArmed { background-color:rgb(147,32,32); color: #FFF;}
+
+#clear, #eraser, #brush { font-weight: bold; padding: 2px; }
+
+input.color_button { width:40px; border-radius: 5px; }
+
+#colorchooser { display:inline; };
+
+
+
+
+
+#form_controls { padding:10px; }
+
+#checkanswer { display:none; }
+#message { text-align: right;
+ color:#a5a5a5;
+ }
+#examples ul { margin-left: 20px; }
+
+/* jquery ui*/
+.tabs-nohdr {
+ padding: 0px;
+ background: none;
+ border-width: 0px;
+ font-size: inherit;
+
+
+
+}
+.tabs-nohdr .ui-tabs-nav {
+ padding-left: 0px;
+ background: transparent;
+ border-width: 0px 0px 1px 0px;
+ -moz-border-radius: 0px;
+ -webkit-border-radius: 0px;
+ border-radius: 0px;
+}
+.tabs-nohdr .ui-tabs-panel {
+ background: #FFF;
+ border-width: 0px 1px 1px 1px;
+ overflow:auto;
+}
+.tabs-nohdr .ui-tabs-anchor{
+ font-weight:normal;
+}
+/* must be under tabs-nohdr */
+div#notegroupsUnabridged {
+ font-size:12px;
+ width: 650px;
+ display:inline-block;
+ float:left;
+}
+
+div#notegroupsUnabridged2 {
+ font-size:12px;
+ width: 650px;
+ display:inline-block;
+ float:left;
+}
+
+
+#notegroupsKeysTab a{
+ font-weight:bold;
+}
+
+
+#dashContainer{
+ border:#aaa thin solid;
+ padding:4px 12px 12px 12px;
+ display:inline-block;
+ float:left;
+ margin-left: 10px;
+ border-radius: 4px;
+ }
+#dashControls{
+ padding:8px;
+ height:24px;
+ }
+#dashControls input { padding:2px;}
+#ngDashboard {
+ border:#aaa thin solid;
+ width: 588px;
+ height: 400px;
+
+}
+
+div.cNoteGroup{
+ float:left;
+ text-align:center;
+ font-size:14px;
+ font-weight: bold;
+ width:120px;
+ height:36px;
+ padding: 4px;
+ margin: 8px;
+ background:rgb(200,238,251);
+ border-bottom:#555 thin solid;
+ border-top:#FFF thin solid;
+ border-right:#FFF thin solid;
+ border-left:#FFF thin solid;
+ /*border-width: 0px 0px 1px 0px; */
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ border-radius: 4px;
+}
+
+div .ngUnabDiv{
+ float:left;
+ text-align:center;
+ width:220px;
+ padding: 6px;
+ margin: 2px;
+ background:rgb(200,238,251);
+ border:#555 thin solid;
+ border-width: 0px 0px 1px 0px;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ border-radius: 4px;
+}
+
+div .tabs-nobg .ui-tabs-panel {
+ overflow:hidden;
+ padding:5px;
+ }
+
+.ui-draggable-helper{
+ background:#aaa;
+ z-index:999;
+ border:#F00 thin solid;
+ }
+
+ul .uNotegroup{
+ list-style:none;
+ border:#555 thin solid;
+ padding:3px;
+ margin: 2px;
+ }
+
+div .ngboxScale{
+ background:#ddfcc2;
+}
+
+div .ngboxArp{
+ background:#faf5af;
+}
+
+div .ngboxChd{
+ background:#cff6fd;
+}
+/* drag drop classes */
+ .ngExchange{}
+ span .drag{
+ background-color:rgb(153,153,153);
+ }
+ .remove-drag-hover {
+ background-color: #ED4949 !important;
+ }
+ .drop-area {
+ background-color: #afd1b2;
+ }
+ .xicon {
+ margin-top: 4px;
+ position: absolute;
+ margin-left: -17px;
+ color: #FFF;
+ font: message-box;
+ text-decoration: none;
+ }
+ .xicon:hover {
+ background-color: #fff;
+ color: #000;
+ width: 13px;
+ height: 20px;
+ text-align: center;
+ }
+ .tip {
+ font-size: 12px;
+ clear: both;
+ }
+
+/* end drag drop classes */
+
+
+div .playing{
+ //color:red;
+ border:rgb(255,0,0) thin solid;
+ //text-decoration:underline;
+ //background-color: rgb(255,102,153);
+ }
+/*@media print { #form_controls { display:none; } }*/
\ No newline at end of file
diff --git a/fretboard.html b/fretboard.html
index ae40233..3962d80 100644
--- a/fretboard.html
+++ b/fretboard.html
@@ -3,40 +3,20 @@
Fretboard Studies
-
-
-
@@ -49,34 +29,161 @@
| | ● | | ● | | ● | | ● | | | | | | ● | | ● | |
| | | | | | | | | | | ● | | | | | | |
| | | | | | | | | | | | | | | | | |
-
-
+
+
-