-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVcode.min.js
More file actions
1 lines (1 loc) · 1.68 KB
/
Vcode.min.js
File metadata and controls
1 lines (1 loc) · 1.68 KB
1
!function(t,e){"function"==typeof define?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.Vcode=e()}(this,function(){function s(t,e){return Math.random()*(e-t)+t}function a(t){for(var e=[],n=0;n<3;n++)e[n]=Math.floor(Math.random()*t);return"rgb("+(e=e.join(","))+")"}var t=function(t){this.code=null,this.data=null,this.count=t.count||4,this.el=document.querySelector(t.el),function(t){var e=this.el,n=t.spacing||"normal";!function(t,e){var n="";for(var o in e)n+=o+":"+e[o]+";";t.style.cssText=n}(e,{position:"relative",overflow:"hidden","font-family":"arial,sans-serif","text-align":"center","-ms-user-select":"none","user-select":"none","text-shadow":"0 2px 3px #333","font-size":t.fontSize||"inherit","line-height":e.offsetHeight+"px","letter-spacing":n}),this.data=t.data||{number:"0123456789",letter:"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",mix:"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"}[t.type||"mix"],this.onReset()}.apply(this,arguments)};return t.prototype.onReset=function(){var t,e,n;t=function(t,e){for(var n="",o=0;o<t;o++)n+=e.charAt(Math.random()*e.length);return n}(this.count,this.data),e=this.el.offsetWidth,n=this.el.offsetHeight,this.el.innerHTML=function(t){for(var e,n="",o=0,i=t.length;o<i;o++)n+="<span style='"+(e="transform: rotate("+s(-45,45)+"deg);")+"-ms-"+e+"display:inline-block;color:"+a(160)+";'>"+t.charAt(o)+"</span>";return n}(t)+function(t,e){for(var n="",o=t*e/36,i=0,r=Math.floor(o);i<r;i++)n+=Math.floor(s(-1,t))+"px "+Math.floor(s(-1,e))+"px 0 "+a(256)+",";return"<div style='width:2px;height:2px;opacity:0.9;position:absolute;top:0;left:0;box-shadow:"+(n=n.substring(0,n.length-1))+"'</div>"}(e,n),this.code=t},t});