From: Raymond I. <xw...@us...> - 2003-03-30 17:14:02
|
Update of /cvsroot/dynapi/dynapi3x/src/ext In directory sc8-pr-cvs1:/tmp/cvs-serv11568/src/ext Modified Files: functions.math.js Log Message: uploaded by raymond - includes kevin's patches Index: functions.math.js =================================================================== RCS file: /cvsroot/dynapi/dynapi3x/src/ext/functions.math.js,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** functions.math.js 21 Feb 2003 12:23:43 -0000 1.2 --- functions.math.js 30 Mar 2003 17:13:24 -0000 1.3 *************** *** 22,25 **** --- 22,43 ---- for (var i=0; i<361; i+=1) lcos[i]=Math.cos((i/180)*Math.PI); }; + f.getRandomNumber = function(n) { + var t=new Date(); + n=(n)? n: parseInt(Math.random()*10000); + return Math.round((Math.abs(Math.sin(t.getTime()))*(Math.random()*1000)))%n+1; + }; + f.getGUID = function() { // Globally Unique ID + var n1,n2,n3,n4; + var l,r,m,c=Math.random()+'' + c=c.substr(c.indexOf('.')+1); + m=(c.length-1)/2; + l=c.substr(0,m); r=c.substr(m); + n1=this.getRandomNumber(1000); + n2=this.getRandomNumber(255);n3=this.getRandomNumber(255);n4=this.getRandomNumber(255); + n2 = (n2 < 16 ? '0' : '') + n2.toString(16); + n3 = (n3 < 16 ? '0' : '') + n3.toString(16); + n4 = (n4 < 16 ? '0' : '') + n4.toString(16); + return (n1+n2+'-'+l+'-'+n3+n4+'-'+r).toUpperCase(); + }; // Path Functions ------------------------ |