Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

Conflicts:
	config.json
  • Loading branch information...
commit 8f431b6d65b1386a230683424cefcec9d7cfc6cd 2 parents 5aa4b11 + 680db32
John COnnolly authored
View
16 config.json
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
{
"host": "bugswarm.net"
, "user": "jconnolly"
@@ -7,5 +8,20 @@
, "swarms": [ "2fe24b7c3132b4ebdf08054d6391f40da43779a4"
]
, "producer_name" : "faker"
+=======
+{ "host": "api.bugswarm.net"
+, "user": "jedahan"
+, "master_key": "02f1703bf735003dabf14d64297daf4aaa8a8a14"
+, "producer_key": "79ab5d326d9bcaeba4693d0955a98b483c796628"
+, "consumer_key": "580a128c2014eccc9b9a69dae9a4a3bb3d487200"
+, "swarms": [ "a88adedd607c166d04cab6680b18e669c080473f" ]
+, "producer_name" : "faker"
+, "feeds": [
+ { "name": "mpg", "max": 70 }
+ , { "name": "rpm", "max": 10000 }
+ , { "name": "change", "max": 10 }
+ , { "name": "rank", "max": 50 }
+ ]
+>>>>>>> 680db320fae34d26bdf088d05a2c07bfd9e76f13
}
View
15 src/faker.coffee
@@ -16,7 +16,6 @@ buglabs = { latitude: 40.72498216901785, longitude: -73.99708271026611 }
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 }
cars = [ { name: "Fiesta", count: 0 }, { name: "Fusion", count: 0 } ]
reqs = []
@@ -40,17 +39,10 @@ app.get '/:feed/:swarm_id', (req, res) ->
#
# Currently, it looks like
#
-# `PUT /resources/:producer_name/feeds/mpg?swarm_id=:swarm_id`
+# `{ latitude: -25.1, longitude: 40.1, mpg: 42, rpm: 2600, ... }`
#
-# `{ latitude: -25.1, longitude: 40.1, mpg: 42 }`
-#
-# If you want to push other data, make sure the feed name and data field is the same, eg:
-#
-# `PUT /resources/:producer_name/feeds/RPM?swarm_id=:swarm_id`
-#
-# `{ latitude: -25.1, longitude: 40.1, RPM: 2600 }`
-fakeData = (feed_name="mpg", swarm_id=config.swarms[Math.floor(Math.random() * config.swarms.length)]) ->
+fakeData = (feed_name="ford", swarm_id=config.swarms[Math.floor(Math.random() * config.swarms.length)]) ->
if config.swarms.indexOf(swarm_id) > -1
options =
host: config.host
@@ -68,7 +60,8 @@ fakeData = (feed_name="mpg", swarm_id=config.swarms[Math.floor(Math.random() * c
car_name: car_name
latitude: center_latitude + Math.random() * max_distance
longitude: center_longitude + Math.random() * max_distance
- feed["#{feed_name}"] = Math.floor(Math.random() * max["#{feed_name}"])
+ for feeder in config.feeds
+ feed[feeder.name] = Math.floor(Math.random() * feeder.max)
req.write JSON.stringify feed
, 5000
req.write '\n'
View
17 src/public/scripts/lepidoptera.coffee
@@ -12,7 +12,6 @@ lepidoptera = ->
mapOptions = zoom: 12, center: new google.maps.LatLng(37.770053, -122.403799) , mapTypeId: google.maps.MapTypeId.ROADMAP
mapCanvas = document.getElementById "map_canvas"
mapGoogle = new google.maps.Map mapCanvas, mapOptions
-
markers = []
# the javascript api handles message callbacks as a consumer only
@@ -44,22 +43,22 @@ lepidoptera = ->
dom_resource.toggleClass 'alive', alive
updateFeed = (resource_id, body) ->
- feed = body.feed
data = JSON.parse body.data
- console.log "updateFeed(#{resource_id},#{feed},#{JSON.stringify data})"
+ console.log "updateFeed(#{resource_id},#{JSON.stringify data})"
dom_name = $("##{resource_id} > .car_name")
dom_name.html(data.car_name) if dom_name[0]?
- # if the feed doesn't exist, add it
- dom_feed = $("##{resource_id} > .feeds > .#{feed}")
+ for feed in config.feeds
+ # if the feed doesn't exist, add it
+ dom_feed = $("##{resource_id} > .feeds > .#{feed.name}")
- if dom_feed.length is 0 and data[feed]?
- dom_feed = $("##{resource_id} > .feeds").append("<li class='feed #{feed}'><h1 class='icon_wrapper'><span class='label'>#{feed}</span></h1>:<span class='data'></span></li>")
+ if dom_feed.length is 0 and data[feed.name]?
+ dom_feed = $("##{resource_id} > .feeds").append("<li class='feed #{feed.name}'><h1 class='icon_wrapper'><span class='label'>#{feed.name}</span></h1>:<span class='data'></span></li>")
- # replace the inner html with the new mpg data
- dom_feed.find(".data").html "#{data[feed]}"
+ # replace the inner html with the new mpg data
+ dom_feed.find(".data").html "#{data[feed.name]}"
# see if we have a marker on the map for this resource
for m in markers
Please sign in to comment.
Something went wrong with that request. Please try again.