|
@ -30,25 +30,6 @@ exports.recursiveDOMDelete = function (DOMobject) { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* this function gives you a range between 0 and 1 based on the min and max values in the set, the total sum of all values and the current value. |
|
|
|
|
|
* |
|
|
|
|
|
* @param {number} min |
|
|
|
|
|
* @param {number} max |
|
|
|
|
|
* @param {number} total |
|
|
|
|
|
* @param {number} value |
|
|
|
|
|
* @returns {number} |
|
|
|
|
|
*/ |
|
|
|
|
|
exports.giveRange = function (min, max, total, value) { |
|
|
|
|
|
if (max == min) { |
|
|
|
|
|
return 0.5; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
var scale = 1 / (max - min); |
|
|
|
|
|
return Math.max(0, (value - min) * scale); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Test whether given object is a string |
|
|
* Test whether given object is a string |
|
|
* @param {*} object |
|
|
* @param {*} object |
|
@ -82,29 +63,13 @@ exports.isDate = function (object) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Create a semi UUID |
|
|
|
|
|
* source: http://stackoverflow.com/a/105074/1262753
|
|
|
|
|
|
|
|
|
* Create a UUID |
|
|
* @return {string} uuid |
|
|
* @return {string} uuid |
|
|
*/ |
|
|
*/ |
|
|
exports.randomUUID = function () { |
|
|
exports.randomUUID = function () { |
|
|
return uuid.v4(); |
|
|
return uuid.v4(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* assign all keys of an object that are not nested objects to a certain value (used for color objects). |
|
|
|
|
|
* @param {object} obj |
|
|
|
|
|
* @param {number} value |
|
|
|
|
|
*/ |
|
|
|
|
|
exports.assignAllKeys = function (obj, value) { |
|
|
|
|
|
for (var prop in obj) { |
|
|
|
|
|
if (obj.hasOwnProperty(prop)) { |
|
|
|
|
|
if (typeof obj[prop] !== 'object') { |
|
|
|
|
|
obj[prop] = value; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Copy property from b to a if property present in a. |
|
|
* Copy property from b to a if property present in a. |
|
|