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,minlon,minlat,maxlon,maxlat) {
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 //set bbox param from 'extents' object
66 if (typeof minlon == "number" &&
67 typeof minlat == "number" &&
68 typeof maxlon == "number" &&
69 typeof maxlat == "number") {
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;
78 node.href = setArgs("/history", args);
79 node.style.fontStyle = 'normal';
81 node.href = 'javascript:alert("zoom in to see editing history");';
82 node.style.fontStyle = 'italic';
87 function getArgs(url) {
88 var args = new Object();
89 var querystart = url.indexOf("?");
91 if (querystart >= 0) {
92 var querystring = url.substring(querystart + 1);
93 var queryitems = querystring.split("&");
95 for (var i = 0; i < queryitems.length; i++) {
96 if (match = queryitems[i].match(/^(.*)=(.*)$/)) {
97 args[unescape(match[1])] = unescape(match[2]);
99 args[unescape(queryitems[i])] = null
107 function setArgs(url, args) {
108 var queryitems = new Array();
112 if (args[arg] == null) {
113 queryitems.push(escape(arg));
115 queryitems.push(escape(arg) + "=" + escape(args[arg]));
119 return url.replace(/\?.*$/, "") + "?" + queryitems.join("&");
122 function getStyle(el, property) {
125 if (el.currentStyle) {
126 style = el.currentStyle[property];
127 } else if( window.getComputedStyle ) {
128 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
130 style = el.style[property];