From d3c60874092c63b493818f227f31027327b595e3 Mon Sep 17 00:00:00 2001 From: Harry Wood Date: Mon, 23 Mar 2009 16:41:18 +0000 Subject: [PATCH] js changes for 'history' tab --- config/routes.rb | 11 +++++++---- public/javascripts/map.js | 2 +- public/javascripts/site.js | 27 ++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 4431c4765..fcf22bced 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -71,7 +71,7 @@ ActionController::Routing::Routes.draw do |map| map.connect "api/#{API_VERSION}/swf/trackpoints", :controller =>'swf', :action =>'trackpoints' # Data browsing - map.connect '/browse', :controller => 'browse', :action => 'index' + map.connect '/browse', :controller => 'changeset', :action => 'list' map.connect '/browse/start', :controller => 'browse', :action => 'start' map.connect '/browse/way/:id', :controller => 'browse', :action => 'way', :id => /\d+/ map.connect '/browse/way/:id/history', :controller => 'browse', :action => 'way_history', :id => /\d+/ @@ -80,11 +80,12 @@ ActionController::Routing::Routes.draw do |map| map.connect '/browse/relation/:id', :controller => 'browse', :action => 'relation', :id => /\d+/ map.connect '/browse/relation/:id/history', :controller => 'browse', :action => 'relation_history', :id => /\d+/ map.connect '/browse/changeset/:id', :controller => 'browse', :action => 'changeset', :id => /\d+/ + map.connect '/browse/changesets', :controller => 'changeset', :action => 'list' # web site - map.connect '/', :controller => 'site', :action => 'index' map.connect '/edit', :controller => 'site', :action => 'edit' + map.connect '/history', :controller => 'changeset', :action => 'list_bbox' map.connect '/export', :controller => 'site', :action => 'export' map.connect '/login', :controller => 'user', :action => 'login' map.connect '/logout', :controller => 'user', :action => 'logout' @@ -101,6 +102,7 @@ ActionController::Routing::Routes.draw do |map| map.connect '/index.html', :controller => 'site', :action => 'index' map.connect '/edit.html', :controller => 'site', :action => 'edit' + map.connect '/history.html', :controller => 'changeset', :action => 'list_bbox' map.connect '/export.html', :controller => 'site', :action => 'export' map.connect '/search.html', :controller => 'way_tag', :action => 'search' map.connect '/login.html', :controller => 'user', :action => 'login' @@ -137,7 +139,7 @@ ActionController::Routing::Routes.draw do |map| # user pages map.connect '/user/:display_name', :controller => 'user', :action => 'view' - map.connect '/user/:display_name/edits', :controller => 'changeset', :action => 'list' + map.connect '/user/:display_name/edits', :controller => 'changeset', :action => 'list_user' map.connect '/user/:display_name/make_friend', :controller => 'user', :action => 'make_friend' map.connect '/user/:display_name/remove_friend', :controller => 'user', :action => 'remove_friend' map.connect '/user/:display_name/diary', :controller => 'diary_entry', :action => 'list' @@ -152,7 +154,8 @@ ActionController::Routing::Routes.draw do |map| map.connect '/diary/rss', :controller => 'diary_entry', :action => 'rss' map.connect '/diary/:language', :controller => 'diary_entry', :action => 'list' map.connect '/diary/:language/rss', :controller => 'diary_entry', :action => 'rss' - + + # test pages map.connect '/test/populate/:table/:from/:count', :controller => 'test', :action => 'populate' map.connect '/test/populate/:table/:count', :controller => 'test', :action => 'populate', :from => 1 diff --git a/public/javascripts/map.js b/public/javascripts/map.js index 608f4c264..a25564f0d 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -144,7 +144,7 @@ function setMapExtent(extent) { map.zoomToExtent(extent.clone().transform(epsg4326, map.getProjectionObject())); } -function getMapExtent(extent) { +function getMapExtent() { return map.getExtent().clone().transform(map.getProjectionObject(), epsg4326); } diff --git a/public/javascripts/site.js b/public/javascripts/site.js index 95c0b938e..d381c0231 100644 --- a/public/javascripts/site.js +++ b/public/javascripts/site.js @@ -1,4 +1,6 @@ -function updatelinks(lon,lat,zoom,layers) { +//Called as the user scrolls/zooms around. +//Maniplate hrefs of the view tab and various other links +function updatelinks(lon,lat,zoom,layers,extents) { var decimals = Math.pow(10, Math.floor(zoom/3)); var node; @@ -55,6 +57,29 @@ function updatelinks(lon,lat,zoom,layers) { node.style.fontStyle = 'italic'; } } + + node = document.getElementById("historyanchor"); + if (node) { + if (zoom >= 11) { + var args = new Object(); + //conjure a bounding box centred at the lat/lon. + //TODO: feed actual bounds of the window through to here somehow. + minlon = extents.left; + minlat = extents.bottom; + maxlon = extents.right; + maxlat = extents.top; + minlon = Math.round(minlon * decimals) / decimals; + minlat = Math.round(minlat * decimals) / decimals; + maxlon = Math.round(maxlon * decimals) / decimals; + maxlat = Math.round(maxlat * decimals) / decimals; + args.bbox = minlon + "," + minlat + "," + maxlon + "," + maxlat; + node.href = setArgs("history/", args); + node.style.fontStyle = 'normal'; + } else { + node.href = 'javascript:alert("zoom in to see editing history");'; + node.style.fontStyle = 'italic'; + } + } } function getArgs(url) { -- 2.43.2