-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generated bobby.js through compiled coffeescript
- Loading branch information
Showing
5 changed files
with
180 additions
and
169 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,168 +1,180 @@ | ||
var map; | ||
var location_cache = {}; | ||
function load() { | ||
var latlng = new google.maps.LatLng(37.541, 127.066); | ||
var myOptions = { | ||
zoom: 16, | ||
center: latlng, | ||
mapTypeId: google.maps.MapTypeId.ROADMAP | ||
}; | ||
map = new google.maps.Map(document.getElementById("map"), myOptions); | ||
} | ||
|
||
var cache = {}; | ||
var NotiBar = { | ||
types: [ 'error', 'success' ], | ||
hideAllMessages: function () { | ||
var messagesHeights = new Array(); | ||
for (i=0; i< this.types.length; i++) { | ||
messagesHeights[i] = $('.' + this.types[i]).outerHeight(); | ||
$('.' + this.types[i]).css('top', -messagesHeights[i]); | ||
(function() { | ||
var Bobby, NotiBar, cache, location_cache; | ||
location_cache = {}; | ||
cache = {}; | ||
NotiBar = { | ||
types: ["error", "success"], | ||
hideAllMessages: function() { | ||
var i, messagesHeights, _results; | ||
messagesHeights = new Array(); | ||
i = 0; | ||
_results = []; | ||
while (i < this.types.length) { | ||
messagesHeights[i] = $("." + this.types[i]).outerHeight(); | ||
$("." + this.types[i]).css("top", -messagesHeights[i]); | ||
_results.push(i++); | ||
} | ||
return _results; | ||
}, | ||
showMessage: function (type, msg) { | ||
showMessage: function(type, msg) { | ||
this.hideAllMessages(); | ||
if (msg) $('.'+type).find('h3').html(msg); | ||
$('.'+type).animate({top:"0"}, 500).delay(1000).fadeOut(); | ||
if (msg) { | ||
$("." + type).find("h3").html(msg); | ||
} | ||
return $("." + type).animate({ | ||
top: "0" | ||
}, 500).delay(1000).fadeOut(); | ||
} | ||
}; | ||
|
||
var Bobby = { | ||
get_venue: function (id) { | ||
return cache["venue:"+id] || $.getJSON('/dashboard/venue/' + id, function (resp) { | ||
result = resp; | ||
cache["venue:"+id] = resp; | ||
}); | ||
}, | ||
update: function () { | ||
$.when($.getJSON('/dashboard/updater')).then(function (resp) { | ||
NotiBar.showMessage('success', "새로운 체크인정보를 업데이트하였습니다"); | ||
}) | ||
} | ||
}; | ||
|
||
$(function () { | ||
$("#Updater img").rotate({ bind: { | ||
click: function() { | ||
$(this).rotate({ angle:0,animateTo:360,easing: $.easing.easeInOutExpo }) | ||
}; | ||
Bobby = { | ||
get_venue: function(id) { | ||
return cache["venue:" + id] || $.getJSON("/dashboard/venue/" + id, function(resp) { | ||
var result; | ||
result = resp; | ||
return cache["venue:" + id] = resp; | ||
}); | ||
}, | ||
update: function() { | ||
return $.when($.getJSON("/dashboard/updater")).then(function(resp) { | ||
return NotiBar.showMessage("success", "새로운 체크인정보를 업데이트하였습니다"); | ||
}); | ||
} | ||
}}); | ||
|
||
$('#Updater').click(function () { | ||
Bobby.update(); | ||
}); | ||
|
||
$('#mylocation').click(function () { | ||
if (navigator.geolocation) { | ||
navigator.geolocation.getCurrentPosition(function (pos) { | ||
|
||
NotiBar.showMessage("success", "I Found You!"); | ||
|
||
var loc = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude); | ||
var marker = new google.maps.Marker({ | ||
position: loc, | ||
}; | ||
$(document).ready(function() { | ||
var latlng, map, myOptions, onNewEvent, s; | ||
latlng = new google.maps.LatLng(37.541, 127.066); | ||
myOptions = { | ||
zoom: 16, | ||
center: latlng, | ||
mapTypeId: google.maps.MapTypeId.ROADMAP | ||
}; | ||
map = new google.maps.Map(document.getElementById("map"), myOptions); | ||
$("#Updater img").rotate({ | ||
bind: { | ||
click: function() { | ||
return $(this).rotate({ | ||
angle: 0, | ||
animateTo: 360, | ||
easing: $.easing.easeInOutExpo | ||
}); | ||
} | ||
} | ||
}); | ||
$("#Updater").click(function() { | ||
return Bobby.update(); | ||
}); | ||
$("#mylocation").click(function() { | ||
if (navigator.geolocation) { | ||
return navigator.geolocation.getCurrentPosition((function(pos) { | ||
var loc, marker; | ||
NotiBar.showMessage("success", "I Found You!"); | ||
loc = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude); | ||
marker = new google.maps.Marker({ | ||
position: loc, | ||
map: map, | ||
icon: "/static/images/person.png", | ||
title: "You're Here!" | ||
}); | ||
return map.setCenter(loc); | ||
}), function() { | ||
return NotiBar.showMessage("error", "Could not use Geolocation API"); | ||
}); | ||
} else { | ||
return NotiBar.showMessage("error", "Could not use Geolocation API"); | ||
} | ||
}); | ||
NotiBar.hideAllMessages(); | ||
$(".message").click(function() { | ||
return $(this).animate({ | ||
top: -$(this).outerHeight() | ||
}, 500); | ||
}); | ||
onNewEvent = function(e) { | ||
var date, location, marker, show_status; | ||
try { | ||
location = new google.maps.LatLng(e.lat, e.lng); | ||
if (location_cache[e.id]) { | ||
location_cache[e.id].push(e); | ||
return; | ||
} else { | ||
location_cache[e.id] = new Array(); | ||
location_cache[e.id].push(e); | ||
} | ||
marker = new google.maps.Marker({ | ||
position: location, | ||
map: map, | ||
icon: "/static/images/person.png", | ||
title: "You're Here!" | ||
animation: google.maps.Animation.DROP, | ||
icon: e.icon, | ||
title: e.name | ||
}); | ||
date = new Date(e.created_at * 1000); | ||
show_status = function() { | ||
var recent_marker; | ||
$("#Photos > img").remove(); | ||
$.when(Bobby.get_venue(e.id)).then(function(res) { | ||
$("#location").html($("<a/>").attr({ | ||
href: res.foursquareUrl, | ||
target: "_blank" | ||
}).html(e.name + " (" + res.beenHere + ")")); | ||
return $(res.photos).each(function(id, data) { | ||
var thumbnail; | ||
thumbnail = data.sizes.items[2]; | ||
if (!thumbnail) { | ||
return; | ||
} | ||
return $("<img>").attr({ | ||
src: thumbnail.url, | ||
width: thumbnail.width, | ||
height: thumbnail.height, | ||
rel: "facebox" | ||
}).click(function() { | ||
return $.facebox({ | ||
image: data.sizes.items[0].url | ||
}, "album"); | ||
}).appendTo($("#Photos")); | ||
}); | ||
}); | ||
$("#location").html(e.name); | ||
$("#VisitedAt").html(date.toDateString() + " " + date.toTimeString()); | ||
$("#People").html("w/ " + e.people); | ||
twttr.anywhere(function(T) { | ||
return T("#People").hovercards(); | ||
}); | ||
$("#result").show(); | ||
if (recent_marker) { | ||
recent_marker.setAnimation(null); | ||
} | ||
recent_marker = marker; | ||
if (marker.getAnimation() != null) { | ||
marker.setAnimation(null); | ||
} else { | ||
marker.setAnimation(google.maps.Animation.BOUNCE); | ||
} | ||
return map.setCenter(location); | ||
}; | ||
google.maps.event.addListener(marker, "click", function() { | ||
return show_status(); | ||
}); | ||
map.setCenter(loc); | ||
|
||
}, function () { | ||
NotiBar.showMessage("error", "Could not use Geolocation API"); | ||
return $("#list").append($("<li/>").html(e.name).click(function() { | ||
return show_status(); | ||
})); | ||
} catch (e) { | ||
if (console) { | ||
return console.log(e); | ||
} | ||
} | ||
}; | ||
if (typeof DUI !== "undefined") { | ||
s = new DUI.Stream(); | ||
s.listen("application/json", function(payload) { | ||
var event; | ||
event = eval("(" + payload + ")"); | ||
return onNewEvent(event); | ||
}); | ||
return s.load("/dashboard/mxhrpoll"); | ||
} else { | ||
NotiBar.showMessage('error', "Could not use Geolocation API"); | ||
$.ev.handlers.message = onNewEvent; | ||
return $.ev.loop("/dashboard/poll?client_id=" + Math.random()); | ||
} | ||
}); | ||
|
||
NotiBar.hideAllMessages(); | ||
|
||
$('.message').click(function(){ | ||
$(this).animate({top: -$(this).outerHeight()}, 500); | ||
}); | ||
|
||
var recent_marker; | ||
var onNewEvent = function (e) { | ||
try { | ||
var location = new google.maps.LatLng(e.lat, e.lng); | ||
if (location_cache[e.id]) { | ||
location_cache[e.id].push(e); | ||
return; | ||
} else { | ||
location_cache[e.id] = new Array(); | ||
location_cache[e.id].push(e); | ||
} | ||
|
||
var marker = new google.maps.Marker({ | ||
position: location, | ||
map: map, | ||
animation: google.maps.Animation.DROP, | ||
icon: e.icon, | ||
title: e.name | ||
}); | ||
|
||
var date = new Date(e.created_at * 1000); | ||
|
||
var show_status = function () { | ||
$('#Photos > img').remove(); | ||
|
||
$.when(Bobby.get_venue(e.id)).then(function (res) { | ||
$('#location').html($('<a/>').attr({ href: res.foursquareUrl, target: "_blank" }).html(e.name + " (" + res.beenHere + ")" )); | ||
$(res.photos).each(function (id, data) { | ||
var thumbnail = data.sizes.items[2]; | ||
if (!thumbnail) return; | ||
|
||
$('<img>').attr({ src: thumbnail.url, width: thumbnail.width, height: thumbnail.height, rel: 'facebox' }) | ||
.click(function() { | ||
$.facebox({ image: data.sizes.items[0].url }, 'album'); | ||
}) | ||
.appendTo($('#Photos')); | ||
}); | ||
}); | ||
|
||
$('#location').html(e.name); | ||
$('#VisitedAt').html(date.toDateString() + " " + date.toTimeString()); | ||
$('#People').html("w/ " + e.people); | ||
twttr.anywhere(function (T) { | ||
T('#People').hovercards(); | ||
}); | ||
|
||
$('#result').show(); | ||
if (recent_marker) { | ||
recent_marker.setAnimation(null); | ||
} | ||
recent_marker = marker; | ||
if (marker.getAnimation() != null) { | ||
marker.setAnimation(null); | ||
} else { | ||
marker.setAnimation(google.maps.Animation.BOUNCE); | ||
} | ||
map.setCenter(location); | ||
}; | ||
|
||
google.maps.event.addListener(marker, 'click', function () { | ||
show_status(); | ||
}); | ||
|
||
$('#list').append( | ||
$('<li/>').html(e.name) | ||
.click(function () { | ||
show_status(); | ||
})); | ||
|
||
} catch (e) { if (console) console.log(e) }; | ||
} | ||
|
||
if (typeof DUI != 'undefined') { | ||
var s = new DUI.Stream(); | ||
s.listen('application/json', function(payload) { | ||
var event = eval('(' + payload + ')'); | ||
onNewEvent(event); | ||
}); | ||
s.load('/dashboard/mxhrpoll'); | ||
} else { | ||
$.ev.handlers.message = onNewEvent; | ||
$.ev.loop('/dashboard/poll?client_id=' + Math.random()); | ||
} | ||
}); | ||
|
||
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters