]> git.openstreetmap.org Git - rails.git/blob - app/views/site/edit.rhtml
b1c5555866a69b957cb9a39b224833911600ccfb
[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 and !@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     if (sc < 11) sc = 11;
43     fo.addVariable('lat',lat);
44     fo.addVariable('long',lon);
45     fo.addVariable('scale',sc);
46     fo.addVariable('token','<%= session[:token] %>');
47 <% if params['gpx'] %>    fo.addVariable('gpx','<%= params['gpx']+"/data" %>'); <% end %>
48     fo.write("map");
49   }
50
51   doSWF(<%= lat %>,<%= lon %>,<%= zoom %>);
52
53   function setPosition(lat, lon, zoom) {
54     doSWF(lat, lon, zoom);
55   }
56
57   function resizeContent() {
58     var content = $("content");
59     var rightMargin = parseInt(getStyle(content, "right"));
60     var bottomMargin = parseInt(getStyle(content, "bottom"));
61
62     content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
63     content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
64   }
65   
66   function resizeMap() {
67     var search_results_width = $("search_results").offsetWidth;
68
69     if (search_results_width > 0) {
70       search_results_width = search_results_width + 5
71     }
72
73     $("map").style.left = (search_results_width) + "px";
74     $("map").style.width = ($("content").offsetWidth - search_results_width) + "px";
75     $("map").style.height = ($("content").offsetHeight - 2) + "px";
76   }
77
78   function handleResize() {
79     if (brokenContentSize) {
80       resizeContent();
81     }
82
83     resizeMap();
84   }
85
86   window.onresize = handleResize;
87   window.onload = handleResize;
88 </script>
89 <% end %>