- // If the current object is the list, don't innerHTML="", since that could clear it.
- if ($("#browse_content").firstChild == browseObjectList) {
- $("#browse_content").removeChild(browseObjectList);
- } else {
- $("#browse_content").empty();
- }
-
- $("#browse_content").html(JST["templates/browse/feature"]({
- name: featureNameSelect(feature),
- url: "/browse/" + featureType(feature) + "/" + feature.osm_id,
- attributes: feature.attributes
- }));
-
- $("#browse_content").find("a.browse_show_list").click(loadObjectList);
- $("#browse_content").find("a.browse_show_history").click(loadHistory);
-
- // Stash the currently drawn feature
- browseActiveFeature = feature;
- }
-
- function loadHistory() {
- $(this).attr("href", "").text(I18n.t('browse.start_rjs.wait'));
-
- var feature = browseActiveFeature;
-
- $.ajax({
- url: "/api/" + OSM.API_VERSION + "/" + featureType(feature) + "/" + feature.osm_id + "/history",
- success: function (xml) {
- if (browseActiveFeature != feature || $("#browse_content").firstChild == browseObjectList) {
- return;
- }
-
- $(this).remove();
-
- var history = [];
- var nodes = xml.getElementsByTagName(featureType(feature));
- for (var i = nodes.length - 1; i >= 0; i--) {
- history.push({
- user: nodes[i].getAttribute("user") || I18n.t('browse.start_rjs.private_user'),
- timestamp: nodes[i].getAttribute("timestamp")
- });
- }
-
- $("#browse_content").append(JST["templates/browse/feature_history"]({
- name: featureNameHistory(feature),
- url: "/browse/" + featureType(feature) + "/" + feature.osm_id,
- history: history
- }));
- }.bind(this)
- });