Changeset 714


Ignore:
Timestamp:
Feb 7, 2010, 3:36:06 PM (10 years ago)
Author:
Nick Burch
Message:

Begin support for viewing multiple decades

Location:
trunk/npemap.org.uk/static
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/static/indexPage.js

    r524 r714  
    11var ROOTURL = ".";
     2var latestVersion = "latest";
    23
    34// The X offset
     
    89
    910function gotoLocation(easting, northing, zoom) {
    10     location.href = urlFor(easting, northing, zoom);
     11        gotoLocationFor(latestVersion, easting, northing, zoom);
     12}
     13function gotoLocationFor(version, easting, northing, zoom) {
     14    location.href = urlFor(version, easting, northing, zoom);
    1115}
    1216
    1317
    1418function click(e) {
    15        
    16   e = YAHOO.util.Event.getEvent(e);
    17   var img = YAHOO.util.Event.getTarget(e);
    18   var imgPos = YAHOO.util.Dom.getXY(img);
     19        clickFor(latestVersion, e);
     20}
     21function buildClick(version) {
     22        return function(e) {
     23                return clickFor(version, e);
     24        }
     25}
     26function clickFor(version, e) {
     27        e = YAHOO.util.Event.getEvent(e);
     28        var img = YAHOO.util.Event.getTarget(e);
     29        var imgPos = YAHOO.util.Dom.getXY(img);
    1930
    2031        var x = (xOffset + YAHOO.util.Event.getPageX(e) - imgPos[0]) * 2;
    2132        var y = (img.height-(YAHOO.util.Event.getPageY(e) - imgPos[1])) * 2;
    2233
    23         location.href=(urlFor(x, y, 3));
     34        location.href=(urlFor(version, x, y, 3));
    2435
    2536        YAHOO.util.Event.stopEvent(e);
     
    3142zooms[3] = 6;
    3243
    33 function urlFor(easting, northing, zoom) {
     44function urlFor(version, easting, northing, zoom) {
    3445  var x= Math.round(easting / zooms[zoom]);
    3546  var y= Math.round(northing/ zooms[zoom]);
    36   return ROOTURL + "/tiles/map.html#" +  x + "," + y +","+zoom;
     47  if(version == latestVersion) {
     48     return ROOTURL + "/tiles/map.html#" + x + "," + y +","+zoom;
     49  } else {
     50     return ROOTURL + "/tiles/" + version +"s/map.html#"+x+","+y+","+zoom;
     51  }
    3752}
    3853
Note: See TracChangeset for help on using the changeset viewer.