Permalink
Browse files

Initial check in

  • Loading branch information...
0 parents commit 78e0b5b4351bbe931ffc263a26d0aaa1ff0fa75f @mchung committed Apr 22, 2011
3 .bundle/config
@@ -0,0 +1,3 @@
+---
+BUNDLE_DISABLE_SHARED_GEMS: "1"
+BUNDLE_WITHOUT: ""
2 .gitignore
@@ -0,0 +1,2 @@
+log/*.log
+
1 .rvmrc
@@ -0,0 +1 @@
+rvm --create 1.9.2-p0@airstatus
13 Gemfile
@@ -0,0 +1,13 @@
+source :rubygems
+
+gem "sinatra", "~> 1.2"
+gem "haml", "~> 3.0"
+gem "json"
+gem "tropo-webapi-ruby"
+gem "nokogiri"
+
+group :development do
+ gem "heroku"
+ gem "shotgun", "~> 0.9"
+ gem "thin", "~> 1.2"
+end
54 Gemfile.lock
@@ -0,0 +1,54 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ configuration (1.2.0)
+ daemons (1.1.2)
+ eventmachine (0.12.10)
+ eventmachine (0.12.10-java)
+ haml (3.0.25)
+ hashie (1.0.0)
+ heroku (1.20.1)
+ launchy (~> 0.3.2)
+ rest-client (>= 1.4.0, < 1.7.0)
+ json (1.5.1)
+ json (1.5.1-java)
+ json_pure (1.5.1)
+ launchy (0.3.7)
+ configuration (>= 0.0.5)
+ rake (>= 0.8.1)
+ mime-types (1.16)
+ nokogiri (1.4.4)
+ nokogiri (1.4.4-java)
+ weakling (>= 0.0.3)
+ rack (1.2.2)
+ rake (0.8.7)
+ rest-client (1.6.1)
+ mime-types (>= 1.16)
+ shotgun (0.9)
+ rack (>= 1.0)
+ sinatra (1.2.3)
+ rack (~> 1.1)
+ tilt (>= 1.2.2, < 2.0)
+ thin (1.2.11)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
+ tilt (1.2.2)
+ tropo-webapi-ruby (0.1.10)
+ hashie (>= 0.2.0)
+ json_pure (>= 1.2.0)
+ weakling (0.0.4-java)
+
+PLATFORMS
+ java
+ ruby
+
+DEPENDENCIES
+ haml (~> 3.0)
+ heroku
+ json
+ nokogiri
+ shotgun (~> 0.9)
+ sinatra (~> 1.2)
+ thin (~> 1.2)
+ tropo-webapi-ruby
174 LICENSE
@@ -0,0 +1,174 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
3 NOTICE
@@ -0,0 +1,3 @@
+airstat.us
+
+Copyright 2011, Marc Chung, All Rights Reserved
21 README.markdown
@@ -0,0 +1,21 @@
+# airstat.us
+
+A quick project to celebrate Earth Day.
+
+airstat.us visitors can view the current status of air quality for the following areas:
+
+ * Maricopa County, http://www.cleanairmakemore.com/
+ * San Francisco, http://sparetheair.org/
+
+## Credits
+
+ * [Earth Day 2011](http://www.earthday.org/earth-day-2011)
+ * [Marc Chung](http://twitter.com/heisenthought), for development
+ * [Matt Clower](http://clowerpower.com), for the name
+ * [Jenny Poon](http://eekostudio.com), for the logo
+
+## Developers
+
+### Start the server in mode:
+
+ shotgun --server=thin --port=5000 config.ru
48 app.rb
@@ -0,0 +1,48 @@
+require "sinatra/base"
+require "open-uri"
+require "json"
+require "pp"
+require "tropo-webapi-ruby"
+
+module Burn
+ class App < Sinatra::Base
+ set :raise_errors, true
+ set :views, "views"
+ set :public, "public"
+ set :static, true
+
+ get "/" do
+ # Phx, by default.
+ redirect "/phx"
+ end
+
+ post "/tropo" do
+ Tropo::Generator.say "Hello, world"
+ end
+
+ get "/sf" do
+ response.headers["Cache-Control"] = "public, max-age=300"
+ @data = Burn::Sf.new
+ if @data.is_spare_the_air_day?
+ haml :"burn/sf/spare_the_air_day"
+ else
+ haml :"burn/sf/clean_air"
+ end
+ end
+
+ get "/phx" do
+ response.headers["Cache-Control"] = "public, max-age=300"
+ @data = Burn::Phx.new
+ if @data.is_no_burn_day?
+ haml :"burn/phx/no_burn_day" # yes, don't burn shit
+ else
+ haml :"burn/phx/clean_air" # no, but try not to burn shit anyway
+ end
+ end
+
+ get "/application.css" do
+ response["Content-Type"] = "text/css; charset=utf-8"
+ scss :style
+ end
+ end
+end
2 burn.rb
@@ -0,0 +1,2 @@
+require File.dirname(__FILE__) + "/burn/phx"
+require File.dirname(__FILE__) + "/burn/sf"
66 burn/phx.rb
@@ -0,0 +1,66 @@
+module Burn
+
+ # According to [1], there is a no-burn day advisory when either the high
+ # pollution advisory or health watch flags are set to true
+ #
+ # For further details, please examine [2]
+ #
+ # [1] http://www.cleanairmakemore.com/embed-widget-thin.html
+ # [2] http://www.cleanairmakemore.com/widget_json.cfm
+ class Phx
+
+ attr_accessor :air_quality_index,
+ :high_pollution_advisory,
+ :health_watch,
+ :allow_ohvehicles,
+ :allow_leafblowers,
+ :allow_woodburning,
+ :date
+
+ def initialize
+ data = fetch_data
+ self.air_quality_index = data["aqi"]
+ self.high_pollution_advisory = data["hpa"]
+ self.health_watch = data["hw"]
+ self.allow_ohvehicles = data["ohvehicles"]
+ self.allow_leafblowers = data["leafblowers"]
+ self.allow_woodburning = data["woodburning"]
+ self.date = Time.new.strftime("%b %d, %Y")
+ end
+
+ def is_no_burn_day?
+ self.high_pollution_advisory || self.health_watch
+ end
+
+ def fetch_data
+ json = fetch_json
+ data = JSON.parse(json)
+ data
+ end
+
+ # Fetches JSON from our third party. Also, fixes bad JSON by
+ # removing everything after "facts"
+ #
+ # Returns the follow JSON
+ def fetch_json
+ res = open("http://www.cleanairmakemore.com/widget_json.cfm").read
+
+ # Documented in views/burn/phx/data.json.
+ s = res.index("facts")
+ json = res[0, s-4] + "}"
+
+ # json = File.read("views/burn/phx/data.json")
+ json
+ end
+
+ # def fetch_json_from_cache
+ # json = $cache.get("clean_air_make_more_json")
+ # if json.nil?
+ # json = fetch_json
+ # $cache.set("clean_air_make_more_json", json, 60)
+ # end
+ # json
+ # end
+ end
+
+end
42 burn/sf.rb
@@ -0,0 +1,42 @@
+require "nokogiri"
+
+module Burn
+
+ class Sf
+
+ attr_accessor :message,
+ :offsite_link,
+ :date
+
+ def initialize
+ data = fetch_data
+ self.message = data["message"]
+ self.offsite_link = data["offsite_link"]
+ self.date = data["date"]
+ end
+
+ def is_spare_the_air_day?
+ self.message != "No Spare the Air Alert in Effect"
+ end
+
+ def fetch_data
+ fetch_html
+ end
+
+ # Fetches HTML from http://www.baaqmd.gov/
+ #
+ def fetch_html
+ res = open("http://www.baaqmd.gov/Feeds/BurnStatusIframe.aspx").read
+ # res = File.read("views/burn/sf/burnstatus_iframe.html")
+
+ html_doc = Nokogiri::HTML(res)
+ data = {}
+ data["date"] = html_doc.css("div.sta-day/div.aq12").text
+ data["message"] = html_doc.css("div.sta-day/div.aq10/a").text
+ data["offsite_link"] = html_doc.css("div.sta-day/div.aq10/a").attribute("href").text
+
+ data
+ end
+ end
+
+end
22 config.ru
@@ -0,0 +1,22 @@
+ENV["TZ"] = "America/Phoenix"
+ENV["RACK_ENV"] = "development" unless ENV["RACK_ENV"]
+
+begin
+ # Require the preresolved locked set of gems.
+ require File.expand_path('../.bundle/environment', __FILE__)
+rescue LoadError
+ # Fallback on doing the resolve at runtime.
+ require "rubygems"
+ require "bundler"
+ Bundler.setup
+end
+
+if ENV["RACK_ENV"] == "production"
+ log = File.new("log/#{ENV['RACK_ENV']}.log", "a")
+ STDOUT.reopen(log)
+ STDERR.reopen(log)
+end
+
+require File.dirname(__FILE__) + "/burn"
+require File.dirname(__FILE__) + "/app"
+run Burn::App
0 log/.gitignore
No changes.
0 public/favicon.ico
No changes.
BIN public/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 public/stylesheets/reset.css
@@ -0,0 +1,48 @@
+/* http://meyerweb.com/eric/tools/css/reset/
+ v2.0 | 20110126
+ License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed,
+figure, figcaption, footer, header, hgroup,
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ font-size: 100%;
+ font: inherit;
+ vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure,
+footer, header, hgroup, menu, nav, section {
+ display: block;
+}
+body {
+ line-height: 1;
+}
+ol, ul {
+ list-style: none;
+}
+blockquote, q {
+ quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+ content: '';
+ content: none;
+}
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
7 views/burn/phx/clean_air.haml
@@ -0,0 +1,7 @@
+%p
+ Phoenix has no clean air advisories for
+ = @data.date
+%p
+ Make a
+ %a{:href => "http://cleanairmakemore.com/commitment.php"} commitment
+ to keep it that way
8 views/burn/phx/data.json
@@ -0,0 +1,8 @@
+{
+ "aqi" : 0,
+ "woodburning" : true,
+ "leafblowers" : true,
+ "ohvehicles" : true,
+ "hpa" : false,
+ "hw" : false
+}
15 views/burn/phx/no_burn_day.haml
@@ -0,0 +1,15 @@
+%p
+ Phoenix has a
+ %span.focus No-Burn Day
+ advisory for
+ = @data.date
+%p
+ Learn more about
+ %a{:href => "http://cleanairmakemore.com/commitment.php"} No-Burn Day
+%section.tiny
+ Violators can be fined up to $250!
+ %br/
+ \..and force-fed pickled strawberries covered in vegemite.
+ %br/
+ Okay, maybe not that last part.
+%br/
25 views/burn/phx/rawdata.json
@@ -0,0 +1,25 @@
+
+{
+ "aqi" : 26,
+ "woodburning" : true,
+ "leafblowers" : true,
+ "ohvehicles" : true,
+ "hpa" : false,
+ "hw" : false,
+ "facts" : [
+ "Did you know there is an ordinance that prohibits the blowing of landscape debris into public roadways?<span style=\"font-style: italic;\">- Maricopa County Air Quality Department</span><br>",
+ "Did you know manufactured logs are prohibited from being used on No Burn Days?<span style=\"font-style: italic;\">- Maricopa County Air Quality Department</span>",
+ "Did you know fireplace restrictions include hotels and restaurants on No Burn Days?<span style=\"font-style: italic;\">- Maricopa County Air Quality Department</span>",
+ "Did you know a High Pollution Advisory or HPA means the highest concentration of pollution <span style=\"font-weight: bold;\">may exceed</span> the federal health standard?<span style=\"font-style: italic;\">- Maricopa County Air Quality Department</span>",
+ "Did you know a Health Watch or HW means the highest concentration of pollution <span style=\"font-weight: bold;\">may approach</span> the federal health standard? <br><br>",
+ "Did you know Gaylord Nelson organized the first Earth Day held on April 22, 1970? <span style=\"font-style: italic;\">- EPA</span><br>",
+ "Did you know transportation consumes 25 percent of the total energy used in the United States? <span style=\"font-style: italic;\">- EPA</span><br>",
+ "Did you know twenty million people celebrated the first Earth Day on April 22, 1970? <span style=\"font-style: italic;\">- EPA</span><br>",
+ "Did you know choosing the most fuel-efficient vehicle could prevent over 15 tons of greenhouse gas pollution over the lifetime of your vehicle? <span style=\"font-style: italic;\">- EPA</span><br>",
+ "Did you know an estimated 14 million school days each year are missed by children in the U.S. due to an asthma-related illness? <span style=\"font-style: italic;\">- EPA</span><br>",
+ "Did you know changing just five conventional bulbs to energy-efficient bulbs can save an estimated $60 per year? <span style=\"font-style: italic;\">- EPA</span><br>",
+ "Did you know twenty percent of U.S. morning traffic consists of students being driven to school? <span style=\"font-style: italic;\">- EPA</span><br>",
+ "Did you know fine particulates (or PM-2.5) are approximately 1/30th the width of the average human hair? <span style=\"font-style: italic;\">- EPA</span><br>",
+ "Did you know the gas mower spews 87 lbs of the greenhouse gas pollution and 54 lbs of other pollutants into the air every year? <span style=\"font-style: italic;\">- EPA</span><br>",
+ ]
+}
213 views/burn/phx/thin-widget.html
@@ -0,0 +1,213 @@
+<html>
+<head>
+<title>Clean Air Make More Widget</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<style type="text/css">
+ a{
+ color: #1a303c;
+ font-weight: bold;
+ }
+</style>
+<script src="/js/jquery.js" type="text/javascript"></script>
+<script type="text/javascript">
+var timeBetweenData = 1000 * 60 * 15, scrollFacts, scrollFactsTimer, curFact = 0, timeBetweenFacts = 10000;
+
+function cycleFacts() {
+ if(scrollFacts && scrollFacts.length > 0) {
+ if(curFact >= scrollFacts.length)
+ curFact = 0;
+
+ $('#fact').fadeOut('fast', function() { $(this).html(scrollFacts[curFact++]).fadeIn('slow'); });
+ scrollFactsTimer = setTimeout(cycleFacts, timeBetweenFacts);
+ }
+}
+
+function getCalendarDate() {
+ var months = new Array(12);
+ months[0] = "January";
+ months[1] = "February";
+ months[2] = "March";
+ months[3] = "April";
+ months[4] = "May";
+ months[5] = "June";
+ months[6] = "July";
+ months[7] = "August";
+ months[8] = "September";
+ months[9] = "October";
+ months[10] = "November";
+ months[11] = "December";
+ var now = new Date();
+ var monthname = months[now.getMonth()];
+ var monthday = now.getDate();
+ var year = now.getYear();
+ if(year < 2000) { year = year + 1900; }
+ var dateString = monthname +
+ ' ' +
+ monthday +
+ ', ' +
+ year;
+ return dateString;
+}
+
+function onClose(){
+ var closing = new air.Event(air.Event.CLOSING, true, true);
+ window.nativeWindow.dispatchEvent(closing);
+ if(!closing.isDefaultPrevented()){
+ window.close();
+ }
+}
+
+function onMinimize(){
+ var minimizing = new air.NativeWindowDisplayStateEvent(
+ air.NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
+ true, true,
+ window.nativeWindow.displayState,
+ air.NativeWindowDisplayState.MINIMIZED);
+ window.nativeWindow.dispatchEvent(minimizing);
+ if(!minimizing.isDefaultPrevented()){
+ nativeWindow.minimize();
+ }
+}
+
+function loadScreenData() {
+ $('#date').html(getCalendarDate());
+ $.getJSON("http://www.cleanairmakemore.com/widget_json.cfm", function(settings) {
+ scrollFacts = settings['facts'];
+ if(!settings['woodburning'])
+ $('#woodburning').attr('src', '/widget/thin/images/wood_burning_red.png');
+ if(!settings['leafblowers'])
+ $('#leafblowers').attr('src', '/widget/thin/images/leaf_blowing_red.png');
+ if(!settings['ohvehicles'])
+ $('#ohvehicles').attr('src', '/widget/thin/images/vehicles_red.png');
+
+ if(settings['hpa'] || settings['hw']) {
+ if(scrollFactsTimer)
+ clearTimeout(scrollFactsTimer);
+ $('#facts').hide();
+ $('#alert').show();
+ $('#alert #icon').attr('src', '/widget/thin/images/' + (settings['hpa'] ? 'hpa' : 'hw') + '.png');
+ }
+ else {
+ $('#alert').hide();
+ $('#facts').show();
+ if(!scrollFactsTimer) {
+ cycleFacts();
+ }
+ }
+
+ maxAQI = 100;
+ level = 1;
+ while(level * (maxAQI / 6) < settings['aqi'])
+ level++;
+ if(level > 6)
+ level = 6;
+ $('#status_level').attr('src', '/widget/thin/images/status_' + level + '.png');
+ if(level >= 3) {
+ $('#status_graphical').attr('src', '/widget/thin/images/city_high.png');
+ }
+ else if(level == 2) {
+ $('#status_graphical').attr('src', '/widget/thin/images/city_medium.png');
+ }
+ else {
+ $('#status_graphical').attr('src', '/widget/thin/images/city_low.png');
+ }
+ $('#status_text').attr('src', '/widget/thin/images/status_' + level + '_text.png');
+ });
+ setTimeout(loadScreenData, timeBetweenData);
+}
+
+$(function() {
+ loadScreenData();
+});
+</script>
+</head>
+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
+<center><table id="Table_01" width="258" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td colspan="3">
+ <img src="/widget/thin/images/widget-03.png" width="258" height="10" alt=""></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td rowspan="2" valign="top">
+ <a href="http://www.cleanairmakemore.com/" target="_blank"><img src="/widget/thin/images/widget-05.png" width="85" height="57" alt="" border="0"></a></td>
+ <td background="/widget/thin/images/date_bg.png" width="129" height="17">
+ <p style="font-family: arial; color: #477a93; font-size: 11px; text-align: right; padding: 0 10px 0 0;" id="date"></p>
+ </td>
+ <td>
+ <a href="" id="minimize"><img src="/widget/thin/images/widget-07.png" width="18" height="17" alt="" border="0"></a></td>
+ <td>
+ <a href="" id="close"><img src="/widget/thin/images/widget-08.png" width="17" height="17" alt="" border="0"></a></td>
+ <td>
+ <img src="/widget/thin/images/date_bg-09.png" width="8" height="17" alt=""></td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <img src="/widget/thin/images/widget-11.png" width="172" height="40" alt=""></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <img src="/widget/thin/images/city_low.png" width="258" height="72" alt="" id="status_graphical"></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+
+ <img src="/widget/thin/images/widget-13.png" width="258" height="24" alt=""></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <img src="/widget/thin/images/status_1.png" width="258" height="42" alt="" id="status_level"></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <img src="/widget/thin/images/status_1_text.png" width="258" height="22" alt="" id="status_text"></td>
+
+ </tr>
+ <tr>
+ <td>
+ <a href="http://www.cleanairmakemore.com/theoffenders/woodburning" target="_blank"><img id="woodburning" src="/widget/thin/images/wood_burning_green.png" width="85" height="98" alt="" border="0"></a></td>
+ <td>
+ <a href="http://www.cleanairmakemore.com/theoffenders/leaf-blowers" target="_blank"><img id="leafblowers" src="/widget/thin/images/leaf_blowing_green.png" width="86" height="98" alt="" border="0"></a></td>
+ <td>
+ <a href="http://www.cleanairmakemore.com/theoffenders/off-highway-vehicles" target="_blank"><img id="ohvehicles" src="/widget/thin/images/vehicles_green.png" width="86" height="98" alt="" border="0"></a></td>
+ </tr>
+ <tr>
+ <td colspan="3" id="facts_container">
+ <table cellpadding="0" cellspacing="0" id="facts">
+ <tr>
+ <td><img src="/widget/thin/images/fact.png" width="44" height="85" alt=""></td>
+ <td background="/widget/thin/images/facts_widget-19.png" width="214px"><p style="padding: 10px 4px 2px; color: #1a303c; font-size: 11px; font-family: arial;" id="fact"></p></td>
+ </tr>
+ </table>
+ <table cellpadding="0" cellspacing="0" id="alert" style="display: none;">
+ <tr>
+ <td>
+ <img src="/widget/thin/images/hpa.png" id="icon" width="85" height="85" alt=""></td>
+ <td background="/widget/thin/images/widget-19.png" width="172px" height="85" valign="top" id="footer">
+ <p style="padding: 10px 4px 0; color: #1a303c; font-size: 11px; font-family: arial;">Did you know a Health Watch or HW means the highest concentration of pollution may approach the federal health standard?</p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <a href="http://www.cleanairmakemore.com/" target="_blank"><img src="/widget/thin/images/footer.png" width="258" height="35" alt="" border="0"></a></td>
+ </tr>
+</table>
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try {
+var pageTracker = _gat._getTracker("UA-1421194-16");
+pageTracker._trackPageview();
+} catch(err) {}</script></center>
+</body>
+</html>
20 views/burn/sf/burnstatus_iframe.html
@@ -0,0 +1,20 @@
+
+ <div class="sta-day">
+ <div class="aq12">Thursday, 4/21</div>
+ <div class="aq10"><a target=_blank href="http://sparetheair.org/Make-a-Difference/Spare-the-Air-Every-Day/Summer.aspx">No Spare the Air Alert in Effect</a></div>
+ </div>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head id="head"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><link rel="shortcut icon" href="http://www.baaqmd.gov/favicon.ico" type="image/vnd.microsoft.icon" /><link rel="icon" type="image/vnd.microsoft.icon" href="http://www.baaqmd.gov/favicon.ico" /><meta http-equiv="cache-control" content="no-cache" /><meta http-equiv="expires" content="0" /><meta http-equiv="pragma" content="no-cache" /><link rel="stylesheet" type="text/css" href="/app_themes/burnstatus/css/feeds.css" /><title>
+
+</title></head>
+<body><form name="form1" method="post" action="/Feeds/BurnStatusIframe.aspx" id="form1">
+<div>
+<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNTgzNzQzMjc0ZGT8io1oWvAv/0CmnCTLyYHzshiZdw==" />
+</div>
+
+
+ </form></body>
+</html>
6 views/burn/sf/clean_air.haml
@@ -0,0 +1,6 @@
+%p
+ San Francisco has no clean air advisories for
+ = @data.date
+%p
+ Learn more about
+ %a{:href => "#{@data.offsite_link}"} Spare the Air
8 views/burn/sf/spare_the_air_day.haml
@@ -0,0 +1,8 @@
+%p
+ San Francisco has a
+ %span.focus Spare the Air
+ advisory for
+ = @data.date
+%p
+ Learn more about
+ %a{:href => "#{@data.offsite_link}"} Spare the Air
41 views/layout.haml
@@ -0,0 +1,41 @@
+!!! 5
+%html
+ / The source for this website is made freely available on GitHub.
+ /
+ / Check out github.com/mchung/airstatus
+ /
+ / Contributors wanted.
+ %head
+ %meta{:charset => "utf-8"}/
+ %meta{:content => "no burn day phoenix, spare the air san franciso", :name => "keywords"}/
+ %meta{:content => "AirStat.us", :name => "description"}/
+ %meta{:content => "UySEkVpFOocl8-VVEHHc3uu2TX_rkIaWE5Csu_9N2Ag", :name => "google-site-verification"}/
+ %link{:rel => "stylesheet", :href => "/stylesheets/reset.css", :type => "text/css", :media => "all"}
+ %link{:rel => "stylesheet", :href => "/application.css", :type => "text/css", :media => "all"}
+ %title AirStat.us | Earth Day 2011
+ %body
+ %section
+ %img{:src => "/logo.png"}/
+ %section#burnday
+ = yield
+
+ %section.tiny.support
+ Support for
+ %a{:href => "/sf"}San Francisco,
+ %a{:href => "/phx"}Phoenix,
+ %a{:href => "http://github.com/mchung/isitnoburnday"} [Add your city]
+
+ %section.tiny
+ Built by
+ %a{:href => "http://twitter.com/heisenthought"}
+ Marc Chung
+ for Earth Day 2011
+
+ :javascript
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ :javascript
+ try {
+ var pageTracker = _gat._getTracker("UA-10284368-2");
+ pageTracker._trackPageview();
+ } catch(err) {}
40 views/style.scss
@@ -0,0 +1,40 @@
+body {
+ background-color: #fff;
+ color: #333;
+ font-family: Arial,Verdana,sans-serif;
+ font-size: 62.5%;
+ margin: 10% 5% 0 5%;
+ text-align:center;
+}
+
+a,
+a:visited,
+a:active {
+ color:#0080ff;
+ text-decoration:underline;
+}
+a:hover {
+ text-decoration:none;
+}
+#burnday {
+ clear: both;
+ font-size: 3em;
+ margin:auto;
+
+ p {
+ margin-bottom: 25px;
+ }
+}
+.tiny {
+ display: block;
+ font-size: 8pt;
+ line-height: 12pt;
+}
+.support {
+ margin-bottom: 25px;
+}
+
+span.focus {
+ font-style: italic;
+ background-color: #ffffe0;
+}

0 comments on commit 78e0b5b

Please sign in to comment.