Permalink
Browse files

Add force update of the clock when the app is refocused.

  • Loading branch information...
koggdal committed Feb 22, 2012
1 parent 97704eb commit e0d5815b37b8ac36c36b754d15df4b46fa61bc62
Showing with 23 additions and 0 deletions.
  1. +23 −0 js/clockface-cards.js
View
@@ -50,6 +50,9 @@ var clockFace = {
}
}
+ window.addEventListener('focus', function () {
+ clockFace.forceUpdate();
+ }, false);
},
@@ -90,6 +93,26 @@ var clockFace = {
this.canvas.redraw();
},
+ forceUpdate: function () {
+ var cards = this.cards;
+ var c, r, clone, i;
+
+ var date = new Date();
+ var hours = date.getHours();
+ var minutes = date.getMinutes();
+ this.lastDate = { h: hours, min: minutes };
+ hours = this.getSplitDigits(hours);
+ minutes = this.getSplitDigits(minutes);
+ var digits = [hours[0], hours[1], minutes[0], minutes[1]];
+
+ for (i = 0; i < 8; i++) {
+ c = parseInt(i / 2);
+ r = i % 2;
+ cards[i].children[0].text = this.getDigit(cards[i], c < 2 ? date.getHours() : date.getMinutes(), c, digits[c] + r);
+ }
+ this.canvas.redraw();
+ },
+
moveCards: function (col, fullValue) {
var self, card1, card2;
self = this;

0 comments on commit e0d5815

Please sign in to comment.