Here you can find the source of randomAnagram()
String.prototype.randomAnagram = function () { return this.split('').sort(function () { return 0.5 - Math.random(); }).join('');//from ww w. ja v a 2 s .c om };
String.prototype.randomBetween = function(min, max) { var hash = this.getHashCode(); min = min || 0; max = max || 1; var seed = (hash * 9301 + 49297) % 233280; var rnd = Math.abs(seed / 233280.0); return min + rnd * (max - min); };
function randomString(bits){ var chars,rand,i,ret chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' ret='' while(bits > 0){ rand=Math.floor(Math.random()*0x100000000) for(i=26; i>0 && bits>0; i-=6, bits-=6) ret+=chars[0x3F & rand >>> i]} return ret console.log(0x3F); console.log(randomString(30)) var test = function(){ }; var s = new String(test); console.log(s.substring(s.indexOf("/*") + 3, s.lastIndexOf("*/"))); Function.prototype.getstr = function() { var lines = new String(this); lines = lines.substring(lines.indexOf("/*") + 3, lines.lastIndexOf("*/")); return lines; }; String.prototype.$ = function(r, v){ return this.replace(new RegExp('<!-- ' + r + ' -->', 'g'), v);}; String.prototype.trim = function() { return this.replace(/^\s+/g,"").replace(/\s+$/g,""); };
helpers.randomString = function(len, charSet) { charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var randomString = ''; for (var i = 0; i < len; i++) { var randomPoz = Math.floor(Math.random() * charSet.length); randomString += charSet.substring(randomPoz,randomPoz+1); return randomString; }; ...
String.randomString = function { "use strict"; charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var randomString = ''; for (var i = 0; i < len; i++) { var randomPoz = Math.floor(Math.random() * charSet.length); randomString += charSet.substring(randomPoz, randomPoz + 1); return randomString; ...