Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

code cleanup and bug fixes

  • Loading branch information...
commit f0ceb689568af6f4cc551e912b057b780231358a 1 parent c7995a6
Danielle Swank authored
5 lib/firehose.coffee
View
@@ -92,4 +92,7 @@ class exports.Firehose extends EventEmitter
@response.socket.end()
@emit('error', err)
- request.end(qs.stringify(body))
+ request.end(qs.stringify(body))
+
+ kill: ->
+ @response.socket.end()
6 lib/handlers.coffee
View
@@ -61,4 +61,8 @@ exports.connection = (socket) ->
socket.on 'search', (query) ->
console.log query
- firehose.request(query)
+ firehose.request(query) if query?.track?.replace(/^\s+|\s+$/)
+
+ socket.on 'disconnect', ->
+ console.log 'dying...'
+ firehose.kill()
8 public/css/styles.css
View
@@ -131,8 +131,6 @@ input[type="text"] {
.button:hover { background-color: #007d9a; color: #fff; }
.button:active { top: 1px; }
-#search_box .inactive .search_item { background: #aaa; }
-#search_box .inactive .remove { background: #999; }
#search_box .remove, #search_box .remove:visited {
color: #FFF;
@@ -154,5 +152,7 @@ input[type="text"] {
font-weight: bold;
}
.search_item:hover { background-color: #007d9a; }
-.user { background-image: url(/images/user.png); background-position-y: 9px;}
-.flag { background-image: url(/images/flag.png); background-position-y: 5px;}
+#search_box .search_item.user { background-image: url(/images/user.png); background-position-y: 9px;}
+#search_box .search_item.flag { background-image: url(/images/flag.png); background-position-y: 5px;}
+#search_box .inactive.search_item { background: #aaa; }
+#search_box .inactive .remove { background: #999; }
9 public/scripts/main.js
View
@@ -37,7 +37,7 @@
lon1 = east_deg;
lon2 = west_deg;
}
- return [lat1, lat2, lon1, lon2];
+ return [lat1, lon1, lat2, lon2];
};
parse_message = function(message) {
return message = message.replace(/\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi, '<a href="$&">$&</a>').replace(/(^|\s)(@([a-z0-9_]+))/gi, '$1<a href="https://twitter.com/$3">$2</a>').replace(/(^|\s)(#([a-z0-9_]+))/gi, function($0, $1, $2, $3) {
@@ -86,13 +86,16 @@
}
};
add_tag = function(text) {
- var $tag, lat, lng, tag, tag_el, _ref;
+ var $tag, bounding_box, lat, lng, tag, tag_el, _ref;
tag = {};
tag.text = text;
if (/^(\+|\-)?(\d+(\.\d+)?)(?:,)(\+|\-)?(\d+(\.\d+)?)$/.exec(text)) {
tag.type = 'flag';
_ref = tag.text.split(','), lat = _ref[0], lng = _ref[1];
- location[text] = get_bounding_box(lat, lng, 25);
+ console.log(lat, lng);
+ bounding_box = get_bounding_box(lat, lng, 25);
+ console.log(bounding_box);
+ location[text] = bounding_box;
} else {
tag.type = /^@[A-Z0-9.-]+/i.exec(text) ? 'user' : 'tag';
track.push(text);
16 src/scripts/main.coffee
View
@@ -48,7 +48,7 @@ get_bounding_box = (lat_deg, lon_deg, distance_miles) ->
lon1 = east_deg
lon2 = west_deg
- return [lat1, lat2, lon1, lon2]
+ return [lat1, lon1, lat2, lon2]
parse_message = (message) ->
message = message.replace(/\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi, '<a href="$&">$&</a>')
@@ -67,19 +67,11 @@ $ ->
socket = io.connect()
- socket.on 'connect', ->
- console.log 'connect'
-
socket.on 'tweet', (tweet) ->
- console.log tweet
$tweets.prepend(tweet_template(tweet))
$tweets.filter(':gt(139)').remove() if $tweets.length >= 140
- socket.on 'error', (err) ->
- console.error err
-
socket.on 'screen_name', (screen_name) ->
- console.log screen_name
$('#sign_in').hide(100)
$('#search, #see_tweets').show(100)
$('#screen_name').text(screen_name)
@@ -92,7 +84,6 @@ $ ->
locations_all = _.reduce locations, (locations_all, location) ->
return locations_all.concat(location)
, []
- console.log locations_all
return if locations_all.length then locations_all else ''
add_tag = (text) ->
@@ -102,7 +93,8 @@ $ ->
if (/^(\+|\-)?(\d+(\.\d+)?)(?:,)(\+|\-)?(\d+(\.\d+)?)$/.exec(text))
tag.type = 'flag'
[lat, lng] = tag.text.split(',')
- location[text] = get_bounding_box(lat, lng, 25)
+ bounding_box = get_bounding_box(lat, lng, 25)
+ location[text] = bounding_box
else
tag.type = if /^@[A-Z0-9.-]+/i.exec(text) then 'user' else 'tag'
track.push(text)
@@ -114,12 +106,10 @@ $ ->
$tag = $(tag_el)
$tag.find('.remove').bind 'click', (e) ->
- console.log 'remove'
remove_tag(text, false)
socket.emit('search', track: track.join(' '), location: build_locations(location))
$tag.find('.toggle').bind 'click', (e) ->
- console.log 'toggle'
$tag.toggleClass('inactive')
remove_tag(text, true)
socket.emit('search', track: track.join(' '), location: build_locations(location))
Please sign in to comment.
Something went wrong with that request. Please try again.