]> git.openstreetmap.org Git - rails.git/blob - app/views/site/edit.rhtml
Limit Osmarender zoom to 17 levels.
[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         #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.";
75         }
76   }
77
78   function markChanged(a) { changesaved=a; }
79
80   function doSWF(lat,lon,sc) {
81     if (sc < 11) sc = 11;
82     fo.addVariable('scale',sc);
83     fo.addVariable('token','<%= session[:token] %>');
84     if (lat) { fo.addVariable('lat',lat); }
85     if (lon) { fo.addVariable('long',lon); }
86     <% if params['gpx']  %>fo.addVariable('gpx' ,'<%= h(params['gpx'] ) %>');<% end %>
87     <% if params['way']  %>fo.addVariable('way' ,'<%= h(params['way'] ) %>');<% end %>
88     <% if params['node'] %>fo.addVariable('node','<%= h(params['node']) %>');<% end %>
89     fo.write("map");
90   }
91
92   doSWF(<%= lat || 'null' %>,<%= lon || 'null' %>,<%= zoom %>);
93
94   function setPosition(lat, lon, zoom) {
95     doSWF(lat, lon, zoom);
96   }
97
98   function resizeContent() {
99     var content = $("content");
100     var rightMargin = parseInt(getStyle(content, "right"));
101     var bottomMargin = parseInt(getStyle(content, "bottom"));
102
103     content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
104     content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
105   }
106   
107   function resizeMap() {
108     var sidebar_width = $("sidebar").offsetWidth;
109
110     if (sidebar_width > 0) {
111       sidebar_width = sidebar_width + 5
112     }
113
114     $("map").style.left = (sidebar_width) + "px";
115     $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
116     $("map").style.height = ($("content").offsetHeight - 2) + "px";
117   }
118
119   function handleResize() {
120     if (brokenContentSize) {
121       resizeContent();
122     }
123
124     resizeMap();
125   }
126
127   function maximiseMap() {
128     $("left").style.display = "none";
129     $("greeting").style.display = "none";
130     $("tabnav").style.display = "none";
131
132     $("content").style.top = "10px";
133     $("content").style.left = "10px";
134
135     handleResize();
136   }
137   
138   function minimiseMap() {
139     $("left").style.display = "";
140     $("greeting").style.display = "";
141     $("tabnav").style.display = "";
142
143     $("content").style.top = "35px";
144     $("content").style.left = "192px";
145
146     handleResize();
147   }
148
149   handleResize();
150
151   window.onload = handleResize;
152   window.onresize = handleResize;
153 </script>
154 <% end %>