d247275d8266bad8d22c108df1b40a8665e109bf
tdreszer
  Fri Sep 23 16:16:24 2011 -0700
Another load of subCfg module (scm). Heavy work getting subCbs, matCbs and views all playing nice.
diff --git src/hg/js/utils.js src/hg/js/utils.js
index fe86c46..949d48e 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -264,50 +264,40 @@
 function tdbIsCompositeSubtrack(tdb)  { return (tdb.kindOfChild  == 2); }
 function tdbIsMultiTrackSubtrack(tdb) { return (tdb.kindOfChild  == 3); }
 function tdbIsSubtrack(tdb)           { return (tdb.kindOfChild  == 2 || tdb.kindOfChild == 3); }
 function tdbHasParent(tdb)            { return (tdb.kindOfChild  != 0 && tdb.parentTrack); }
 
 function aryFind(ary,val)
 {// returns the index of a value on the array or -1;
     for(var ix=0;ix<ary.length;ix++) {
         if(ary[ix] == val) {
             return ix;
         }
     }
     return -1;
 }
 
-function aryRemoveVals(ary,vals)
+function aryRemove(ary,vals)
 { // removes one or more variables that are found in the array
     for(var vIx=0;vIx<vals.length;vIx++) {
         var ix = aryFind(ary,vals[vIx]);
         if(ix != -1)
             ary.splice(ix,1);
     }
     return ary;
 }
 
-function aryRemove(ary,val)
-{ // removes one or more variables that are found in the array
-    for(var vIx=1;vIx<arguments.length;vIx++) {
-        var ix = aryFind(ary,arguments[vIx]);
-        if(ix != -1)
-            ary.splice(ix,1);
-    }
-    return ary;
-}
-
 function isInteger(s)
 {
     return (!isNaN(parseInt(s)) && isFinite(s) && s.toString().indexOf('.') < 0);
 }
 function isFloat(s)
 {
     return (!isNaN(parseFloat(s)) && isFinite(s));
 }
 
 function validateInt(obj,min,max)
 {   // validates an integer which may be restricted to a range (if min and/or max are numbers)
     var title = obj.title;
     var rangeMin=parseInt(min);
     var rangeMax=parseInt(max);
     if(title.length == 0)
@@ -1355,31 +1345,31 @@
 {// Updates the sortOrder in a sortable table
     if (addSuperscript == undefined)
         addSuperscript = false;
     if ($(table).is('tbody'))
         table = $(table).parent();
     var tr = $(table).find('tr.sortable')[0];
     if (tr) {
         //warn("sortOrderUpdate("+sortColumns.cellIxs.length+")");
         for(cIx=0;cIx<sortColumns.cellIxs.length;cIx++) {
             var th = tr.cells[sortColumns.cellIxs[cIx]];
             $(th).each(function(i) {
                 // First remove old sort classes
                 var classList = $( this ).attr("class").split(" ");
                 if (classList.length < 2) // assertable
                     return;
-                classList = aryRemove(classList,"sortable");
+                classList = aryRemove(classList,["sortable"]);
                 while( classList.length > 0 ) {
                     var aClass = classList.pop();
                     if (aClass.indexOf("sort") == 0)
                         $(this).removeClass(aClass);
                 }
 
                 // Now add current sort classes
                 $(this).addClass("sort"+(cIx+1));
                 if (sortColumns.reverse[cIx])
                     $(this).addClass("sortRev");
 
                 // update any superscript
                 sup = $(this).find('sup')[0];
                 if (sup || addSuperscript) {
                     var content = (sortColumns.reverse[cIx] == false ? "&darr;":"&uarr;");
@@ -1406,31 +1396,31 @@
 }
 
 function sortOrderFromTr(tr)
 {// Looks up the sortOrder input value from a *.sortable header row of a sortable table
     var inp = $(tr).find('input.sortOrder')[0];
     if (inp)
         return $(inp).val();
     else {
         // create something like "cellType=+ rep=+ protocol=+ treatment=+ factor=+ view=+"
         var fields = new Array();
         var cells = $(tr).find('th.sortable');
         $(cells).each(function (i) {
             var classList = $( this ).attr("class").split(" ");
             if (classList.length < 2) // assertable
                 return;
-            classList = aryRemove(classList,"sortable");
+            classList = aryRemove(classList,["sortable"]);
             var reverse = false;
             var sortIx = -1;
             while( classList.length > 0 ) {
                 var aClass = classList.pop();
                 if (aClass.indexOf("sort") == 0) {
                     if (aClass == "sortRev")
                         reverse = true;
                     else {
                         aClass = aClass.substring(4);  // clip off the "sort" portion
                         var ix = parseInt(aClass);
                         if (ix != NaN) {
                             sortIx = ix;
                         }
                     }
                 }
@@ -2302,31 +2292,31 @@
 }
 
 /////////////////////////////////////////////////////
 // filterTable functions
 
 function filterTableFilterVar(filter)
 { // returns the var associated with a fileFilter
 
     if($(filter).hasClass('filterBy') == false)
         return undefined;
     if($(filter).hasClass('filterTable') == false)
         return undefined;
 
     // Find the var for this filter
     var classes = $(filter).attr("class").split(' ');
-    classes = aryRemove(classes,"filterBy","filterTable","noneIsAll");
+    classes = aryRemove(classes,["filterBy","filterTable","noneIsAll"]);
     if (classes.length > 1 ) {
         warn('Too many classes for filterBy: ' + classes);
         return undefined;
     }
     return classes.pop();
 }
 
 /* // This version of filterTable() uses the yieldingIterator methods.
    // These methods and the yieldingIterator were developed because IE was so slow.
    // HOWEVER: IE was sped up by avoiding .add() and .parent(),
    // so I reverted to simpler code but wish to retain this example for
    // future reference of how to deael with slow javascript.
 
 function _filterTableByClassesIterative(args)
 { // Applies a single class filter to a filterTable TRs
@@ -2616,31 +2606,31 @@
         $(filter).children('option.excluded').removeClass('excluded');   // remove .excluded" from all
         return true;  // Nothing more to do.  All are already excluded
     }
 
     // Find the tds that belong to this var
     var tds = $(visibleTrs).find('td.'+filterVar);
     if (tds.length == 0) {
         $(filter).children('option').addClass('excluded');   // add .excluded" to all
         return true;
     }
 
     // Find the val classes
     var classes = new Array();
     $(tds).each(function (i) {
         var someClass = $(this).attr("class").split(' ');
-        someClass = aryRemove(someClass,filterVar);
+        someClass = aryRemove(someClass,[filterVar]);
         var val = someClass.pop()
         if (aryFind(classes,val) == -1)
             classes.push(val);
     });
     if (classes.length == 0) {
         $(filter).children('option').addClass('excluded');   // add .excluded" to all
         return true;
     }
 
     // Find all options with those classes
     $(filter).children('option').each(function (i) {
         if (aryFind(classes,$(this).val()) != -1)
             $(this).removeClass('excluded'); // remove .excluded from matching
         else
             $(this).addClass('excluded');    // add .excluded" to non-matching