- function validateLinks() {
- var bounds = this.getExtent();
- bounds = bounds.clone().transform(map.getProjectionObject(), epsg4326);
-
- if (bounds.getWidth() * bounds.getHeight() > 0.25) {
- $("use_map").style.display = "none";
- } else {
- $("use_map").style.display = "inline";
- }
+
+ $("browse_object_list").appendChild(ul);
+
+ var link = document.createElement("a");
+ link.href = "/browse/"+type+"/"+feature.osm_id+"/history";
+ link.appendChild(document.createTextNode("History"));
+ link.onclick = OpenLayers.Function.bind(loadHistory, {
+ type: type, feature: feature, link: link
+ });
+
+ $("browse_object_list").appendChild(link);
+
+ // Stash the currently drawn feature
+ browseActiveFeature = feature;
+ }
+
+ function loadHistory() {
+ this.link.href = "";
+ this.link.innerHTML = "Wait...";
+
+ new Ajax.Request("/api/0.5/" + this.type + "/" + this.feature.osm_id + "/history", {
+ onComplete: OpenLayers.Function.bind(displayHistory, this)
+ });
+
+ return false;
+ }
+
+ function displayHistory(request) {
+ if (browseActiveFeature.osm_id != this.feature.osm_id || $("browse_object_list").firstChild == browseObjectList) {
+ return false;
+ }
+
+ this.link.parentNode.removeChild(this.link);
+
+ var doc = request.responseXML;
+ var div = document.createElement("div");
+ var h3 = document.createElement("h3");
+ h3.appendChild(document.createTextNode("History"));
+ div.appendChild(h3);
+
+ var nodes = doc.getElementsByTagName(this.type);
+ var history = document.createElement("ul");
+ for (var i = nodes.length - 1; i >= 0; i--) {
+ var user = nodes[i].getAttribute("user") || "private user";
+ var timestamp = nodes[i].getAttribute("timestamp");
+ var item = document.createElement("li");
+ item.appendChild(document.createTextNode("Edited by " + user + " at " + timestamp));
+ history.appendChild(item);