]> git.openstreetmap.org Git - rails.git/blob - app/views/user/account.rhtml
Bloomin Americans that can't spell...
[rails.git] / app / views / user / account.rhtml
1 <h2>User details</h2>
2 <%= error_messages_for 'user' %>
3 <% form_tag :controller => 'user', :action => 'account', :display_name => @user.display_name do %>
4 <table style="width : 100%">
5   <tr><td>Email</td><td><%= @user.email %></td></tr>
6   <tr><td>Mapper since</td><td><%= @user.creation_time %> (<%= time_ago_in_words(@user.creation_time) %> ago)</td></tr>
7   <tr><td>Display Name</td><td><%= text_field :user, :display_name, :value => @user.display_name %></td></tr>
8   <tr><td>Password</td><td><%= password_field('user', 'pass_crypt',{:value => '', :size => 50, :maxlength => 255}) %></td></tr>
9   <tr><td>Confirm Password</td><td><%= password_field('user', 'pass_crypt_confirmation',{:value => '', :size => 50, :maxlength => 255}) %></td></tr>
10
11   <tr><td valign="top">Description</td><td><%= text_area :user, :description, :value => @user.description, :class => "editDescription" %></td></tr>
12
13   <tr id="homerow" <% unless @user.home_lat and @user.home_lon %> class="nohome" <%end%> ><td>Your home</td><td><em class="message">You have not entered your home location.</em><span class="location">Latitude: <%= text_field :user, :home_lat, :value => @user.home_lat, :size => 20, :id => "home_lat" %> Longitude <%= text_field :user, :home_lon, :value => @user.home_lon, :size => 20, :id => "home_lon" %></span>  </td></tr>
14
15   <tr><td></td><td>
16   <p>Update home location when I click on the map? <input type="checkbox" value="1" <% unless @user.home_lat and @user.home_lon %> checked="checked" <% end %> id="updatehome" /> </p>
17   <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 300px;">
18     <% # This now just used to detect the width/height required for the popup. %>
19     <p id="highlightinfo"></p>
20   </div>
21   </td></tr>
22 </table>
23 <%= submit_tag 'Save Changes' %>
24 <% end %>
25
26 <% nearest_str = "" %>
27 <% if !@user.home_lat.nil? and !@user.home_lon.nil? %>
28   <% if !@user.nearby.empty? %>
29     <% @user.nearby.each do |nearby| %>
30     <% nearest_str += "nearest.push( { 'display_name' : '#{nearby.display_name}', 'home_lat' : #{nearby.home_lat}, 'home_lon' : #{nearby.home_lon} } );\n" %>
31     <% end %>
32   <% end %>
33 <% end %>
34 <script type="text/javascript">
35     var nearest = [], friends = [];
36     <%= nearest_str %>
37 </script>
38
39 <% if @user.home_lat.nil? or @user.home_lon.nil? %>
40   <% lon =  params['lon'] || '-0.1' %>
41   <% lat =  params['lat'] || '51.5' %>
42   <% zoom =  params['zoom'] || '4' %> 
43 <% else %>
44   <% marker = true %>
45   <% mlon = @user.home_lon %> 
46   <% mlat = @user.home_lat %>
47   <% lon =  @user.home_lon %>
48   <% lat =  @user.home_lat %>
49   <% zoom =  '12' %>
50 <% end %>
51
52 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
53 <%= javascript_include_tag 'map.js' %>
54
55 <script type="text/javascript">
56   <!--
57   var marker;
58
59   function init(){
60     var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
61     var zoom = <%= zoom %>;
62
63     <% if params['scale'] and params['scale'].length > 0 then %>
64     zoom = scaleToZoom(<%= params['scale'].to_f() %>);
65     <% end %>
66
67     var map = createMap("map");
68
69     map.setCenter(centre, zoom);
70
71     <% if marker %>
72     marker = addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)), null, "Your location");
73     <% end %>
74
75     var near_icon = OpenLayers.Marker.defaultIcon();
76     near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
77     var i = nearest.length;
78     while( i-- ) {
79       var description = 'Nearby mapper: <a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a>'
80       var nearmarker = addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(nearest[i].home_lon, nearest[i].home_lat)), near_icon.clone(), description);
81     }
82
83     map.events.register("click", map, setHome);
84   }        
85
86   function setHome( e ) { 
87     closeMapPopup();
88
89     if (document.getElementById('updatehome').checked) {
90       var merc = map.getLonLatFromViewPortPx(e.xy);
91       var lonlat = mercatorToLonLat(merc);
92
93       document.getElementById('homerow').className = '';
94       document.getElementById('home_lat').value = lonlat.lat;
95       document.getElementById('home_lon').value = lonlat.lon;
96
97       if (marker) {
98         removeMarkerFromMap(marker);
99       }
100
101       marker = addMarkerToMap(merc, null, "Your location");
102     }
103   }
104
105   window.onload = init;
106 // -->
107 </script>
108
109 <h2>Privacy</h2>
110 <% if @user.data_public? %>
111   All your edits are public.
112 <% else %>
113   Currently your edits are anonymous and people can't find out where you are located. To show what you edited and allow people to contact you through the website, click the button below. This action cannot be reversed.
114   <br /><br />
115   <% form_tag :controller => 'user', :action => 'go_public' do %>
116   <%= submit_tag 'Make all my edits public, forever' %>
117   <% end %>
118 <% end %>