Skip to content

Commit

Permalink
using setInterval now since I feel that may be more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaiwarner committed Jan 26, 2011
1 parent 23a7a13 commit 0dea475
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
28 changes: 20 additions & 8 deletions background.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<script>
var jacopo = {

refresh_rate: 3600000,
refresh_rate: 60 * 60 * 1000,
default_calendar_url: 'http://calendaraboutnothing.com/~',

refresh_timer: undefined,


fetch_from_calendar_url: function() {
var self = this;
Expand Down Expand Up @@ -54,27 +56,37 @@
chrome.browserAction.setIcon({path: "icon.png"});
chrome.browserAction.setBadgeBackgroundColor({color:[255,0,0,255]});
}

// Schedule Next Update
setTimeout(function(){
self.update();
}, this.refresh_rate);
},


schedule_refresh: function() {
var self = this;
if (this.refresh_timer) {
clearInterval(this.refresh_timer);
}
this.refresh_timer = setInterval(function(){ self.update(); }, this.refresh_rate);
},


update: function() {
console.log("UPDATED AT: "+(Math.round(new Date().getTime() / 1000)));

// A simple scrape of the page will do for now.
// We'll authenticate to github for faster results in the future.
this.fetch_from_calendar_url();
}
},

init: function() {
this.schedule_refresh();
this.update();
}
};

jacopo.update();
jacopo.init();

// listen_for_storage_updates
window.addEventListener("storage", function(event){
jacopo.schedule_refresh();
jacopo.update();
}, false);

Expand Down
Binary file modified jacopo.crx
Binary file not shown.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Jacopo",
"version": "1.0.1",
"version": "1.1.0",
"description": "A little reminder for your Seinfeld Calendar",
"background_page": "background.html",
"browser_action": {
Expand Down

0 comments on commit 0dea475

Please sign in to comment.