Build 576754stable
Module 498419
8,694 characters · in 40041.5a3e48a93289fd56.jsDependencies
Source Raw
function(t){!function(){var e=function(t){"use strict";t=t||{};var e,n,i,r,o,a,s,l,u,c,h,d,f,p,g,m,y={bgColor:"#d00",textColor:"#fff",fontFamily:"sans-serif",fontStyle:"bold",type:"circle",position:"down",animation:"slide",elementId:!1,dataUrl:!1,win:window};(f={}).ff="u">typeof InstallTrigger,f.chrome=!!window.chrome,f.opera=!!window.opera||navigator.userAgent.indexOf("Opera")>=0,f.ie=!1,f.safari=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0,f.supported=f.chrome||f.ff||f.opera;var v=[];h=function(){},l=d=!1;var b={};b.ready=function(){l=!0,b.reset(),h()},b.reset=function(){l&&(v=[],u=!1,c=!1,a.clearRect(0,0,r,i),a.drawImage(s,0,0,r,i),S.setIcon(o),window.clearTimeout(p),window.clearTimeout(g))},b.start=function(){if(l&&!c){var t=function(){u=v[0],c=!1,v.length>0&&(v.shift(),b.start())};if(v.length>0){c=!0;var n=function(){["type","animation","bgColor","textColor","fontFamily","fontStyle"].forEach(function(t){t in v[0].options&&(e[t]=v[0].options[t])}),C.run(v[0].options,function(){t()},!1)};u?C.run(u.options,function(){n()},!0):n()}}};var w={},x=function(t){return t.n="number"==typeof t.n?Math.abs(0|t.n):t.n,t.x=r*t.x,t.y=i*t.y,t.w=r*t.w,t.h=i*t.h,t.len=(""+t.n).length,t};function _(t){if(t.paused||t.ended||d)return!1;try{a.clearRect(0,0,r,i),a.drawImage(t,0,0,r,i)}catch(t){}g=setTimeout(function(){_(t)},C.duration),S.setIcon(o)}w.circle=function(t){t=x(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,r,i),a.drawImage(s,0,0,r,i),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()},w.rectangle=function(t){t=x(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,r,i),a.drawImage(s,0,0,r,i),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 S={};function E(t){t=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,n,i){return e+e+n+n+i+i});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 T(t,e){var n,i={};for(n in t)i[n]=t[n];for(n in e)i[n]=e[n];return i}S.getIcon=function(){var t=!1;return e.element?t=e.element:e.elementId?(t=m.getElementById(e.elementId)).setAttribute("href",t.getAttribute("src")):!1===(t=function(){for(var t=m.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=m.createElement("link")).setAttribute("rel","icon"),m.getElementsByTagName("head")[0].appendChild(t)),t.setAttribute("type","image/png"),t},S.setIcon=function(t){var i=t.toDataURL("image/png");if(e.dataUrl&&e.dataUrl(i),e.element)e.element.setAttribute("href",i),e.element.setAttribute("src",i);else if(e.elementId){var r=m.getElementById(e.elementId);r.setAttribute("href",i),r.setAttribute("src",i)}else if(f.ff||f.opera){var o=n;n=m.createElement("link"),f.opera&&n.setAttribute("rel","icon"),n.setAttribute("rel","icon"),n.setAttribute("type","image/png"),m.getElementsByTagName("head")[0].appendChild(n),n.setAttribute("href",i),o.parentNode&&o.parentNode.removeChild(o)}else n.setAttribute("href",i)};var C={};C.duration=40,C.types={},C.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}],C.types.none=[{x:.4,y:.4,w:.6,h:.6,o:1}],C.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}],C.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}],C.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}],C.run=function(t,n,i,r){var a=C.types[m.hidden||m.msHidden||m.webkitHidden||m.mozHidden?"none":e.animation];(r=!0===i?void 0!==r?r:a.length-1:void 0!==r?r:0,n=n||function(){},r<a.length&&r>=0)?(w[e.type](T(t,a[r])),p=setTimeout(function(){i?r-=1:r+=1,C.run(t,n,i,r)},C.duration),S.setIcon(o)):n()},(e=T(y,t)).bgColor=E(e.bgColor),e.textColor=E(e.textColor),e.position=e.position.toLowerCase(),e.animation=C.types[""+e.animation]?e.animation:y.animation,m=e.win.document;var A=e.position.indexOf("up")>-1,R=e.position.indexOf("left")>-1;if(A||R)for(var D=0;D<C.types[""+e.animation].length;D++){var M=C.types[""+e.animation][D];A&&(M.y<.6?M.y=M.y-.4:M.y=M.y-2*M.y+(1-M.w)),R&&(M.x<.6?M.x=M.x-.4:M.x=M.x-2*M.x+(1-M.h)),C.types[""+e.animation][D]=M}return e.type=w[""+e.type]?e.type:y.type,n=S.getIcon(),o=document.createElement("canvas"),s=document.createElement("img"),n.hasAttribute("href")?(s.setAttribute("crossOrigin","anonymous"),s.onload=function(){i=s.height>0?s.height:32,r=s.width>0?s.width:32,o.height=i,o.width=r,a=o.getContext("2d"),b.ready()},s.setAttribute("src",n.getAttribute("href"))):(s.onload=function(){i=32,r=32,s.height=i,s.width=r,o.height=i,o.width=r,a=o.getContext("2d"),b.ready()},s.setAttribute("src","")),{badge:function(t,e){e=("string"==typeof e?{animation:e}:e)||{},h=function(){try{if("number"==typeof t?t>0:""!==t){var n={type:"badge",options:{n:t}};if("animation"in e&&C.types[""+e.animation]&&(n.options.animation=""+e.animation),"type"in e&&w[""+e.type]&&(n.options.type=""+e.type),["bgColor","textColor"].forEach(function(t){t in e&&(n.options[t]=E(e[t]))}),["fontStyle","fontFamily"].forEach(function(t){t in e&&(n.options[t]=e[t])}),v.push(n),v.length>100)throw Error("Too many badges requests in queue.");b.start()}else b.reset()}catch(t){throw Error("Error setting badge. Message: "+t.message)}},l&&h()},video:function(t){h=function(){try{if("stop"===t){d=!0,b.reset(),d=!1;return}t.addEventListener("play",function(){_(this)},!1)}catch(t){throw Error("Error setting video. Message: "+t.message)}},l&&h()},image:function(t){h=function(){try{var e=t.width,n=t.height,s=document.createElement("img"),l=e/r<n/i?e/r:n/i;s.setAttribute("crossOrigin","anonymous"),s.onload=function(){a.clearRect(0,0,r,i),a.drawImage(s,0,0,r,i),S.setIcon(o)},s.setAttribute("src",t.getAttribute("src")),s.height=n/l,s.width=e/l}catch(t){throw Error("Error setting image. Message: "+t.message)}},l&&h()},webcam:function(t){if(window.URL&&window.URL.createObjectURL||(window.URL=window.URL||{},window.URL.createObjectURL=function(t){return t}),f.supported){var e=!1;navigator.getUserMedia=navigator.getUserMedia||navigator.oGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia||navigator.webkitGetUserMedia,h=function(){try{if("stop"===t){d=!0,b.reset(),d=!1;return}(e=document.createElement("video")).width=r,e.height=i,navigator.getUserMedia({video:!0,audio:!1},function(t){e.src=URL.createObjectURL(t),e.play(),_(e)},function(){})}catch(t){throw Error("Error setting webcam. Message: "+t.message)}},l&&h()}},reset:b.reset,browser:{supported:f.supported}}};"u">typeof define&&define.amd?define([],function(){return e}):t.exports?t.exports=e:this.Favico=e}()}