3 <%= error_messages_for 'diary_entry' %>
5 <% form_for :diary_entry do |f| %>
8 <td class="fieldName">Subject:</td>
9 <td><%= f.text_field :title, :size => 60 %></td>
12 <td class="fieldName">Body:</td>
13 <td><%= f.text_area :body, :cols => 80 %></td>
16 <td class="fieldName">Location:</td>
18 <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 400px; display: none;"></div>
19 <span class="location">Latitude: <%= f.text_field :latitude, :size => 20, :id => "latitude" %> Longitude: <%= f.text_field :longitude, :size => 20, :id => "longitude" %></span>
20 <a href="javascript:openMap()" id="usemap">use map</a>
27 <%= submit_tag 'Save' %>
28 <%# TODO: button should say 'publish' or 'save changes' depending on new/edit state %>
34 <% if @user.home_lat.nil? or @user.home_lon.nil? %>
35 <% lon = h(params['lon'] || '-0.1') %>
36 <% lat = h(params['lat'] || '51.5') %>
37 <% zoom = h(params['zoom'] || '4') %>
39 <% lon = @user.home_lon %>
40 <% lat = @user.home_lat %>
44 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
45 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
46 <%= javascript_include_tag 'map.js' %>
48 <script type="text/javascript">
53 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
54 var zoom = <%= zoom %>;
56 var map = createMap("map");
58 setMapCenter(centre, zoom);
60 map.events.register("click", map, setLocation);
63 function setLocation( e ) {
66 var lonlat = getEventPosition(e);
68 document.getElementById('latitude').value = lonlat.lat;
69 document.getElementById('longitude').value = lonlat.lon;
72 removeMarkerFromMap(marker);
75 marker = addMarkerToMap(lonlat, null, "Diary entry location");
79 $("map").style.display = "block";
80 $("usemap").style.display = "none";