Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaiwarner committed Jan 19, 2011
0 parents commit c2f61a3
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 0 deletions.
20 changes: 20 additions & 0 deletions LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2011 Nikolai Warner

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 12 additions & 0 deletions README.md
@@ -0,0 +1,12 @@
# Jacopo: Get your streak on.

Jacopo is a little reminder for your Seinfeld Calendar that lives in Chrome.


## Usage

* Install the extension!

* Set your seinfeld calendar url in the Options. Perhaps go here first: http://calendaraboutnothing.com

* Make some open source progress!
82 changes: 82 additions & 0 deletions background.html
@@ -0,0 +1,82 @@
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script>
var seinfeld_chrome = {

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


fetch_from_calendar_url: function() {
var self = this;
if (localStorage['calendar_url'] === undefined || localStorage['calendar_url'] === this.default_calendar_url) {
localStorage['calendar_url'] = this.default_calendar_url;
} else {
$.ajax({
url: localStorage['calendar_url'],
success: function(data) {
self.calendar_data_response(data);
}
});
}
},


calendar_data_response: function(data) {
// Streak
localStorage['current_streak'] = parseInt($(".current_streak span.num", data).html(), 10);

// Get Progress Today
if ($(".progressed.today", data).length > 0) {
localStorage['progressed_today'] = 'true';
} else {
localStorage['progressed_today'] = 'false';
}

this.update_interface();
},


update_interface: function() {
var self = this;

// Update Badge
if (localStorage['show_badge'] === 'true') {
chrome.browserAction.setBadgeText({text: localStorage['current_streak']});
} else {
chrome.browserAction.setBadgeText({text: ""});
}

// Update Progress
if (localStorage['progressed_today'] === 'true') {
chrome.browserAction.setIcon({path: "icon_green.png"});
chrome.browserAction.setBadgeBackgroundColor({color:[0,255,0,255]});
} else {
chrome.browserAction.setIcon({path: "icon.png"});
chrome.browserAction.setBadgeBackgroundColor({color:[255,0,0,255]});
}

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



update: function() {
// 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();
}

};

seinfeld_chrome.update();

// listen_for_storage_updates
window.addEventListener("storage", function(event){
console.log('store')
seinfeld_chrome.update();
}, false);

</script>
Binary file added icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon_green.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jacopo.crx
Binary file not shown.
19 changes: 19 additions & 0 deletions manifest.json
@@ -0,0 +1,19 @@
{
"name": "Jacopo",
"version": "1.0",
"description": "A little reminder for your Seinfeld Calendar",
"background_page": "background.html",
"browser_action": {
"default_icon": "icon.png",
"popup": "options.html"
},
"options_page": "options.html",
"permissions": [
"http://*/"
],
"icons": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
}
}
65 changes: 65 additions & 0 deletions options.html
@@ -0,0 +1,65 @@
<html>
<head><title>Options</title></head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

function save_options() {

localStorage["show_badge"] = $('#show_badge').is(':checked');
localStorage["calendar_url"] = $('#calendar_url').val();

// Update status to let user know options were saved.
$("#status").html("Options Saved.");
setTimeout(function() {
$("#status").html("");
}, 4000);
}


function restore_options() {
$('#show_badge').attr('checked', (localStorage["show_badge"] === "true"));
$('#calendar_url').val(localStorage["calendar_url"]);
}

</script>

<style>
h1, div {
font-family: Helvetica;
font-size: 15px;
padding-bottom: 10px;
}

h1 {
border-bottom: 1px solid #ddd;
}

#status{
text-align: center;
color: #999;
}
</style>

<body onload="restore_options()">

<div id='status'></div>

<h1>
Options
</h1>

<div>
Calendar URL: <input type="text" id="calendar_url" style='width:300px' />
</div>

<div>
<input type="checkbox" id="show_badge" value="true" /> Show Current Streak
</div>


<div>
<button onclick="save_options()">Save</button>
</div>

</body>
</html>

0 comments on commit c2f61a3

Please sign in to comment.