Permalink
Browse files

Initial commit of the dealios chrome extension.

  • Loading branch information...
0 parents commit 8f799a442a05cc7713c6b2fbee48a57d156f830d @austenito austenito committed Aug 22, 2011
@@ -0,0 +1,152 @@
+<html>
+ <head>
+ <script src="fancy-options/lib/store.js"></script>
+ <script>
+
+ // Global settings
+ var settings = null;
+ var deal_to_link = [];
+
+ // TODO: Probably should make a func out of this
+ var city_feed_objs = [
+ {
+ 'city': 'honolulu',
+ 'city_display': 'Honolulu, HI',
+ 'feeds': [
+ {'title': 'Groupon', 'url': 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/grouponhonolulu'},
+ {'title': 'Living Social', 'url': 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://livingsocial.com/cities/82-honolulu.atom'},
+ {'title': 'Hot Deals Hawaii', 'url': 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://hotdealshawaii.com/rss/honolulu'},
+ ]
+ },
+ {
+ 'city': 'chicago',
+ 'city_display': 'Chicago, IL',
+ 'feeds': [
+ {'title': 'Groupon', 'url': 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/groupon'},
+ ]
+ },
+ ];
+
+ // Initialize
+ init();
+ run_background();
+ setInterval("run_background()", 3600000);
+
+ function init() {
+ var city_key = 'honolulu';
+ if (settings != null) {
+ var city_key = settings.get('dealios-location');
+ }
+ settings = new Store("settings", {'dealios-location': city_key});
+ };
+
+ function get_user_city_feed_obj() {
+ var city_key = settings.get('dealios-location');
+ for (feed in city_feed_objs) {
+ if (city_key == city_feed_objs[feed]['city']) {
+ return city_feed_objs[feed];
+ }
+ }
+ return null;
+ };
+
+ function crawl_json_feed(url, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function()
+ {
+ if (xhr.readyState == 4)
+ {
+ if (xhr.status == 200)
+ {
+ var json_response = JSON.parse(xhr.responseText);
+ callback(json_response);
+ }
+ else
+ {
+ callback(null);
+ }
+ }
+ };
+ xhr.open("GET", url, true);
+ xhr.send();
+ };
+
+ function add_deals_to_element(element)
+ {
+ for(deal_source in window.localStorage) {
+ if(deal_source != 'store.settings.dealios-location'){
+ var title = document.createElement('h3');
+ var title_text = document.createTextNode(deal_source);
+ title.appendChild(title_text);
+ element.appendChild(title);
+
+ var ul = document.createElement('ul');
+ var deal_titles = JSON.parse(window.localStorage.getItem(deal_source));
+ for (key in deal_titles) {
+ var title = deal_titles[key];
+ var li = document.createElement('li');
+
+ var link = document.createElement('a');
+ link.setAttribute('href', deal_to_link[title]);
+ link.setAttribute('target', '_blank');
+
+ var text = document.createTextNode(title);
+
+ link.appendChild(text);
+ li.appendChild(link);
+ ul.appendChild(li);
+ }
+ element.appendChild(ul);
+ }
+ }
+ };
+
+ function run_background()
+ {
+ var user_city_feed_obj = get_user_city_feed_obj();
+ var city_display = user_city_feed_obj.city_display;
+ var feeds = user_city_feed_obj.feeds;
+
+ for (feed in feeds) {
+ var deal_source = feeds[feed]['title'];
+ var url = feeds[feed]['url'];
+
+ // Closure
+ (function(deal_source, url) {
+ crawl_json_feed(url,
+ function(response) {
+ var entries = response.responseData.feed.entries;
+ store_deal(deal_source, entries);
+ }
+ );
+ })(deal_source, url);
+ }
+ }
+
+ function store_deal(deal_source, entries)
+ {
+ var deal_titles = JSON.parse(localStorage.getItem(deal_source));
+ if (deal_titles == null) {
+ var deal_titles = [];
+ }
+
+ var current_deal_titles = [];
+ for (index in entries) {
+ var title = entries[index].title;
+ var link = entries[index].link;
+
+ // If the deal doesn't exist, update the browser icon.
+ if (deal_titles.indexOf(title) == -1) {
+ chrome.browserAction.setIcon({"path" : "images/dealios22.png"});
+ }
+
+ current_deal_titles.push(title);
+ deal_to_link[title] = link;
+ }
+ window.localStorage.setItem(deal_source, JSON.stringify(current_deal_titles));
+ };
+ </script>
+ </head>
+ <body>
+ </body>
+</html>

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,132 @@
+/*
+// Copyright (c) 2011 Frank Kohlhepp
+// https://github.com/frankkohlhepp/fancy-settings
+// License: LGPL v2.1
+*/
+.fancy {
+ text-shadow: #F5F5F5 0 1px 0;
+}
+
+#sidebar {
+ position: absolute;
+ background-color: #EDEDED;
+ background-image: linear-gradient(top, #EDEDED, #F5F5F5);
+ background-image: -webkit-gradient(
+ linear,
+ left top,
+ left 500,
+ color-stop(0, #EDEDED),
+ color-stop(1, #F5F5F5)
+ );
+ background-image: -moz-linear-gradient(
+ center top,
+ #EDEDED 0%,
+ #F5F5F5 100%
+ );
+ background-image: -o-linear-gradient(top, #EDEDED, #F5F5F5);
+ width: 219px;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ border-right: 1px solid #C2C2C2;
+ box-shadow: inset -8px 0 30px -30px black;
+}
+
+#icon {
+ position: absolute;
+ width: 30px;
+ height: 30px;
+ top: 12px;
+ left: 12px;
+}
+
+#sidebar h1 {
+ position: absolute;
+ top: 13px;
+ right: 25px;
+ font-size: 26px;
+ color: #707070;
+}
+
+#tab-container {
+ position: absolute;
+ top: 50px;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ overflow-y: auto;
+ overflow-x: hidden;
+ text-align: right;
+}
+
+#tab-container .tab {
+ height: 28px;
+ padding-right: 25px;
+ border-top: 1px solid transparent;
+ border-bottom: 1px solid transparent;
+ font-size: 12px;
+ line-height: 28px;
+ color: #808080;
+ cursor: pointer;
+}
+
+#search-container {
+ margin-top: 5px;
+ margin-bottom: 5px;
+ padding-right: 23px !important;
+ cursor: default !important;
+}
+
+#search-container input {
+ width: 130px;
+}
+
+#tab-container .tab.active, body.searching #search-container {
+ background-color: #D4D4D4;
+ border-color: #BFBFBF;
+ color: black;
+ text-shadow: #DBDBDB 0 1px 0;
+ box-shadow: inset -12px 0 30px -30px black;
+}
+
+body.searching #tab-container .tab.active {
+ background-color: transparent;
+ border-color: transparent;
+ color: #808080;
+ text-shadow: inherit;
+ box-shadow: none;
+}
+
+#content {
+ position: absolute;
+ top: 0;
+ left: 220px;
+ right: 0;
+ bottom: 0;
+ overflow: auto;
+}
+
+.tab-content {
+ display: none;
+ position: absolute;
+ width: 840px;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ padding: 20px;
+ padding-top: 15px;
+}
+
+body.searching .tab-content {
+ display: none !important;
+}
+
+body.searching #search-result-container {
+ display: block !important;
+}
+
+body.measuring .tab-content, body.measuring #search-result-container {
+ display: block !important;
+ opacity: 0;
+ overflow: hidden;
+}
@@ -0,0 +1,81 @@
+/*
+// Copyright (c) 2011 Frank Kohlhepp
+// https://github.com/frankkohlhepp/fancy-settings
+// License: LGPL v2.1
+*/
+.tab-content h2 {
+ margin: 0;
+ padding-bottom: 5px;
+ font-size: 26px;
+ color: #707070;
+ line-height: 1;
+}
+
+.setting.group {
+ border-top: 1px solid #EEEEEE;
+ margin-top: 10px;
+ padding-top: 5px;
+ padding-left: 2px;
+}
+
+.setting.group-name {
+ width: 140px;
+ padding: 0;
+ font-size: 14px;
+ font-weight: bold;
+ vertical-align: top;
+}
+
+.setting.bundle {
+ max-width: 600px;
+ margin-bottom: 5px;
+}
+
+.setting.bundle.list-box {
+ margin-bottom: 10px;
+}
+
+.setting.label.radio-buttons + .setting.container.radio-buttons {
+ margin-top: 3px;
+}
+
+.setting.label, .setting.element-label {
+ margin-right: 15px;
+ font-size: 13px;
+ font-weight: normal;
+}
+
+.setting.label.checkbox, .setting.element-label {
+ margin-left: 5px;
+ margin-right: 0;
+}
+
+.setting.label.checkbox {
+ position: relative;
+ top: 1px;
+}
+
+.setting.element.slider {
+ position: relative;
+ width: 150px;
+ top: 4px;
+}
+
+.setting.element.list-box {
+ display: block;
+ height: 100px;
+ width: 100%;
+}
+
+.setting.display.slider {
+ margin-left: 5px;
+ color: #666666;
+}
+
+#nothing-found {
+ display: none;
+ margin-top: 10px;
+ font-size: 18px;
+ font-weight: lighter;
+ color: #999999;
+}
@@ -0,0 +1,4 @@
+/*
+// Add your own style rules here, not in css/main.css
+// or css/setting.css for easy updating reasons.
+*/
Oops, something went wrong.

0 comments on commit 8f799a4

Please sign in to comment.