Skip to content

Commit

Permalink
Add a function to pass the current list of next venues to the client.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Salomone committed Apr 9, 2011
1 parent 01dc343 commit 124a4ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions client/lib/toppl.js
Expand Up @@ -3,6 +3,10 @@ $(document).ready(function() {
$("#current_location_name").html(venue.name);
}

now.setNextVenues = function(venues) {
$("#bar-choice-0").html(venues[0].name);
}

for(var i=0; i<5; i++) {
$("#bar-choice-" + i).click(function() {
alert($(this).attr("value") + " was clicked!");
Expand Down
5 changes: 3 additions & 2 deletions server/server.js
Expand Up @@ -48,6 +48,7 @@ everyone.now.bars = bars;
everyone.connected(function(){
console.log("Joined: " + this.now.name);
everyone.now.setCurrentLocation(currentVenue);
everyone.now.setNextVenues(nextVenues);
});


Expand Down Expand Up @@ -76,7 +77,7 @@ var currentVenue;
// temp fake result data in case I don't want to call the Yellow API
var fake_result_data = '{"summary":{"what":"bar","where":"cZ-80.524378,43.464745","latitude":"43.464745","longitude":"-80.524378","firstListing":1,"lastListing":5,"totalListings":5876,"pageCount":1176,"currentPage":1,"listingsPerPage":5},"listings":[{"parentId":"","isParent":false,"distance":"0.0","content":{"Video":{"avail":false,"inMkt":false},"Photo":{"avail":false,"inMkt":false},"Profile":{"avail":false,"inMkt":false},"DspAd":{"avail":false,"inMkt":false},"Url":{"avail":false,"inMkt":false},"Logo":{"avail":false,"inMkt":false}},"id":"532082","name":"Duke Of Wellington The","address":{"street":"33 Erb St W","city":"Waterloo","prov":"ON","pcode":"N2L1S8"},"geoCode":{"latitude":"43.464745","longitude":"-80.524378"}},{"parentId":"","isParent":false,"distance":"0.3","content":{"Video":{"avail":false,"inMkt":false},"Photo":{"avail":false,"inMkt":false},"Profile":{"avail":false,"inMkt":false},"DspAd":{"avail":false,"inMkt":false},"Url":{"avail":true,"inMkt":true},"Logo":{"avail":false,"inMkt":false}},"id":"1041135","name":"McMullans On King","address":{"street":"56 King N","city":"Waterloo","prov":"ON","pcode":"N2J2X1"},"geoCode":{"latitude":"43.467032","longitude":"-80.522958"}},{"parentId":"","isParent":false,"distance":"0.4","content":{"Video":{"avail":false,"inMkt":false},"Photo":{"avail":false,"inMkt":false},"Profile":{"avail":false,"inMkt":false},"DspAd":{"avail":false,"inMkt":false},"Url":{"avail":false,"inMkt":false},"Logo":{"avail":false,"inMkt":false}},"id":"606766","name":"Failte Irish Pub","address":{"street":"85 King N","city":"Waterloo","prov":"ON","pcode":"N2J2X3"},"geoCode":{"latitude":"43.468002","longitude":"-80.523176"}},{"parentId":"","isParent":false,"distance":"1.4","content":{"Video":{"avail":false,"inMkt":false},"Photo":{"avail":false,"inMkt":false},"Profile":{"avail":false,"inMkt":false},"DspAd":{"avail":false,"inMkt":false},"Url":{"avail":true,"inMkt":true},"Logo":{"avail":false,"inMkt":false}},"id":"1088388","name":"Morty\'s Pub","address":{"street":"272 King N","city":"Waterloo","prov":"ON","pcode":"N2J2Y9"},"geoCode":{"latitude":"43.477115","longitude":"-80.52517"}},{"parentId":"","isParent":false,"distance":"2.8","content":{"Video":{"avail":false,"inMkt":false},"Photo":{"avail":false,"inMkt":false},"Profile":{"avail":false,"inMkt":false},"DspAd":{"avail":false,"inMkt":false},"Url":{"avail":false,"inMkt":false},"Logo":{"avail":false,"inMkt":false}},"id":"649696","name":"Frankies Pub","address":{"street":"273 King W","city":"Kitchener","prov":"ON","pcode":"N2G1B1"},"geoCode":{"latitude":"43.451568","longitude":"-80.494121"}}]}';

function getLocations(currentVenue, num_results) {
function getNextVenues(currentVenue, num_results) {
var locx = currentVenue.geoCode.longitude;
var locy = currentVenue.geoCode.latitude;

Expand Down Expand Up @@ -105,6 +106,6 @@ currentVenue = {
}
};

var yellowAPIResults = getLocations(currentVenue, NUM_NEXT_VENUE_OPTIONS);
var yellowAPIResults = getNextVenues(currentVenue, NUM_NEXT_VENUE_OPTIONS);
var nextVenues = yellowAPIResults.listings;

0 comments on commit 124a4ad

Please sign in to comment.