updated by GasGit automation
This commit is contained in:
parent
08b8899934
commit
2681411eaf
1 changed files with 35 additions and 0 deletions
|
@ -175,6 +175,41 @@ var Utils = (function (ns) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generateUniqueString
|
||||||
|
* get a unique string
|
||||||
|
* @param {number} optAbcLength the length of the alphabetic prefix
|
||||||
|
* @return {string} a unique string
|
||||||
|
**/
|
||||||
|
ns.generateUniqueString = function (optAbcLength) {
|
||||||
|
var abcLength = ns.isUndefined(optAbcLength) ? 3 : optAbcLength;
|
||||||
|
return (new Date().getTime()).toString(36) + arbitraryString(abcLength) ;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get an arbitrary alpha string
|
||||||
|
* @param {number} length of the string to generate
|
||||||
|
* @return {string} an alpha string
|
||||||
|
**/
|
||||||
|
ns.arbitraryString = function (length) {
|
||||||
|
var s = '';
|
||||||
|
for (var i = 0; i < length; i++) {
|
||||||
|
s += String.fromCharCode(ns.randBetween ( 97,122));
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* randBetween
|
||||||
|
* get an random number between x and y
|
||||||
|
* @param {number} min the lower bound
|
||||||
|
* @param {number} max the upper bound
|
||||||
|
* @return {number} the random number
|
||||||
|
**/
|
||||||
|
ns.randBetween = function (min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
ns.yesish = function(s) {
|
ns.yesish = function(s) {
|
||||||
var t = s.toString().toLowerCase();
|
var t = s.toString().toLowerCase();
|
||||||
return t === "yes" || "y" || "true" || "1";
|
return t === "yes" || "y" || "true" || "1";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue