Changeset 122


Ignore:
Timestamp:
Oct 21, 2006, 11:43:35 PM (13 years ago)
Author:
David Sheldon
Message:

Ok, back button now works, but we should tidy up the links _to_ this page so they use # rather than ? (this will probably also improve caching)

File:
1 edited

Legend:

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

    r119 r122  
    198198  size = 1000;
    199199
    200         urlquery=location.href.split("?")
    201         if (urlquery[1]) {
    202                 urlterms=urlquery[1].split(",")
    203                 offsetGridX = urlterms[0]-0 ;
    204                 offsetGridY = urlterms[1]-0 ;
    205 
    206                 if(urlterms.length > 2) {
    207                         zoomLevel = urlterms[2]-0 ;
    208                 }
    209         }
     200  parseQueryString();
    210201
    211202    prefix = prefixes[zoomLevel];
    212203}
     204
     205function parseQueryString() {
     206  var hash = location.href.lastIndexOf('#');
     207        var query = location.href.lastIndexOf("?")
     208  var params = '';
     209  if (hash != -1) {
     210    params = location.href.substring(hash+1);
     211  }
     212  else if (query != -1) {
     213    params = location.href.substring(query+1);
     214  }
     215  if (params.length > 0) {
     216    urlterms=params.split(",")
     217    offsetGridX = urlterms[0]-0 ;
     218    offsetGridY = urlterms[1]-0 ;
     219
     220    if(urlterms.length > 2) {
     221      zoomLevel = urlterms[2]-0 ;
     222    }
     223        }
     224}
     225
    213226
    214227// Need to use substring for IE, and it doesn't take negative numbers.
     
    308321
    309322function updatePermalink() {
    310         document.getElementById("permalink").href = "?" + offsetGridX + "," + offsetGridY + "," + zoomLevel;
    311 }
    312 
     323        document.getElementById("permalink").href = "#" + getLink();
     324  location.href = '#'+getLink();
     325 
     326}
     327
     328function getLink() {
     329  return offsetGridX + "," + offsetGridY + "," + zoomLevel;
     330}
    313331
    314332function updateGrid(theDirection) {
Note: See TracChangeset for help on using the changeset viewer.