src/hg/js/utils.js 1.25

1.25 2009/11/11 21:55:14 tdreszer
Added some obvious array functions
Index: src/hg/js/utils.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/utils.js,v
retrieving revision 1.24
retrieving revision 1.25
diff -b -B -U 4 -r1.24 -r1.25
--- src/hg/js/utils.js	23 Aug 2009 20:38:06 -0000	1.24
+++ src/hg/js/utils.js	11 Nov 2009 21:55:14 -0000	1.25
@@ -249,8 +249,28 @@
     }
     return postTheForm(formName,window.location.href);
 }
 
+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 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);
 }