]> git.openstreetmap.org Git - rails.git/blob - app/views/site/edit.rhtml
Disable OSM export when the area is too large.
[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 <% 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 <% session[:token] = @user.tokens.create.token unless session[:token] %>
25
26 <% if params['mlon'] and params['mlat'] %>
27 <% lon =  h(params['mlon']) %>
28 <% lat =  h(params['mlat'])  %>
29 <% zoom =  h(params['zoom'] || '14') %>
30 <% elsif @user and params['lon'].nil? and params['lat'].nil? and params['gpx'].nil? %> 
31 <% lon =  @user.home_lon %>
32 <% lat =  @user.home_lat %>
33 <% zoom = '14' %>
34 <% elsif params['gpx'].nil? %>
35 <% lon =  h(params['lon'] || '-0.1') %>
36 <% lat =  h(params['lat'] || '51.5') %>
37 <% zoom =  h(params['zoom'] || '14') %>
38 <% else %>
39 <% lon = nil %>
40 <% lat = nil %>
41 <% zoom = '14' %>
42 <% end %>
43
44 <div id="map">You need a Flash player to use Potlatch, the
45     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>.
46
47     <a href="http://wiki.openstreetmap.org/index.php/Editing">Several other options</a> are also available
48     for editing OpenStreetMap.
49 </div>
50 <%= javascript_include_tag 'swfobject.js' %>
51 <script type="text/javascript" defer="defer">
52   var brokenContentSize = $("content").offsetWidth == 0;
53   var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "100%", "100%", "6", "#FFFFFF");
54   // 700,600 for fixed size, 100%,100% for resizable
55   var changesaved=true;
56   var winie=false; if (document.all && window.print) { winie=true; }
57   
58   window.onbeforeunload=function() {
59         if (!changesaved && !winie) {
60             return "You have unsaved changes. (To save in Potlatch, you should deselect the current way or point.)";
61         }
62   }
63
64   function doSWF(lat,lon,sc) {
65     if (sc < 11) sc = 11;
66     fo.addVariable('scale',sc);
67     fo.addVariable('token','<%= session[:token] %>');
68     if (lat) { fo.addVariable('lat',lat); }
69     if (lon) { fo.addVariable('long',lon); }
70     <% if params['gpx'] %>
71     fo.addVariable('gpx','<%= h(params['gpx']) + "/data.xml" %>');
72     <% end %>
73     fo.write("map");
74   }
75
76   doSWF(<%= lat || 'null' %>,<%= lon || 'null' %>,<%= zoom %>);
77
78   function setPosition(lat, lon, zoom) {
79     doSWF(lat, lon, zoom);
80   }
81
82   function resizeContent() {
83     var content = $("content");
84     var rightMargin = parseInt(getStyle(content, "right"));
85     var bottomMargin = parseInt(getStyle(content, "bottom"));
86
87     content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
88     content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
89   }
90   
91   function resizeMap() {
92     var sidebar_width = $("sidebar").offsetWidth;
93
94     if (sidebar_width > 0) {
95       sidebar_width = sidebar_width + 5
96     }
97
98     $("map").style.left = (sidebar_width) + "px";
99     $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
100     $("map").style.height = ($("content").offsetHeight - 2) + "px";
101   }
102
103   function handleResize() {
104     if (brokenContentSize) {
105       resizeContent();
106     }
107
108     resizeMap();
109   }
110   
111   handleResize();
112
113   window.onload = handleResize;
114   window.onresize = handleResize;
115 </script>
116 <% end %>