UUID.min.js 1.0 KB

1
  1. MWF.widget=MWF.widget||{};MWF.widget.UUID=new Class({initialize:function(){this.id=this.createUUID()},valueOf:function(){return this.id},toString:function(){return this.id},createUUID:function(){var t=new Date(1582,10,15,0,0,0,0);var e=new Date;var r=e.getTime()-t.getTime();var i=this.getIntegerBits(r,0,31);var n=this.getIntegerBits(r,32,47);var s=this.getIntegerBits(r,48,59)+"1";var a=this.getIntegerBits(this.rand(4095),0,7);var g=this.getIntegerBits(this.rand(4095),0,7);var h=this.getIntegerBits(this.rand(8191),0,7)+this.getIntegerBits(this.rand(8191),8,15)+this.getIntegerBits(this.rand(8191),0,7)+this.getIntegerBits(this.rand(8191),8,15)+this.getIntegerBits(this.rand(8191),0,15);return i+n+s+a+g+h},getIntegerBits:function(t,e,r){var i=this.returnBase(t,16);var n=new Array;var s="";var a=0;for(a=0;a<i.length;a++){n.push(i.substring(a,a+1))}for(a=Math.floor(e/4);a<=Math.floor(r/4);a++){if(!n[a]||n[a]=="")s+="0";else s+=n[a]}return s},returnBase:function(t,e){return t.toString(e).toUpperCase()},rand:function(t){return Math.floor(Math.random()*(t+1))}});