Permalink
Browse files

Merge changes from cdrx/piecon.

  • Loading branch information...
1 parent f95e6f8 commit c4a8568f8c09c8576cb4331d9c56309d649f6b49 @lipka committed Sep 6, 2012
Showing with 27 additions and 29 deletions.
  1. +27 −29 piecon.js
View
@@ -88,33 +88,33 @@
var faviconImage = new Image();
faviconImage.onload = function() {
- 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) {
+ 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) - 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;
}
};

0 comments on commit c4a8568

Please sign in to comment.