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">Language:</td>
17 <td><%= f.select :language, Language.find(:all).map {|l| [l.name, l.language_code]} %></td>
20 <td class="fieldName">Location:</td>
22 <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 400px; display: none;"></div>
23 <span class="location">Latitude: <%= f.text_field :latitude, :size => 20, :id => "latitude" %> Longitude: <%= f.text_field :longitude, :size => 20, :id => "longitude" %></span>
24 <a href="javascript:openMap()" id="usemap">use map</a>
31 <%= submit_tag 'Save' %>
32 <%# TODO: button should say 'publish' or 'save changes' depending on new/edit state %>
38 <% if @user.home_lat.nil? or @user.home_lon.nil? %>
39 <% lon = h(params['lon'] || '-0.1') %>
40 <% lat = h(params['lat'] || '51.5') %>
41 <% zoom = h(params['zoom'] || '4') %>
43 <% lon = @user.home_lon %>
44 <% lat = @user.home_lat %>
48 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
49 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
50 <%= javascript_include_tag 'map.js' %>
52 <script type="text/javascript">
57 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
58 var zoom = <%= zoom %>;
60 var map = createMap("map");
62 setMapCenter(centre, zoom);
64 map.events.register("click", map, setLocation);
67 function setLocation( e ) {
70 var lonlat = getEventPosition(e);
72 document.getElementById('latitude').value = lonlat.lat;
73 document.getElementById('longitude').value = lonlat.lon;
76 removeMarkerFromMap(marker);
79 marker = addMarkerToMap(lonlat, null, "Diary entry location");
83 $("map").style.display = "block";
84 $("usemap").style.display = "none";