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