Permalink
Browse files

Merge branch 'master' of github.com:buglabs/Lepidoptera into techcrunch

  • Loading branch information...
2 parents a7f5da9 + d5adeb7 commit 5aa4b11fa0d3780269394af9a2f3a61aca4abaae John COnnolly committed Sep 9, 2011
Showing with 23 additions and 26 deletions.
  1. +5 −5 src/faker.coffee
  2. +10 −10 src/public/scripts/lepidoptera.coffee
  3. +4 −0 src/public/stylesheets/screen.css
  4. +4 −11 views/map.jade
View
@@ -13,7 +13,7 @@ config = JSON.parse require('fs').readFileSync './config.json', 'utf8'
# center latitude and longitude, max distance, and max mpg
buglabs = { latitude: 40.72498216901785, longitude: -73.99708271026611 }
-max_distance = .25
+max_distance = .01
center_latitude = (buglabs.latitude - max_distance / 2)
center_longitude = (buglabs.longitude - max_distance / 2)
max = { mpg: 70, rpm: 10000, change: 10, rank: 50 }
@@ -74,16 +74,16 @@ fakeData = (feed_name="mpg", swarm_id=config.swarms[Math.floor(Math.random() * c
req.write '\n'
reqs.push req
-process.on 'SIGTERM', () ->
+process.on 'SIGTERM', ->
process.exit 1
-process.on 'SIGINT', () ->
+process.on 'SIGINT', ->
process.exit 1
-process.on 'exit', () ->
+process.on 'exit', ->
console.log 'sending presence unavailable'
for req in reqs
- req.write JSON.stringify {presence: {type:"unavailable"}}
+ req.end
fakeData()
app.listen 33
@@ -16,33 +16,33 @@ lepidoptera = ->
markers = []
# the javascript api handles message callbacks as a consumer only
- SWARM.join apikey: "#{config.consumer_key}", swarms: config.swarms, callback: (message) ->
- from = message.presence?.from or message.message?.from
+ SWARM.join apikey: "#{config.consumer_key}", swarms: config.swarms, callback: (stanza) ->
+ from = stanza.presence?.from or stanza.message?.from
resource_id = from?.split('/')[1]
if resource_id?.indexOf('web') is -1
if resource_id?.indexOf('browser') is -1
# for _messages_, update the readout
- if message.message?.body?
+ if stanza.message?.body?
try
- updateFeed resource_id, message.message.body
+ updateFeed resource_id, stanza.message.body
catch err
- console.error "#{message.message.body}"
+ console.error "#{stanza.message.body}"
# for _presence_, determine if a resource just joined or just left
- if message.presence?.type?
- updatePresence resource_id, message.presence.type is 'available'
+ if stanza.presence?.type?
+ updatePresence resource_id, stanza.presence.type is 'available'
updatePresence = (resource_id, alive) ->
console.log "updatePresence(#{resource_id}, #{alive})"
# if the resource doesn't exist, add it
dom_resource = $("#resources > ##{resource_id}")
- if dom_resource[0]?
- dom_resource.find("##{resource_id}").toggleClass 'alive', alive
- else if alive
+ if not dom_resource[0]?
dom_resource = $("#resources").append("<li class='resource alive' id='#{resource_id}'><h1 class='car_icon_wrapper'><span class='car_icon'>Car Icon</span></h1><span class='car_name'></span><ul class='feeds'></ul></li>")
+ dom_resource.toggleClass 'alive', alive
+
updateFeed = (resource_id, body) ->
feed = body.feed
data = JSON.parse body.data
@@ -5,6 +5,10 @@ a {
text-decoration: none;
}
+#menu li:last-child img {
+ display: none;
+}
+
.label {
text-transform:uppercase;
}
View
@@ -22,17 +22,10 @@ html
#header
img#logo(src="images/logo.png", alt="logo")
ul#menu
- li
- a(href="#") HOW IT WORKS
- img#divider(src="images/divider.png", alt="divider")
- li
- a(href="#") DOCUMENTATION
- img#divider(src="images/divider.png", alt="divider")
- li
- a(href="#") BLOG
- img#divider(src="images/divider.png", alt="divider")
- li
- a(href="#") SUPPORT
+ for link, i in ["HOW IT WORKS", "DOCUMENTATION", "BLOG", "SUPPORT"]
+ li
+ a(href="#") #{link}
+ img.divider(src="images/divider.png", alt="|")
#content
h1#title Fuel Efficiency Challenge!
#map_canvas

0 comments on commit 5aa4b11

Please sign in to comment.