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