1
1
/* code to handle manipulation */
2
2
3
3
// OVERVIEW:
4
- // This code is quite a jumble, but hopefully this outline will give direction.
4
+ // Hopefully this outline will give direction. I tried following some OOP and MCV principles best I could
5
+ // with Javascript. The Models, controllers and such are not discreetly encapsulated; just a 'road-map'.
5
6
// There are now basically three 'model-controller-views' to be aware of and an 'uber-model'
6
- // which are just vars holding states -- really it is connected to the FretboardModel.
7
- // The Models, controllers and such are not discreetly encapsulated, unfortunately. Just a 'road-map' .
7
+ // Perhaps uber-model would be better encapsulated in a Panel Model, in any case, it
8
+ // is just capitalized vars holding states .
8
9
//
9
10
// The Fretboard MCV paints the Fretboard at the top of the UI.
10
11
// The FretboardModel tracks how to paints notes with appropriate text based on:
11
12
// -color by interval vs color by pallete
12
13
// -text of interval or text of note-name
13
14
// -interval color is governed by KEY
14
15
//
15
- // Below the fretboard are grey buttons which paint or erase all notes in that fret
16
+ // Below the fretboard are grey buttons (fretpainters) which paint or erase all notes in that fret
16
17
//
17
18
// The UI buttons below the fretboard change these states.
18
19
// When 'brush' is 'on' moused-Over notes are painted according to state
23
24
// The Key pulldown is an alternative to set root button,
24
25
// sets key in uber model and recolors/renames painted notes if required
25
26
//
26
- // The div to the left under the UI buttons is the container for 'unabridged' notegroups -- scales, arpeggios, etc.
27
+ // The div to the left under the UI buttons is the 'Dictionary' for 'unabridged' notegroups -- scales, arpeggios, etc.
27
28
// Tabbing allows collections of notegroups sorted by key, etc.
28
29
// The colored divs are buttons serving as "notegroup" objects.
29
30
// Clicking a notegroup recolors/renames the painted fret notes
36
37
// Single-click of abridged notegroups repaints the fretboard like unabridged notegroups.
37
38
// The play button cycles through the abridged notegroups in the dashboard, repainting the FB accordingly
38
39
//
39
- // Below the unabridged dictionary and abridged dashboard player are the links and quizzes.
40
+ // Also in the 'panel' below the fretboard are links and quizzes.
40
41
//
41
42
// A link provides an html link with a snapshot of the app. Anytime the dashboard player or Fretboard is changed,
42
43
// a new link must be created with update_link
50
51
// constants
51
52
var CHECKANSWER = 'Check Answer!' ;
52
53
var HELP_TEXT = "HEre is some help" ;
53
- var GUITAR_STRINGS ;
54
54
55
+ var GUITAR_STRINGS ; // will be array of strings
55
56
var INTERVAL_COLORS = [
56
57
"i_root" ,
57
58
"i_flatnine" ,
@@ -182,6 +183,8 @@ var getArrNotegroupsInDash = function(){
182
183
str = str . replace ( / , + $ / , "" ) ; // eliminate last comma
183
184
return str ;
184
185
}
186
+
187
+ //generate URL based on snapshot of fretboard and dashboard player
185
188
var create_link_from_fretboard = function ( ) {
186
189
var href = window . location . href ;
187
190
if ( href . indexOf ( '#' ) > 0 ) {
@@ -200,11 +203,13 @@ var create_link_from_fretboard = function(){
200
203
return href ;
201
204
}
202
205
206
+ // update link should be called whenever view changes
203
207
var update_link = function ( ) {
204
208
$ ( '#linkthis' ) . attr ( 'href' , create_link_from_fretboard ( ) ) ;
205
209
$ ( '#linkquiz' ) . attr ( 'href' , create_link_from_fretboard ( ) + "&q=y" ) ;
206
210
}
207
- // handle url parameters
211
+
212
+ // handler to get url parameters
208
213
function get_url_parameters ( ) {
209
214
var query = arguments . length > 0 ? arguments [ 0 ] : window . location . href ;
210
215
var params = { } ;
@@ -218,6 +223,8 @@ function get_url_parameters(){
218
223
}
219
224
return params ;
220
225
}
226
+
227
+ // paint fretboard based on URL params for strings/frets
221
228
function fill_from_repr ( repr ) {
222
229
var a_rep = repr . split ( ';' ) ;
223
230
var match_color = arguments . length > 1 ? arguments [ 1 ] : null ;
@@ -658,10 +665,6 @@ var set_notes_per_notegroup = function(keySafeName, ngType, ng){
658
665
set_notespans ( ) ;
659
666
ctl_updateQuizzingInterval ( false ) ;
660
667
COLORBYINTERVALS = ! paletteState ; // keep pallete if open
661
- //var msg = "Painting notes for <strong>"+mFB.getKeyTextName();
662
- // if(ngType != "ARP"){msg += " ";}
663
- // msg += mFB.getNotegroup().name+"</strong>";
664
- // $('#message').html(msg);
665
668
}
666
669
667
670
var isPalleteColor = function ( c ) {
@@ -671,6 +674,7 @@ var isPalleteColor = function(c){
671
674
return false ;
672
675
}
673
676
677
+ // get step integer in a scale
674
678
var getChromaticInt = function ( noteStr , chromNamesScale ) {
675
679
676
680
if ( chromNamesScale == null ) {
@@ -683,7 +687,7 @@ var getChromaticInt = function(noteStr, chromNamesScale){
683
687
}
684
688
685
689
686
-
690
+ // return safename enharmonic
687
691
var getEnharmonic = function ( noteStr ) {
688
692
// make sure more than 1 chars
689
693
if ( noteStr . length > 1 ) {
@@ -736,12 +740,14 @@ var getKeyObjFromNoteName = function(noteStr){
736
740
return getKeyObjFromUnsafeName ( newKeyHtmlName ) ;
737
741
}
738
742
743
+ // safename eplicitly spells flat, natural or sharp with root
739
744
var getSafeNameFromNoteName = function ( noteStr ) {
740
745
var intFromC = getKeyObjFromUnsafeName ( noteStr ) . fromC
741
746
var newKeyHtmlName = mFB . getKeyObj ( ) . baseScale [ intFromC ] ;
742
747
return getKeyObjFromUnsafeName ( newKeyHtmlName ) . safename ;
743
748
}
744
749
750
+ // keyObj is a key object with various names, steps from C
745
751
var getKeyObjFromSafeName = function ( safenameStr ) {
746
752
var keyObj = "" ;
747
753
for ( ko in dictKeys ) {
@@ -781,6 +787,7 @@ var getKeyObjFromUnsafeName = function(htmlStr){
781
787
return keyObj ;
782
788
}
783
789
790
+ // the notespan is a span with note text inside at td notecontainer
784
791
var getNotespanFromTD = function ( td ) {
785
792
var arr = td . attr ( 'id' ) . split ( '_' ) ;
786
793
return $ ( '#ns_' + arr [ 1 ] + '_' + arr [ 2 ] ) ;
0 commit comments