mirror of
https://github.com/lipka/piecon.git
synced 2026-04-18 03:00:25 -04:00
Compile minified version.
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
var links = document.getElementsByTagName('link');
|
||||
|
||||
for (var i = 0, l = links.length; i < l; i++) {
|
||||
if ((links[i].getAttribute('rel') || '').match(/\bicon\b/)) {
|
||||
if (links[i].getAttribute('rel') === 'icon' || links[i].getAttribute('rel') === 'shortcut icon') {
|
||||
return links[i];
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
|
||||
for (var i = 0, l = links.length; i < l; i++) {
|
||||
if (typeof(links[i]) !== 'undefined' && links[i].getAttribute('rel') === 'icon') {
|
||||
if (links[i].getAttribute('rel') === 'icon' || links[i].getAttribute('rel') === 'shortcut icon') {
|
||||
head.removeChild(links[i]);
|
||||
}
|
||||
}
|
||||
@@ -88,33 +88,33 @@
|
||||
|
||||
var faviconImage = new Image();
|
||||
faviconImage.onload = function() {
|
||||
context.clearRect(0, 0, 16, 16);
|
||||
if (context) {
|
||||
context.clearRect(0, 0, 16, 16);
|
||||
|
||||
// Draw shadow
|
||||
context.beginPath();
|
||||
context.moveTo(canvas.width / 2, canvas.height / 2);
|
||||
context.arc(canvas.width / 2, canvas.height / 2, Math.min(canvas.width / 2, canvas.height / 2), 0, Math.PI * 2, false);
|
||||
context.fillStyle = options.shadow;
|
||||
context.fill();
|
||||
|
||||
// Draw background
|
||||
context.beginPath();
|
||||
context.moveTo(canvas.width / 2, canvas.height / 2);
|
||||
context.arc(canvas.width / 2, canvas.height / 2, Math.min(canvas.width / 2, canvas.height / 2) - 2, 0, Math.PI * 2, false);
|
||||
context.fillStyle = options.background;
|
||||
context.fill();
|
||||
|
||||
// Draw pie
|
||||
if (percentage > 0) {
|
||||
// Draw shadow
|
||||
context.beginPath();
|
||||
context.moveTo(canvas.width / 2, canvas.height / 2);
|
||||
context.arc(canvas.width / 2, canvas.height / 2, Math.min(canvas.width / 2, canvas.height / 2) - 2, (-0.5) * Math.PI, (-0.5 + 2 * percentage / 100) * Math.PI, false);
|
||||
context.lineTo(canvas.width / 2, canvas.height / 2);
|
||||
context.fillStyle = options.color;
|
||||
context.arc(canvas.width / 2, canvas.height / 2, Math.min(canvas.width / 2, canvas.height / 2), 0, Math.PI * 2, false);
|
||||
context.fillStyle = options.shadow;
|
||||
context.fill();
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// Draw background
|
||||
context.beginPath();
|
||||
context.moveTo(canvas.width / 2, canvas.height / 2);
|
||||
context.arc(canvas.width / 2, canvas.height / 2, Math.min(canvas.width / 2, canvas.height / 2) - 2, 0, Math.PI * 2, false);
|
||||
context.fillStyle = options.background;
|
||||
context.fill();
|
||||
|
||||
// Draw pie
|
||||
if (percentage > 0) {
|
||||
context.beginPath();
|
||||
context.moveTo(canvas.width / 2, canvas.height / 2);
|
||||
context.arc(canvas.width / 2, canvas.height / 2, Math.min(canvas.width / 2, canvas.height / 2) - 2, (-0.5) * Math.PI, (-0.5 + 2 * percentage / 100) * Math.PI, false);
|
||||
context.lineTo(canvas.width / 2, canvas.height / 2);
|
||||
context.fillStyle = options.color;
|
||||
context.fill();
|
||||
}
|
||||
|
||||
setFaviconTag(canvas.toDataURL());
|
||||
}
|
||||
};
|
||||
@@ -129,12 +129,10 @@
|
||||
};
|
||||
|
||||
var updateTitle = function(percentage) {
|
||||
if (options.fallback) {
|
||||
if (percentage > 0) {
|
||||
document.title = '(' + percentage + '%) ' + originalTitle;
|
||||
} else {
|
||||
document.title = originalTitle;
|
||||
}
|
||||
if (percentage > 0) {
|
||||
document.title = '(' + percentage + '%) ' + originalTitle;
|
||||
} else {
|
||||
document.title = originalTitle;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -185,4 +183,4 @@
|
||||
|
||||
Piecon.setOptions(defaults);
|
||||
window.Piecon = Piecon;
|
||||
})();
|
||||
})();
|
||||
|
||||
10
piecon.min.js
vendored
10
piecon.min.js
vendored
@@ -1,5 +1,5 @@
|
||||
(function(){var i={},j=null,k=null,h=null,g=null,f={},l={color:"#ff0084",background:"#bbb",shadow:"#fff",fallback:!1},e,p=navigator.userAgent.toLowerCase();e=function(c){return-1!==p.indexOf(c)};var q=e("msie");e("chrome");e("chrome")||e("safari");var r=e("safari")&&!e("chrome");e("mozilla")&&!e("chrome")&&e("safari");var m=function(c){for(var a=document.getElementsByTagName("link"),e=document.getElementsByTagName("head")[0],f=0,h=a.length;f<h;f++)"undefined"!==typeof a[f]&&"icon"===a[f].getAttribute("rel")&&
|
||||
e.removeChild(a[f]);a=document.createElement("link");a.type="image/x-icon";a.rel="icon";a.href=c;document.getElementsByTagName("head")[0].appendChild(a)},n=function(){g||(g=document.createElement("canvas"),g.width=16,g.height=16);return g},o=function(c){f.fallback&&(document.title=0<c?"("+c+"%) "+h:h)};i.setOptions=function(c){f={};for(var a in l)f[a]=c.hasOwnProperty(a)?c[a]:l[a];return this};i.setProgress=function(c){h||(h=document.title);if(!k||!j){var a;a:{a=document.getElementsByTagName("link");
|
||||
for(var e=0,i=a.length;e<i;e++)if((a[e].getAttribute("rel")||"").match(/\bicon\b/)){a=a[e];break a}a=!1}k=j=a?a.getAttribute("href"):"/favicon.ico"}if(!isNaN(parseFloat(c))&&isFinite(c)){if(!n().getContext||q||r||!0==f.fallback)return o(c);"force"===f.fallback&&o(c);var g=c,b=n(),d=b.getContext("2d"),g=g||0,c=j;a=new Image;a.onload=function(){d.clearRect(0,0,16,16);d.beginPath();d.moveTo(b.width/2,b.height/2);d.arc(b.width/2,b.height/2,Math.min(b.width/2,b.height/2),0,Math.PI*2,false);d.fillStyle=
|
||||
f.shadow;d.fill();d.beginPath();d.moveTo(b.width/2,b.height/2);d.arc(b.width/2,b.height/2,Math.min(b.width/2,b.height/2)-2,0,Math.PI*2,false);d.fillStyle=f.background;d.fill();if(g>0){d.beginPath();d.moveTo(b.width/2,b.height/2);d.arc(b.width/2,b.height/2,Math.min(b.width/2,b.height/2)-2,-0.5*Math.PI,(-0.5+2*g/100)*Math.PI,false);d.lineTo(b.width/2,b.height/2);d.fillStyle=f.color;d.fill()}d&&m(b.toDataURL())};c.match(/^data/)||(a.crossOrigin="anonymous");a.src=c}else return!1};i.reset=function(){h&&
|
||||
(document.title=h);k&&(j=k,m(j))};i.setOptions(l);window.Piecon=i})();
|
||||
(function(){var i={},j=null,k=null,f=null,g=null,h={},l={color:"#ff0084",background:"#bbb",shadow:"#fff",fallback:!1},c,o=navigator.userAgent.toLowerCase();c=function(e){return-1!==o.indexOf(e)};var p=c("msie");c("chrome");c("chrome")||c("safari");var q=c("safari")&&!c("chrome");c("mozilla")&&!c("chrome")&&c("safari");var m=function(e){for(var a=document.getElementsByTagName("link"),c=document.getElementsByTagName("head")[0],f=0,h=a.length;f<h;f++)("icon"===a[f].getAttribute("rel")||"shortcut icon"===
|
||||
a[f].getAttribute("rel"))&&c.removeChild(a[f]);a=document.createElement("link");a.type="image/x-icon";a.rel="icon";a.href=e;document.getElementsByTagName("head")[0].appendChild(a)},n=function(){g||(g=document.createElement("canvas"),g.width=16,g.height=16);return g};i.setOptions=function(e){h={};for(var a in l)h[a]=e.hasOwnProperty(a)?e[a]:l[a];return this};i.setProgress=function(e){f||(f=document.title);if(!k||!j){var a;a:{a=document.getElementsByTagName("link");for(var c=0,i=a.length;c<i;c++)if("icon"===
|
||||
a[c].getAttribute("rel")||"shortcut icon"===a[c].getAttribute("rel")){a=a[c];break a}a=!1}k=j=a?a.getAttribute("href"):"/favicon.ico"}if(!isNaN(parseFloat(e))&&isFinite(e))if(!n().getContext||p||q||!0==h.fallback)document.title=0<e?"("+e+"%) "+f:f;else{"force"===h.fallback&&(document.title=0<e?"("+e+"%) "+f:f);var g=e,b=n(),d=b.getContext("2d"),g=g||0,e=j;a=new Image;a.onload=function(){if(d){d.clearRect(0,0,16,16);d.beginPath();d.moveTo(b.width/2,b.height/2);d.arc(b.width/2,b.height/2,Math.min(b.width/
|
||||
2,b.height/2),0,Math.PI*2,false);d.fillStyle=h.shadow;d.fill();d.beginPath();d.moveTo(b.width/2,b.height/2);d.arc(b.width/2,b.height/2,Math.min(b.width/2,b.height/2)-2,0,Math.PI*2,false);d.fillStyle=h.background;d.fill();if(g>0){d.beginPath();d.moveTo(b.width/2,b.height/2);d.arc(b.width/2,b.height/2,Math.min(b.width/2,b.height/2)-2,-0.5*Math.PI,(-0.5+2*g/100)*Math.PI,false);d.lineTo(b.width/2,b.height/2);d.fillStyle=h.color;d.fill()}m(b.toDataURL())}};e.match(/^data/)||(a.crossOrigin="anonymous");
|
||||
a.src=e}else return!1};i.reset=function(){f&&(document.title=f);k&&(j=k,m(j))};i.setOptions(l);window.Piecon=i})();
|
||||
|
||||
Reference in New Issue
Block a user