]> git.openstreetmap.org Git - rails.git/blob - app/views/site/edit.rhtml
Only include the home link if the user is logged in.
[rails.git] / app / views / site / edit.rhtml
1 <% if API_READONLY %>
2 <p>The OpenStreetMap database is currently in read-only mode while
3    essential database maintenance work is carried out.
4 </p>
5 <% else %>
6 <% content_for :greeting do %>
7 <% if !@user.home_lon.nil? and !@user.home_lat.nil? %>
8 <%= link_to_function 'home', "setPosition(#{@user.home_lat}, #{@user.home_lon}, 10)" %> |
9 <% end %>
10 <% end %>
11
12 <%= render :partial => 'search', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
13
14 <% session[:token] = @user.tokens.create.token unless session[:token] %>
15
16 <% if params['mlon'] and params['mlat'] %>
17 <% lon =  params['mlon'] %>
18 <% lat =  params['mlat']  %>
19 <% zoom =  params['zoom'] || '12' %>
20 <% elsif @user and params['lon'].nil? and params['lat'].nil? %> 
21 <% lon =  @user.home_lon %>
22 <% lat =  @user.home_lat %>
23 <% zoom = '12' %>
24 <%else%>
25 <% lon =  params['lon'] || '-0.1' %>
26 <% lat =  params['lat'] || '51.5' %>
27 <% zoom =  params['zoom'] || '12' %>
28 <% end %>
29
30 <div id="map">You need a Flash player to use Potlatch, the
31     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>.
32
33     <a href="http://wiki.openstreetmap.org/index.php/Editing">Several other options</a> are also available
34     for editing OpenStreetMap.
35 </div>
36 <script type="text/javascript" src="/javascripts/swfobject.js"></script>
37 <script type="text/javascript">
38   var brokenContentSize = $("content").offsetWidth == 0;
39   var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "700", "600", "6", "#FFFFFF");
40
41   function doSWF(lat,lon,sc) {
42     fo.addVariable('lat',lat);
43     fo.addVariable('long',lon);
44     fo.addVariable('scale',sc);
45     fo.addVariable('token','<%= session[:token] %>');
46     fo.write("map");
47   }
48
49   doSWF(<%= lat %>,<%= lon %>,<%= zoom %>);
50
51   function setPosition(lat, lon, zoom) {
52     doSWF(lat, lon, zoom);
53   }
54
55   function resizeContent() {
56     var content = $("content");
57     var rightMargin = parseInt(getStyle(content, "right"));
58     var bottomMargin = parseInt(getStyle(content, "bottom"));
59
60     content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
61     content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
62   }
63   
64   function resizeMap() {
65     var search_results_width = $("search_results").offsetWidth;
66
67     if (search_results_width > 0) {
68       search_results_width = search_results_width + 5
69     }
70
71     $("map").style.left = (search_results_width) + "px";
72     $("map").style.width = ($("content").offsetWidth - search_results_width) + "px";
73     $("map").style.height = ($("content").offsetHeight - 2) + "px";
74   }
75
76   function handleResize() {
77     if (brokenContentSize) {
78       resizeContent();
79     }
80
81     resizeMap();
82   }
83
84   window.onresize = handleResize;
85   window.onload = handleResize;
86 </script>
87 <% end %>