diff --git a/piecon.js b/piecon.js index ca57c8c..ddfc621 100644 --- a/piecon.js +++ b/piecon.js @@ -3,7 +3,7 @@ // // https://github.com/lipka/piecon // -// Copyright (c) 2012 Lukas Lipka . All rights reserved. +// Copyright (c) 2015 Lukas Lipka . All rights reserved. // (function(){ diff --git a/piecon.min.js b/piecon.min.js index bc2aa1a..682fbbf 100644 --- a/piecon.min.js +++ b/piecon.min.js @@ -1 +1 @@ -!function(){var a={},b=null,c=null,d=null,e=null,f={},g={color:"#ff0084",background:"#bbb",shadow:"#fff",fallback:!1},h=window.devicePixelRatio>1,i=function(){var a=navigator.userAgent.toLowerCase();return function(b){return-1!==a.indexOf(b)}}(),j={ie:i("msie"),chrome:i("chrome"),webkit:i("chrome")||i("safari"),safari:i("safari")&&!i("chrome"),mozilla:i("mozilla")&&!i("chrome")&&!i("safari")},k=function(){for(var a=document.getElementsByTagName("link"),b=0,c=a.length;c>b;b++)if("icon"===a[b].getAttribute("rel")||"shortcut icon"===a[b].getAttribute("rel"))return a[b];return!1},l=function(){for(var a=document.getElementsByTagName("link"),b=document.getElementsByTagName("head")[0],c=0,d=a.length;d>c;c++)("icon"===a[c].getAttribute("rel")||"shortcut icon"===a[c].getAttribute("rel"))&&b.removeChild(a[c])},m=function(a){l();var b=document.createElement("link");b.type="image/x-icon",b.rel="icon",b.href=a,document.getElementsByTagName("head")[0].appendChild(b)},n=function(){return e||(e=document.createElement("canvas"),h?(e.width=32,e.height=32):(e.width=16,e.height=16)),e},o=function(a){var b=n(),c=b.getContext("2d");a=a||0,c&&(c.clearRect(0,0,b.width,b.height),c.beginPath(),c.moveTo(b.width/2,b.height/2),c.arc(b.width/2,b.height/2,Math.min(b.width/2,b.height/2),0,2*Math.PI,!1),c.fillStyle=f.shadow,c.fill(),c.beginPath(),c.moveTo(b.width/2,b.height/2),c.arc(b.width/2,b.height/2,Math.min(b.width/2,b.height/2)-2,0,2*Math.PI,!1),c.fillStyle=f.background,c.fill(),a>0&&(c.beginPath(),c.moveTo(b.width/2,b.height/2),c.arc(b.width/2,b.height/2,Math.min(b.width/2,b.height/2)-2,-.5*Math.PI,(-.5+2*a/100)*Math.PI,!1),c.lineTo(b.width/2,b.height/2),c.fillStyle=f.color,c.fill()),m(b.toDataURL()))},p=function(a){document.title=a>0?"("+a+"%) "+d:d};a.setOptions=function(a){f={};for(var b in g)f[b]=a.hasOwnProperty(b)?a[b]:g[b];return this},a.setProgress=function(a){if(d||(d=document.title),!c||!b){var e=k();c=b=e?e.getAttribute("href"):"/favicon.ico"}return!isNaN(parseFloat(a))&&isFinite(a)?!n().getContext||j.ie||j.safari||f.fallback===!0?p(a):("force"===f.fallback&&p(a),o(a)):!1},a.reset=function(){d&&(document.title=d),c&&(b=c,m(b))},a.setOptions(g),window.Piecon=a}(); +!function(){var t={},e=null,i=null,n=null,o=null,a={},r={color:"#ff0084",background:"#bbb",shadow:"#fff",fallback:!1},h=window.devicePixelRatio>1,l=function(){var t=navigator.userAgent.toLowerCase();return function(e){return-1!==t.indexOf(e)}}(),c={ie:l("msie"),chrome:l("chrome"),webkit:l("chrome")||l("safari"),safari:l("safari")&&!l("chrome"),mozilla:l("mozilla")&&!l("chrome")&&!l("safari")},u=function(){for(var t=document.getElementsByTagName("link"),e=0,i=t.length;i>e;e++)if("icon"===t[e].getAttribute("rel")||"shortcut icon"===t[e].getAttribute("rel"))return t[e];return!1},f=function(){for(var t=document.getElementsByTagName("link"),e=document.getElementsByTagName("head")[0],i=0,n=t.length;n>i;i++)("icon"===t[i].getAttribute("rel")||"shortcut icon"===t[i].getAttribute("rel"))&&e.removeChild(t[i])},g=function(t){f();var e=document.createElement("link");e.type="image/x-icon",e.rel="icon",e.href=t,document.getElementsByTagName("head")[0].appendChild(e)},d=function(){return o||(o=document.createElement("canvas"),h?(o.width=32,o.height=32):(o.width=16,o.height=16)),o},m=function(t){var e=d(),i=e.getContext("2d");t=t||0,i&&(i.clearRect(0,0,e.width,e.height),i.beginPath(),i.moveTo(e.width/2,e.height/2),i.arc(e.width/2,e.height/2,Math.min(e.width/2,e.height/2),0,2*Math.PI,!1),i.fillStyle=a.shadow,i.fill(),i.beginPath(),i.moveTo(e.width/2,e.height/2),i.arc(e.width/2,e.height/2,Math.min(e.width/2,e.height/2)-2,0,2*Math.PI,!1),i.fillStyle=a.background,i.fill(),t>0&&(i.beginPath(),i.moveTo(e.width/2,e.height/2),i.arc(e.width/2,e.height/2,Math.min(e.width/2,e.height/2)-2,-.5*Math.PI,(-.5+2*t/100)*Math.PI,!1),i.lineTo(e.width/2,e.height/2),i.fillStyle=a.color,i.fill()),g(e.toDataURL()))},s=function(t){document.title=t>0?"("+t+"%) "+n:n};t.setOptions=function(t){a={};for(var e in r)a[e]=t.hasOwnProperty(e)?t[e]:r[e];return this},t.setProgress=function(t){if(n||(n=document.title),!i||!e){var o=u();i=e=o?o.getAttribute("href"):"/favicon.ico"}return!isNaN(parseFloat(t))&&isFinite(t)?!d().getContext||c.ie||c.safari||a.fallback===!0?s(t):("force"===a.fallback&&s(t),m(t)):!1},t.reset=function(){n&&(document.title=n),i&&(e=i,g(e))},t.setOptions(r),window.Piecon=t}(); \ No newline at end of file