]> git.openstreetmap.org Git - rails.git/blob - app/views/site/edit.rhtml
Check for wrapped timeout errors properly.
[rails.git] / app / views / site / edit.rhtml
1 <% if OSM_STATUS == :database_offline or OSM_STATUS == :api_offline %>
2 <p>The OpenStreetMap database is currently offline while
3    essential database maintenance work is carried out.
4 </p>
5 <% elsif OSM_STATUS == :database_readonly or OSM_STATUS == :api_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 no longer edit the map 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, :anchor => 'public'}%>.</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 <%
25 session[:token] = @user.tokens.create.token unless session[:token]
26
27 # Decide on a lat lon to initialise potlatch with. Various ways of doing this
28 if params['lon'] and params['lat']
29         lon =  h(params['lon']) 
30         lat =  h(params['lat']) 
31         zoom =  h(params['zoom'])
32
33 elsif params['mlon'] and params['mlat'] 
34         lon =  h(params['mlon']) 
35         lat =  h(params['mlat']) 
36         zoom =  h(params['zoom'])
37         
38 elsif params['gpx']
39         # The user may pass a gpx and zoom
40         if params['zoom']
41            zoom = h(params['zoom'])
42         end
43         #use gpx id to locate (dealt with below)
44         
45 elsif cookies.key?("_osm_location")
46         lon,lat,zoom,layers = cookies["_osm_location"].split("|")
47         
48 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? 
49         lon =  @user.home_lon
50         lat =  @user.home_lat
51
52 else
53         #catch all.  Do nothing.  lat=nil, lon=nil
54         #Currently this results in potlatch starting up at 0,0 (Atlantic ocean).
55 end
56
57 zoom='14' if zoom.nil?
58 %>
59
60 <div id="map">
61         You need a Flash player to use Potlatch, the
62     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>.
63
64     <a href="http://wiki.openstreetmap.org/index.php/Editing">Several other options</a> are also available
65     for editing OpenStreetMap.
66 </div>
67
68 <%= javascript_include_tag 'swfobject.js' %>
69 <script type="text/javascript" defer="defer">
70   var brokenContentSize = $("content").offsetWidth == 0;
71   var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "100%", "100%", "6", "#FFFFFF");
72   // 700,600 for fixed size, 100%,100% for resizable
73   var changesaved=true;
74   var winie=false; if (document.all && window.print) { winie=true; }
75   
76   window.onbeforeunload=function() {
77         if (!changesaved && !winie) {
78             return "You have unsaved changes. (To save in Potlatch, you should deselect the current way or point.)";
79         }
80   }
81
82   function markChanged(a) { changesaved=a; }
83
84   function doSWF(lat,lon,sc) {
85     if (sc < 11) sc = 11;
86     fo.addVariable('scale',sc);
87     fo.addVariable('token','<%= session[:token] %>');
88     if (lat) { fo.addVariable('lat',lat); }
89     if (lon) { fo.addVariable('long',lon); }
90     if (zoom) { fo.addVariable('zoom',zoom); }
91     <% if params['gpx']  %>fo.addVariable('gpx' ,'<%= h(params['gpx'] ) %>');<% end %>
92     <% if params['way']  %>fo.addVariable('way' ,'<%= h(params['way'] ) %>');<% end %>
93     <% if params['node'] %>fo.addVariable('node','<%= h(params['node']) %>');<% end %>
94     fo.write("map");
95   }
96
97   doSWF(<%= lat || 'null' %>,<%= lon || 'null' %>,<%= zoom %>);
98
99   function setPosition(lat, lon, zoom) {
100     doSWF(lat, lon, zoom);
101   }
102
103   function resizeContent() {
104     var content = $("content");
105     var rightMargin = parseInt(getStyle(content, "right"));
106     var bottomMargin = parseInt(getStyle(content, "bottom"));
107
108     content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
109     content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
110   }
111   
112   function resizeMap() {
113     var sidebar_width = $("sidebar").offsetWidth;
114
115     if (sidebar_width > 0) {
116       sidebar_width = sidebar_width + 5
117     }
118
119     $("map").style.left = (sidebar_width) + "px";
120     $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
121     $("map").style.height = ($("content").offsetHeight - 2) + "px";
122   }
123
124   function handleResize() {
125     if (brokenContentSize) {
126       resizeContent();
127     }
128
129     resizeMap();
130   }
131
132   function maximiseMap() {
133     $("left").style.display = "none";
134     $("greeting").style.display = "none";
135     $("tabnav").style.display = "none";
136
137     $("content").style.top = "10px";
138     $("content").style.left = "10px";
139
140     handleResize();
141   }
142   
143   function minimiseMap() {
144     $("left").style.display = "";
145     $("greeting").style.display = "";
146     $("tabnav").style.display = "";
147
148     $("content").style.top = "35px";
149     $("content").style.left = "192px";
150
151     handleResize();
152   }
153
154   handleResize();
155
156   window.onload = handleResize;
157   window.onresize = handleResize;
158 </script>
159 <% end %>