]> git.openstreetmap.org Git - rails.git/blob - app/views/site/edit.rhtml
Add keyboard shortcuts to the slippy map.
[rails.git] / app / views / site / edit.rhtml
1 <% if API_STATUS == :offline %>
2 <p>The OpenStreetMap database is currently offline while
3    essential database maintenance work is carried out.
4 </p>
5 <% elsif API_STATUS == :readonly %>
6 <p>The OpenStreetMap database is currently in read-only mode while
7    essential database maintenance work is carried out.
8 </p>
9 <% elsif !@user.data_public? %>
10 <p>You haven't set your edits to be public.</p>
11 <p>You can't use the online editor unless you do so. You can set your edits as public from your 
12 <%= link_to 'user page', {:controller => 'user', :action => 'account', :display_name => @user.display_name}%>.</p>
13 <p>(<a href="http://wiki.openstreetmap.org/index.php/Disabling_anonymous_edits">Find out why this is the case.</a>)</p>
14 <% else %>
15 <% content_for :greeting do %>
16 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
17 <%= link_to_function 'home', "setPosition(#{@user.home_lat}, #{@user.home_lon}, 10)" %> |
18 <% end %>
19 <% end %>
20
21 <%= render :partial => 'sidebar', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
22 <%= render :partial => 'search' %>
23
24 <% session[:token] = @user.tokens.create.token unless session[:token] %>
25
26 <% if params['mlon'] and params['mlat'] %>
27 <% lon =  params['mlon'] %>
28 <% lat =  params['mlat']  %>
29 <% zoom =  params['zoom'] || '12' %>
30 <% elsif @user and params['lon'].nil? and params['lat'].nil? %> 
31 <% lon =  @user.home_lon %>
32 <% lat =  @user.home_lat %>
33 <% zoom = '12' %>
34 <%else%>
35 <% lon =  params['lon'] || '-0.1' %>
36 <% lat =  params['lat'] || '51.5' %>
37 <% zoom =  params['zoom'] || '12' %>
38 <% end %>
39
40 <div id="map">You need a Flash player to use Potlatch, the
41     OpenStreetMap Flash editor. You can <a href="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">download Flash Player from Adobe.com</a>.
42
43     <a href="http://wiki.openstreetmap.org/index.php/Editing">Several other options</a> are also available
44     for editing OpenStreetMap.
45 </div>
46 <script type="text/javascript" src="/javascripts/swfobject.js"></script>
47 <script type="text/javascript">
48   var brokenContentSize = $("content").offsetWidth == 0;
49   var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "700", "600", "6", "#FFFFFF");
50
51   function doSWF(lat,lon,sc) {
52     if (sc < 11) sc = 11;
53     fo.addVariable('lat',lat);
54     fo.addVariable('long',lon);
55     fo.addVariable('scale',sc);
56     fo.addVariable('token','<%= session[:token] %>');
57 <% if params['gpx'] %>    fo.addVariable('gpx','<%= params['gpx']+"/data" %>'); <% end %>
58     fo.write("map");
59   }
60
61   doSWF(<%= lat %>,<%= lon %>,<%= zoom %>);
62
63   function setPosition(lat, lon, zoom) {
64     doSWF(lat, lon, zoom);
65   }
66
67   function resizeContent() {
68     var content = $("content");
69     var rightMargin = parseInt(getStyle(content, "right"));
70     var bottomMargin = parseInt(getStyle(content, "bottom"));
71
72     content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
73     content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
74   }
75   
76   function resizeMap() {
77     var sidebar_width = $("sidebar").offsetWidth;
78
79     if (sidebar_width > 0) {
80       sidebar_width = sidebar_width + 5
81     }
82
83     $("map").style.left = (sidebar_width) + "px";
84     $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
85     $("map").style.height = ($("content").offsetHeight - 2) + "px";
86   }
87
88   function handleResize() {
89     if (brokenContentSize) {
90       resizeContent();
91     }
92
93     resizeMap();
94   }
95
96   window.onresize = handleResize;
97   window.onload = handleResize;
98
99 </script>
100 <% end %>