3d283800e2d599f69c0d16fd6015620f7d27f5a1 tdreszer Fri May 9 13:42:40 2014 -0700 Replaced Object.keys() which may not be supported by some browsers and moved three utility type scripts from cart to utils.js. Redmine 13164. diff --git src/hg/js/utils.js src/hg/js/utils.js index a41f93a..e40facc 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -235,30 +235,56 @@ } } return -1; } 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 arysToObj(names,values) +{ // Make hash type obj with two parallel arrays. + var obj = {}; + for(var ix=0; ix<names.length; ix++) { + obj[names[ix]] = values[ix]; + } + return obj; +} + +function objNotEmpty(obj) +{ // returns true on non empty object. + return ($.isEmptyObject(obj) === false); +} + +function objKeyCount(obj) +{ // returns number of keys in object. + if (!Object.keys) { + var count = 0; + for (var key in obj) { + count++; + } + return count; + } else + return Object.keys(obj).length; +} + 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)