1 //Called as the user scrolls/zooms around.
2 //Maniplate hrefs of the view tab and various other links
3 function updatelinks(lon,lat,zoom,layers,extents) {
4 var decimals = Math.pow(10, Math.floor(zoom/3));
7 lat = Math.round(lat * decimals) / decimals;
8 lon = Math.round(lon * decimals) / decimals;
10 node = document.getElementById("permalinkanchor");
12 var args = getArgs(node.href);
17 args["layers"] = layers;
19 node.href = setArgs(node.href, args);
22 node = document.getElementById("viewanchor");
24 var args = getArgs(node.href);
29 args["layers"] = layers;
31 node.href = setArgs(node.href, args);
34 node = document.getElementById("exportanchor");
36 var args = getArgs(node.href);
41 args["layers"] = layers;
43 node.href = setArgs(node.href, args);
46 node = document.getElementById("editanchor");
49 var args = new Object();
53 node.href = setArgs("/edit", args);
54 node.style.fontStyle = 'normal';
56 node.href = 'javascript:alert("zoom in to edit map");';
57 node.style.fontStyle = 'italic';
61 node = document.getElementById("historyanchor");
64 var args = new Object();
65 //conjure a bounding box centred at the lat/lon.
66 //TODO: feed actual bounds of the window through to here somehow.
67 minlon = extents.left;
68 minlat = extents.bottom;
69 maxlon = extents.right;
71 minlon = Math.round(minlon * decimals) / decimals;
72 minlat = Math.round(minlat * decimals) / decimals;
73 maxlon = Math.round(maxlon * decimals) / decimals;
74 maxlat = Math.round(maxlat * decimals) / decimals;
75 args.bbox = minlon + "," + minlat + "," + maxlon + "," + maxlat;
76 node.href = setArgs("history/", args);
77 node.style.fontStyle = 'normal';
79 node.href = 'javascript:alert("zoom in to see editing history");';
80 node.style.fontStyle = 'italic';
85 function getArgs(url) {
86 var args = new Object();
87 var querystart = url.indexOf("?");
89 if (querystart >= 0) {
90 var querystring = url.substring(querystart + 1);
91 var queryitems = querystring.split("&");
93 for (var i = 0; i < queryitems.length; i++) {
94 if (match = queryitems[i].match(/^(.*)=(.*)$/)) {
95 args[unescape(match[1])] = unescape(match[2]);
97 args[unescape(queryitems[i])] = null
105 function setArgs(url, args) {
106 var queryitems = new Array();
110 if (args[arg] == null) {
111 queryitems.push(escape(arg));
113 queryitems.push(escape(arg) + "=" + escape(args[arg]));
117 return url.replace(/\?.*$/, "") + "?" + queryitems.join("&");
120 function getStyle(el, property) {
123 if (el.currentStyle) {
124 style = el.currentStyle[property];
125 } else if( window.getComputedStyle ) {
126 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
128 style = el.style[property];