Module 498419

8,694 characters · in 15230.72f1553659600211.js
Dependencies
Required by (1)
Lazily required by (0)none
Requires (0)none
Lazily requires (0)none
Source Raw
function(t){!function(){var e=function(t){"use strict";t=t||{};var e,n,r,i,o,a,s,c,h,u,l,f,p,d,g,y,m={bgColor:"#d00",textColor:"#fff",fontFamily:"sans-serif",fontStyle:"bold",type:"circle",position:"down",animation:"slide",elementId:!1,dataUrl:!1,win:window};(p={}).ff="u">typeof InstallTrigger,p.chrome=!!window.chrome,p.opera=!!window.opera||navigator.userAgent.indexOf("Opera")>=0,p.ie=!1,p.safari=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0,p.supported=p.chrome||p.ff||p.opera;var x=[];l=function(){},c=f=!1;var v={};v.ready=function(){c=!0,v.reset(),l()},v.reset=function(){c&&(x=[],h=!1,u=!1,a.clearRect(0,0,i,r),a.drawImage(s,0,0,i,r),A.setIcon(o),window.clearTimeout(d),window.clearTimeout(g))},v.start=function(){if(c&&!u){var t=function(){h=x[0],u=!1,x.length>0&&(x.shift(),v.start())};if(x.length>0){u=!0;var n=function(){["type","animation","bgColor","textColor","fontFamily","fontStyle"].forEach(function(t){t in x[0].options&&(e[t]=x[0].options[t])}),E.run(x[0].options,function(){t()},!1)};h?E.run(h.options,function(){n()},!0):n()}}};var b={},_=function(t){return t.n="number"==typeof t.n?Math.abs(0|t.n):t.n,t.x=i*t.x,t.y=r*t.y,t.w=i*t.w,t.h=r*t.h,t.len=(""+t.n).length,t};function w(t){if(t.paused||t.ended||f)return!1;try{a.clearRect(0,0,i,r),a.drawImage(t,0,0,i,r)}catch(t){}g=setTimeout(function(){w(t)},E.duration),A.setIcon(o)}b.circle=function(t){t=_(t);var n=!1;2===t.len?(t.x=t.x-.4*t.w,t.w=1.4*t.w,n=!0):t.len>=3&&(t.x=t.x-.65*t.w,t.w=1.65*t.w,n=!0),a.clearRect(0,0,i,r),a.drawImage(s,0,0,i,r),a.beginPath(),a.font=e.fontStyle+" "+Math.floor(t.h*(t.n>99?.85:1))+"px "+e.fontFamily,a.textAlign="center",n?(a.moveTo(t.x+t.w/2,t.y),a.lineTo(t.x+t.w-t.h/2,t.y),a.quadraticCurveTo(t.x+t.w,t.y,t.x+t.w,t.y+t.h/2),a.lineTo(t.x+t.w,t.y+t.h-t.h/2),a.quadraticCurveTo(t.x+t.w,t.y+t.h,t.x+t.w-t.h/2,t.y+t.h),a.lineTo(t.x+t.h/2,t.y+t.h),a.quadraticCurveTo(t.x,t.y+t.h,t.x,t.y+t.h-t.h/2),a.lineTo(t.x,t.y+t.h/2),a.quadraticCurveTo(t.x,t.y,t.x+t.h/2,t.y)):a.arc(t.x+t.w/2,t.y+t.h/2,t.h/2,0,2*Math.PI),a.fillStyle="rgba("+e.bgColor.r+","+e.bgColor.g+","+e.bgColor.b+","+t.o+")",a.fill(),a.closePath(),a.beginPath(),a.stroke(),a.fillStyle="rgba("+e.textColor.r+","+e.textColor.g+","+e.textColor.b+","+t.o+")","number"==typeof t.n&&t.n>999?a.fillText((t.n>9999?9:Math.floor(t.n/1e3))+"k+",Math.floor(t.x+t.w/2),Math.floor(t.y+t.h-.2*t.h)):a.fillText(t.n,Math.floor(t.x+t.w/2),Math.floor(t.y+t.h-.15*t.h)),a.closePath()},b.rectangle=function(t){t=_(t);2===t.len?(t.x=t.x-.4*t.w,t.w=1.4*t.w):t.len>=3&&(t.x=t.x-.65*t.w,t.w=1.65*t.w),a.clearRect(0,0,i,r),a.drawImage(s,0,0,i,r),a.beginPath(),a.font=e.fontStyle+" "+Math.floor(t.h*(t.n>99?.9:1))+"px "+e.fontFamily,a.textAlign="center",a.fillStyle="rgba("+e.bgColor.r+","+e.bgColor.g+","+e.bgColor.b+","+t.o+")",a.fillRect(t.x,t.y,t.w,t.h),a.fillStyle="rgba("+e.textColor.r+","+e.textColor.g+","+e.textColor.b+","+t.o+")","number"==typeof t.n&&t.n>999?a.fillText((t.n>9999?9:Math.floor(t.n/1e3))+"k+",Math.floor(t.x+t.w/2),Math.floor(t.y+t.h-.2*t.h)):a.fillText(t.n,Math.floor(t.x+t.w/2),Math.floor(t.y+t.h-.15*t.h)),a.closePath()};var A={};function C(t){t=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,n,r){return e+e+n+n+r+r});var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return!!e&&{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}}function S(t,e){var n,r={};for(n in t)r[n]=t[n];for(n in e)r[n]=e[n];return r}A.getIcon=function(){var t=!1;return e.element?t=e.element:e.elementId?(t=y.getElementById(e.elementId)).setAttribute("href",t.getAttribute("src")):!1===(t=function(){for(var t=y.getElementsByTagName("head")[0].getElementsByTagName("link"),e=t.length,n=e-1;n>=0;n--)if(/(^|\s)icon(\s|$)/i.test(t[n].getAttribute("rel")))return t[n];return!1}())&&((t=y.createElement("link")).setAttribute("rel","icon"),y.getElementsByTagName("head")[0].appendChild(t)),t.setAttribute("type","image/png"),t},A.setIcon=function(t){var r=t.toDataURL("image/png");if(e.dataUrl&&e.dataUrl(r),e.element)e.element.setAttribute("href",r),e.element.setAttribute("src",r);else if(e.elementId){var i=y.getElementById(e.elementId);i.setAttribute("href",r),i.setAttribute("src",r)}else if(p.ff||p.opera){var o=n;n=y.createElement("link"),p.opera&&n.setAttribute("rel","icon"),n.setAttribute("rel","icon"),n.setAttribute("type","image/png"),y.getElementsByTagName("head")[0].appendChild(n),n.setAttribute("href",r),o.parentNode&&o.parentNode.removeChild(o)}else n.setAttribute("href",r)};var E={};E.duration=40,E.types={},E.types.fade=[{x:.4,y:.4,w:.6,h:.6,o:0},{x:.4,y:.4,w:.6,h:.6,o:.1},{x:.4,y:.4,w:.6,h:.6,o:.2},{x:.4,y:.4,w:.6,h:.6,o:.3},{x:.4,y:.4,w:.6,h:.6,o:.4},{x:.4,y:.4,w:.6,h:.6,o:.5},{x:.4,y:.4,w:.6,h:.6,o:.6},{x:.4,y:.4,w:.6,h:.6,o:.7},{x:.4,y:.4,w:.6,h:.6,o:.8},{x:.4,y:.4,w:.6,h:.6,o:.9},{x:.4,y:.4,w:.6,h:.6,o:1}],E.types.none=[{x:.4,y:.4,w:.6,h:.6,o:1}],E.types.pop=[{x:1,y:1,w:0,h:0,o:1},{x:.9,y:.9,w:.1,h:.1,o:1},{x:.8,y:.8,w:.2,h:.2,o:1},{x:.7,y:.7,w:.3,h:.3,o:1},{x:.6,y:.6,w:.4,h:.4,o:1},{x:.5,y:.5,w:.5,h:.5,o:1},{x:.4,y:.4,w:.6,h:.6,o:1}],E.types.popFade=[{x:.75,y:.75,w:0,h:0,o:0},{x:.65,y:.65,w:.1,h:.1,o:.2},{x:.6,y:.6,w:.2,h:.2,o:.4},{x:.55,y:.55,w:.3,h:.3,o:.6},{x:.5,y:.5,w:.4,h:.4,o:.8},{x:.45,y:.45,w:.5,h:.5,o:.9},{x:.4,y:.4,w:.6,h:.6,o:1}],E.types.slide=[{x:.4,y:1,w:.6,h:.6,o:1},{x:.4,y:.9,w:.6,h:.6,o:1},{x:.4,y:.9,w:.6,h:.6,o:1},{x:.4,y:.8,w:.6,h:.6,o:1},{x:.4,y:.7,w:.6,h:.6,o:1},{x:.4,y:.6,w:.6,h:.6,o:1},{x:.4,y:.5,w:.6,h:.6,o:1},{x:.4,y:.4,w:.6,h:.6,o:1}],E.run=function(t,n,r,i){var a=E.types[y.hidden||y.msHidden||y.webkitHidden||y.mozHidden?"none":e.animation];(i=!0===r?void 0!==i?i:a.length-1:void 0!==i?i:0,n=n||function(){},i<a.length&&i>=0)?(b[e.type](S(t,a[i])),d=setTimeout(function(){r?i-=1:i+=1,E.run(t,n,r,i)},E.duration),A.setIcon(o)):n()},(e=S(m,t)).bgColor=C(e.bgColor),e.textColor=C(e.textColor),e.position=e.position.toLowerCase(),e.animation=E.types[""+e.animation]?e.animation:m.animation,y=e.win.document;var T=e.position.indexOf("up")>-1,R=e.position.indexOf("left")>-1;if(T||R)for(var M=0;M<E.types[""+e.animation].length;M++){var P=E.types[""+e.animation][M];T&&(P.y<.6?P.y=P.y-.4:P.y=P.y-2*P.y+(1-P.w)),R&&(P.x<.6?P.x=P.x-.4:P.x=P.x-2*P.x+(1-P.h)),E.types[""+e.animation][M]=P}return e.type=b[""+e.type]?e.type:m.type,n=A.getIcon(),o=document.createElement("canvas"),s=document.createElement("img"),n.hasAttribute("href")?(s.setAttribute("crossOrigin","anonymous"),s.onload=function(){r=s.height>0?s.height:32,i=s.width>0?s.width:32,o.height=r,o.width=i,a=o.getContext("2d"),v.ready()},s.setAttribute("src",n.getAttribute("href"))):(s.onload=function(){r=32,i=32,s.height=r,s.width=i,o.height=r,o.width=i,a=o.getContext("2d"),v.ready()},s.setAttribute("src","")),{badge:function(t,e){e=("string"==typeof e?{animation:e}:e)||{},l=function(){try{if("number"==typeof t?t>0:""!==t){var n={type:"badge",options:{n:t}};if("animation"in e&&E.types[""+e.animation]&&(n.options.animation=""+e.animation),"type"in e&&b[""+e.type]&&(n.options.type=""+e.type),["bgColor","textColor"].forEach(function(t){t in e&&(n.options[t]=C(e[t]))}),["fontStyle","fontFamily"].forEach(function(t){t in e&&(n.options[t]=e[t])}),x.push(n),x.length>100)throw Error("Too many badges requests in queue.");v.start()}else v.reset()}catch(t){throw Error("Error setting badge. Message: "+t.message)}},c&&l()},video:function(t){l=function(){try{if("stop"===t){f=!0,v.reset(),f=!1;return}t.addEventListener("play",function(){w(this)},!1)}catch(t){throw Error("Error setting video. Message: "+t.message)}},c&&l()},image:function(t){l=function(){try{var e=t.width,n=t.height,s=document.createElement("img"),c=e/i<n/r?e/i:n/r;s.setAttribute("crossOrigin","anonymous"),s.onload=function(){a.clearRect(0,0,i,r),a.drawImage(s,0,0,i,r),A.setIcon(o)},s.setAttribute("src",t.getAttribute("src")),s.height=n/c,s.width=e/c}catch(t){throw Error("Error setting image. Message: "+t.message)}},c&&l()},webcam:function(t){if(window.URL&&window.URL.createObjectURL||(window.URL=window.URL||{},window.URL.createObjectURL=function(t){return t}),p.supported){var e=!1;navigator.getUserMedia=navigator.getUserMedia||navigator.oGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia||navigator.webkitGetUserMedia,l=function(){try{if("stop"===t){f=!0,v.reset(),f=!1;return}(e=document.createElement("video")).width=i,e.height=r,navigator.getUserMedia({video:!0,audio:!1},function(t){e.src=URL.createObjectURL(t),e.play(),w(e)},function(){})}catch(t){throw Error("Error setting webcam. Message: "+t.message)}},c&&l()}},reset:v.reset,browser:{supported:p.supported}}};"u">typeof define&&define.amd?define([],function(){return e}):t.exports?t.exports=e:this.Favico=e}()}