Skip to content

Commit

Permalink
Generated bobby.js through compiled coffeescript
Browse files Browse the repository at this point in the history
  • Loading branch information
aanoaa committed Sep 6, 2011
1 parent d88ddb0 commit 58d72c4
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 169 deletions.
Binary file added static/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 9 additions & 10 deletions static/js/bobby.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
load = ->
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)

location_cache = {}
cache = {}
NotiBar =
Expand Down Expand Up @@ -35,7 +26,15 @@ Bobby =
$.when_($.getJSON("/dashboard/updater")).then (resp) ->
NotiBar.showMessage "success", "새로운 체크인정보를 업데이트하였습니다"

$ ->
$(document).ready ->
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: ->
$(this).rotate
angle: 0
Expand Down
326 changes: 169 additions & 157 deletions static/js/bobby.js
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);
2 changes: 1 addition & 1 deletion static/js/facebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<div class="popup"> \
<div class="content"> \
</div> \
<a href="#" class="close"><img src="/facebox/closelabel.png" title="close" class="close_image" /></a> \
<a href="#" class="close"><img src="/static/images/closelabel.png" title="close" class="close_image" /></a> \
</div> \
</div>'
},
Expand Down
2 changes: 1 addition & 1 deletion templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
% }
<script src="/static/js/bobby.js"></script>
</head>
<body onload="load()">
<body>
<div class="messages">
<div class="success message">
<h3>새로운 체크인정보를 업데이트했습니다.</h3>
Expand Down

0 comments on commit 58d72c4

Please sign in to comment.