]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/application.js
Remove unused osmarender key data
[rails.git] / app / assets / javascripts / application.js
index 352ec9f8ae2117ac7082efa2b79da801ba9dfe25..747c6d9afe5d45544717c7f24c759ee5f8bfd77a 100644 (file)
@@ -2,21 +2,22 @@
 //= require jquery_ujs
 //= require jquery.autogrowtextarea
 //= require jquery.timers
+//= require augment
 //= require openlayers
 //= require i18n/translations
 //= require globals
-//= require compat
 //= require browse
 //= require export
 //= require map
+//= require key
 //= require menu
+//= require sidebar
 
-if ( !Array.prototype.forEach ) {
-  Array.prototype.forEach = function(fn, scope) {
-    for(var i = 0, len = this.length; i < len; ++i) {
-      fn.call(scope || this, this[i], i, this);
-    }
-  }
+function zoomPrecision(zoom) {
+    var decimals = Math.pow(10, Math.floor(zoom/3));
+    return function(x) {
+         return Math.round(x * decimals) / decimals;
+    };
 }
 
 /*
@@ -24,17 +25,17 @@ if ( !Array.prototype.forEach ) {
  * view tab and various other links
  */
 function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,objid) {
-  var decimals = Math.pow(10, Math.floor(zoom/3));
+  var toPrecision = zoomPrecision(zoom);
   var node;
 
-  lat = Math.round(lat * decimals) / decimals;
-  lon = Math.round(lon * decimals) / decimals;
+  lat = toPrecision(lat);
+  lon = toPrecision(lon);
 
   if (minlon) {
-    minlon = Math.round(minlon * decimals) / decimals;
-    minlat = Math.round(minlat * decimals) / decimals;
-    maxlon = Math.round(maxlon * decimals) / decimals;
-    maxlat = Math.round(maxlat * decimals) / decimals;
+    minlon = toPrecision(minlon);
+    minlat = toPrecision(minlat);
+    maxlon = toPrecision(maxlon);
+    maxlat = toPrecision(maxlat);
   }
 
   $(".geolink").each(function (index, link) {