Skip to content

Commit 21616fc

Browse files
committed
code comments
1 parent 7b12ca9 commit 21616fc

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

boxfrets.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/* code to handle manipulation */
22

33
// 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'.
56
// 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.
89
//
910
// The Fretboard MCV paints the Fretboard at the top of the UI.
1011
// The FretboardModel tracks how to paints notes with appropriate text based on:
1112
// -color by interval vs color by pallete
1213
// -text of interval or text of note-name
1314
// -interval color is governed by KEY
1415
//
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
1617
//
1718
// The UI buttons below the fretboard change these states.
1819
// When 'brush' is 'on' moused-Over notes are painted according to state
@@ -23,7 +24,7 @@
2324
// The Key pulldown is an alternative to set root button,
2425
// sets key in uber model and recolors/renames painted notes if required
2526
//
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.
2728
// Tabbing allows collections of notegroups sorted by key, etc.
2829
// The colored divs are buttons serving as "notegroup" objects.
2930
// Clicking a notegroup recolors/renames the painted fret notes
@@ -36,7 +37,7 @@
3637
// Single-click of abridged notegroups repaints the fretboard like unabridged notegroups.
3738
// The play button cycles through the abridged notegroups in the dashboard, repainting the FB accordingly
3839
//
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.
4041
//
4142
// A link provides an html link with a snapshot of the app. Anytime the dashboard player or Fretboard is changed,
4243
// a new link must be created with update_link
@@ -50,8 +51,8 @@
5051
// constants
5152
var CHECKANSWER = 'Check Answer!';
5253
var HELP_TEXT = "HEre is some help";
53-
var GUITAR_STRINGS;
5454

55+
var GUITAR_STRINGS; // will be array of strings
5556
var INTERVAL_COLORS = [
5657
"i_root",
5758
"i_flatnine",
@@ -182,6 +183,8 @@ var getArrNotegroupsInDash = function(){
182183
str = str.replace(/,+$/, ""); // eliminate last comma
183184
return str;
184185
}
186+
187+
//generate URL based on snapshot of fretboard and dashboard player
185188
var create_link_from_fretboard = function(){
186189
var href = window.location.href;
187190
if (href.indexOf('#') > 0){
@@ -200,11 +203,13 @@ var create_link_from_fretboard = function(){
200203
return href;
201204
}
202205

206+
// update link should be called whenever view changes
203207
var update_link = function(){
204208
$('#linkthis').attr('href', create_link_from_fretboard());
205209
$('#linkquiz').attr('href', create_link_from_fretboard() + "&q=y");
206210
}
207-
// handle url parameters
211+
212+
// handler to get url parameters
208213
function get_url_parameters(){
209214
var query = arguments.length > 0 ? arguments[0] : window.location.href;
210215
var params = {};
@@ -218,6 +223,8 @@ function get_url_parameters(){
218223
}
219224
return params;
220225
}
226+
227+
// paint fretboard based on URL params for strings/frets
221228
function fill_from_repr(repr){
222229
var a_rep = repr.split(';');
223230
var match_color = arguments.length > 1 ? arguments[1] : null;
@@ -658,10 +665,6 @@ var set_notes_per_notegroup = function(keySafeName, ngType, ng){
658665
set_notespans();
659666
ctl_updateQuizzingInterval(false);
660667
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);
665668
}
666669

667670
var isPalleteColor = function(c){
@@ -671,6 +674,7 @@ var isPalleteColor = function(c){
671674
return false;
672675
}
673676

677+
// get step integer in a scale
674678
var getChromaticInt = function(noteStr, chromNamesScale){
675679

676680
if(chromNamesScale == null){
@@ -683,7 +687,7 @@ var getChromaticInt = function(noteStr, chromNamesScale){
683687
}
684688

685689

686-
690+
// return safename enharmonic
687691
var getEnharmonic = function(noteStr){
688692
// make sure more than 1 chars
689693
if(noteStr.length > 1){
@@ -736,12 +740,14 @@ var getKeyObjFromNoteName = function(noteStr){
736740
return getKeyObjFromUnsafeName(newKeyHtmlName);
737741
}
738742

743+
// safename eplicitly spells flat, natural or sharp with root
739744
var getSafeNameFromNoteName = function(noteStr){
740745
var intFromC = getKeyObjFromUnsafeName(noteStr).fromC
741746
var newKeyHtmlName = mFB.getKeyObj().baseScale[intFromC];
742747
return getKeyObjFromUnsafeName(newKeyHtmlName).safename;
743748
}
744749

750+
// keyObj is a key object with various names, steps from C
745751
var getKeyObjFromSafeName = function(safenameStr){
746752
var keyObj = "";
747753
for(ko in dictKeys){
@@ -781,6 +787,7 @@ var getKeyObjFromUnsafeName = function(htmlStr){
781787
return keyObj;
782788
}
783789

790+
// the notespan is a span with note text inside at td notecontainer
784791
var getNotespanFromTD = function(td){
785792
var arr = td.attr('id').split('_');
786793
return $('#ns_'+arr[1]+'_'+arr[2]);

0 commit comments

Comments
 (0)