]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/index.rhtml
User null to indicate the the user's home location is not set.
[rails.git] / app / views / site / index.rhtml
index 1e2fa3ad10f85415e600a834ced56ce29d34de3b..5b9fd84f65ea4f376613229be7b22649c2f74b7f 100644 (file)
@@ -4,31 +4,37 @@
 <% marker = true %>
 <% mlon = params['mlon'] %> 
 <% mlat = params['mlat'] %>
-<% lon =  params['mlon'] %>
-<% lat =  params['mlat']  %>
+<% end %>
+
+<% if params['lon'] and params['lat'] %>
+<% lon =  params['lon'] %>
+<% lat =  params['lat'] %>
+<% zoom =  params['zoom'] || '5' %>
+<% elsif params['mlon'] and params['mlat'] %>
+<% lon = params['mlon'] %> 
+<% lat = params['mlat'] %>
 <% zoom =  params['zoom'] || '12' %>
-<% elsif @user and params['lon'].nil? and params['lat'].nil? %> 
+<% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %> 
 <% lon =  @user.home_lon %>
 <% lat =  @user.home_lat %>
 <% zoom = '10' %>
-<%else%>
-<% lon =  params['lon'] || '-0.1' %>
-<% lat =  params['lat'] || '51.5' %>
-<% zoom =  params['zoom'] || '4' %>
+<% else %>
+<% lon =  '-0.1' %>
+<% lat =  '51.5' %>
+<% zoom =  params['zoom'] || '5' %>
 <% end %>
 
 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
 <%= javascript_include_tag 'map.js' %>
 
-    <% unless @user %>
-    <script src="http://www.mappam.com/javascripts/mappam.js" type="text/javascript"></script>
-
-    <% end %>
+<% unless @user %>
+<script src="http://www.mappam.com/javascripts/mappam.js" type="text/javascript"></script>
+<% end %>
 
 
 <script type="text/javascript">
   <!--
-  var ie6 = ! ( window.addEventListener || window.XMLHttpRequest );
+  var ie = navigator.appName.indexOf("Microsoft Internet Explorer") != -1;
   var map;
 
   function init(){
     updateLocation();
 
     <% unless @user %>
-     if( window.location.host.match( /^www/ ) ) { 
-        mappam.register( map, '10011756636067178496', '1');
-      } else {
-        mappam.register( map, '6738410720121976832', '1');
-      }
-
+    if ( window.location.hostname == "www.openstreetmap.org" ) { 
+      mappam.register( map, '10011756636067178496', '1');
+    } else if( window.location.hostname == "openstreetmap.org" ) {
+      mappam.register( map, '6738410720121976832', '1');
+    }
     <% end %>
 
     document.getElementById('map_OpenLayers_ViewPort').style.position = 'absolute';
-    if ( ie6 ) {
+    if ( ie ) {
       handleResize();
     }
   }        
@@ -89,6 +94,7 @@
     var bottom = getStyle( el, 'bottom' );
     var right = getStyle( el, 'right' );
     var width = el.old_width;
+    var height;
     if( ! width ) {
         width = getStyle( el, 'width' );
     }
     if( el.offsetParent.nodeName == 'BODY' || el.offsetParent.nodeName == 'HTML' ) {
       if( typeof( window.innerWidth ) == 'number' ) {
           pwidth = window.innerWidth;
-          height = window.innerHeight;
+          pheight = window.innerHeight;
       } else if( document.documentElement &&
           ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
           pwidth = document.documentElement.clientWidth;
     }
     map.updateSize();
     el.style.display = 'none';
-    setTimeout( function() {
-        el.style.display = '';
-        }, 200 );
+    setTimeout( function() { el.style.display = ''; }, 200 );
   }
 
-  if ( ie6 ) {
+  if ( ie ) {
     window.onresize = handleResize;
   }