Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

notifications should remove themselves

  • Loading branch information...
commit 83b7866d4f337f5c39688cc89b845c9d93ce3ad6 1 parent f8d0bbf
Nikolai Warner authored
18 background.html
... ... @@ -1,2 +1,18 @@
1 1 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
2   -<script src="jacopo.js" type="text/javascript"></script>
  2 +<script src="jacopo.js" type="text/javascript"></script>
  3 +
  4 +<script>
  5 +$(document).ready(function(){
  6 + jacopo.init();
  7 +
  8 + // listen_for_storage_updates
  9 + window.addEventListener("storage", function(event){
  10 + if (event.key === 'calendar_url') {
  11 + jacopo.schedule_refresh();
  12 + jacopo.update();
  13 + } else {
  14 + jacopo.update_interface();
  15 + }
  16 + }, false);
  17 +});
  18 +</script>
29 jacopo.js
@@ -34,15 +34,7 @@ var jacopo = {
34 34
35 35 // Show notification
36 36 if (localStorage['show_notification'] === 'true' && localStorage['progressed_today'] === 'false') {
37   - var current_time = new Date();
38   - var time_left_hours = 24 - current_time.getHours();
39   - //var time_left_minutes = 60 - current_time.getMinutes();
40   -
41   - var notification = webkitNotifications.createNotification(
42   - 'icon.png',
43   - "Don't break your streak.",
44   - 'You have not completed your contribution to open source today. You have less than ' + time_left_hours + ' hours remaining.'
45   - );
  37 + var notification = webkitNotifications.createHTMLNotification('notification.html');
46 38 notification.show();
47 39 }
48 40
@@ -81,8 +73,6 @@ var jacopo = {
81 73
82 74
83 75 update: function() {
84   - console.log("UPDATED AT: "+(Math.round(new Date().getTime() / 1000)));
85   -
86 76 // A simple scrape of the page will do for now.
87 77 // We'll authenticate to github for faster results in the future.
88 78 this.fetch_from_calendar_url();
@@ -92,19 +82,4 @@ var jacopo = {
92 82 this.schedule_refresh();
93 83 this.update();
94 84 }
95   -};
96   -
97   -
98   -$(document).ready(function(){
99   - jacopo.init();
100   -
101   - // listen_for_storage_updates
102   - window.addEventListener("storage", function(event){
103   - if (event.key === 'calendar_url') {
104   - jacopo.schedule_refresh();
105   - jacopo.update();
106   - } else {
107   - jacopo.update_interface();
108   - }
109   - }, false);
110   -});
  85 +};
2  manifest.json
... ... @@ -1,6 +1,6 @@
1 1 {
2 2 "name": "Jacopo",
3   - "version": "1.2.0",
  3 + "version": "1.2.2",
4 4 "description": "A little reminder for your Seinfeld Calendar",
5 5 "background_page": "background.html",
6 6 "browser_action": {
31 notification.html
... ... @@ -0,0 +1,31 @@
  1 +<link href="stylesheet.css" media="screen" rel="stylesheet" type="text/css" />
  2 +
  3 +<p>
  4 + <img src='icon.png' style='float:left; padding: 5px;' />
  5 +
  6 + <h1>Don't break your streak.</h1>
  7 + <br/>
  8 + You have not completed your contribution to open source today.
  9 + <br/>
  10 + <span id='time_left'></span>
  11 +</p>
  12 +
  13 +
  14 +
  15 +
  16 +
  17 +<script src="jacopo.js" type="text/javascript"></script>
  18 +
  19 +<script>
  20 + // remove before the next refresh
  21 + setTimeout(function(){
  22 + window.close();
  23 + }, jacopo.refresh_rate);
  24 +
  25 + // set the time remaining text
  26 + var current_time = new Date();
  27 + var time_left_hours = 24 - current_time.getHours();
  28 + var time_left_text = "Less than " + time_left_hours + " hour";
  29 + time_left_text = (time_left_hours === 1) ? time_left_text + "s remain." : time_left_text + " remains.";
  30 + document.getElementById('time_left').innerHTML = time_left_text;
  31 +</script>
22 options.html
... ... @@ -1,5 +1,7 @@
1 1 <html>
2   -<head><title>Options</title></head>
  2 +<head><title>Options</title>
  3 +<link href="stylesheet.css" media="screen" rel="stylesheet" type="text/css" />
  4 +
3 5 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
4 6 <script type="text/javascript">
5 7
@@ -25,23 +27,7 @@
25 27
26 28 </script>
27 29
28   -<style>
29   - h1, div {
30   - font-family: Helvetica;
31   - font-size: 15px;
32   - padding-bottom: 10px;
33   - }
34   -
35   - h1 {
36   - border-bottom: 1px solid #ddd;
37   - }
38   -
39   - #status{
40   - text-align: center;
41   - color: #999;
42   - }
43   -</style>
44   -
  30 +</head>
45 31 <body onload="restore_options()">
46 32
47 33 <div id='status'></div>
14 stylesheet.css
... ... @@ -0,0 +1,14 @@
  1 +h1, div {
  2 + font-family: Helvetica;
  3 + font-size: 15px;
  4 + padding-bottom: 10px;
  5 +}
  6 +
  7 +h1 {
  8 + border-bottom: 1px solid #ddd;
  9 +}
  10 +
  11 +#status{
  12 + text-align: center;
  13 + color: #999;
  14 +}

0 comments on commit 83b7866

Please sign in to comment.
Something went wrong with that request. Please try again.