Optimize
This commit is contained in:
parent
b37c237d67
commit
6b78540653
|
@ -16,19 +16,10 @@
|
||||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||||
};
|
};
|
||||||
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
||||||
|
|
||||||
var redMarker = '/images/markers/red.png';
|
var redMarker = '/images/markers/red.png';
|
||||||
var greenMarker = '/images/markers/green.png';
|
var greenMarker = '/images/markers/green.png';
|
||||||
<% @hydrants.each do |hydrant| %>
|
var openInfoWindow;
|
||||||
<% if user = hydrant.user %>
|
var formString = '\
|
||||||
<% require 'digest/md5' %>
|
|
||||||
<% hash = Digest::MD5.hexdigest(user.email) %>
|
|
||||||
var contentString = '\
|
|
||||||
<h2>Adopted by <%= hydrant.user.name %></h2>\
|
|
||||||
<a class="button">Email a reminder to shovel</a>\
|
|
||||||
'
|
|
||||||
<% else %>
|
|
||||||
var contentString = '\
|
|
||||||
<div class="box">\
|
<div class="box">\
|
||||||
<h2>Adopt this Hydrant</h2>\
|
<h2>Adopt this Hydrant</h2>\
|
||||||
<%= form_tag do %>\
|
<%= form_tag do %>\
|
||||||
|
@ -66,21 +57,32 @@
|
||||||
<% end %>\
|
<% end %>\
|
||||||
</div>\
|
</div>\
|
||||||
';
|
';
|
||||||
|
<% @hydrants.each do |hydrant| %>
|
||||||
|
<% if user = hydrant.user %>
|
||||||
|
<% require 'digest/md5' %>
|
||||||
|
<% hash = Digest::MD5.hexdigest(user.email) %>
|
||||||
|
var contentString = '\
|
||||||
|
<h2>Adopted by <%= hydrant.user.name %></h2>\
|
||||||
|
<a class="button">Email a reminder to shovel</a>\
|
||||||
|
'
|
||||||
|
<% else %>
|
||||||
|
var contentString = formString;
|
||||||
<% end %>
|
<% end %>
|
||||||
var h<%= hydrant.id %>InfoWindow = new google.maps.InfoWindow({
|
|
||||||
content: contentString
|
|
||||||
});
|
|
||||||
var h<%= hydrant.id %>LatLng = new google.maps.LatLng(<%= hydrant.lat %>, <%= hydrant.lng %>);
|
var h<%= hydrant.id %>LatLng = new google.maps.LatLng(<%= hydrant.lat %>, <%= hydrant.lng %>);
|
||||||
var h<%= hydrant.id %>Marker = new google.maps.Marker({
|
var h<%= hydrant.id %>Marker = new google.maps.Marker({
|
||||||
position: h<%= hydrant.id %>LatLng,
|
position: h<%= hydrant.id %>LatLng,
|
||||||
map: map,
|
map: map,
|
||||||
icon: <%= hydrant.user_id ? "greenMarker" : "redMarker" %>
|
icon: <%= hydrant.user_id ? "greenMarker" : "redMarker" %>
|
||||||
});
|
});
|
||||||
|
var h<%= hydrant.id %>InfoWindow = new google.maps.InfoWindow({
|
||||||
|
content: contentString
|
||||||
|
});
|
||||||
google.maps.event.addListener(h<%= hydrant.id %>Marker, 'click', function() {
|
google.maps.event.addListener(h<%= hydrant.id %>Marker, 'click', function() {
|
||||||
<% @hydrants.each do |hydrant| %>
|
if(openInfoWindow) {
|
||||||
h<%= hydrant.id %>InfoWindow.close();
|
openInfoWindow.close();
|
||||||
<% end %>
|
}
|
||||||
h<%= hydrant.id %>InfoWindow.open(map, h<%= hydrant.id %>Marker);
|
h<%= hydrant.id %>InfoWindow.open(map, h<%= hydrant.id %>Marker);
|
||||||
|
openInfoWindow = h<%= hydrant.id %>InfoWindow;
|
||||||
});
|
});
|
||||||
<% end %>
|
<% end %>
|
||||||
$('.box input[type="radio"]').live('click', function() {
|
$('.box input[type="radio"]').live('click', function() {
|
||||||
|
|
Loading…
Reference in New Issue