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