X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/18777b41ea4aa1364dbf33e86e6cb65762b53296..b63ce5d460cf794602aa7996cdd857dc39faa3d9:/app/views/browse/start.rjs?ds=sidebyside diff --git a/app/views/browse/start.rjs b/app/views/browse/start.rjs index 35cd56591..b96e8c39c 100644 --- a/app/views/browse/start.rjs +++ b/app/views/browse/start.rjs @@ -1,8 +1,7 @@ -page.replace_html :sidebar_title, 'Data' +page.replace_html :sidebar_title, t('browse.start_rjs.data_frame_title') page.replace_html :sidebar_content, :partial => 'start' page << <= 15) { - useMap(); + useMap(false); } else { - $("browse_status").innerHTML = "Zoom in or Select an area of the map to view."; + setStatus("#{I18n.t('browse.start_rjs.zoom_or_select')}"); } } } function stopBrowse() { - if (browseActive) { - browseActive = false; - - if (browseDataLayer) { - browseDataLayer.destroy(); - browseDataLayer = null; - } + if (map.dataLayer.active) { + map.dataLayer.active = false; if (browseSelectControl) { browseSelectControl.destroy(); @@ -62,7 +61,7 @@ page << < 0.25) { - $("browse_status").innerHTML = "Unable to load: Bounding box size of " + size + " is too large. (Must be smaller than 0.25)
"; + if (size > #{MAX_REQUEST_AREA}) { + setStatus(i18n("#{I18n.t('browse.start_rjs.unable_to_load_size', :max_bbox_size => MAX_REQUEST_AREA)}", { bbox_size: size })); } else { - loadGML("/api/0.5/map?bbox=" + projected.toBBOX()); + loadGML("/api/#{API_VERSION}/map?bbox=" + projected.toBBOX(), reload); } } - function loadGML(url) { - $("browse_status").innerHTML = "Loading..."; - $("browse_object_list").innerHTML = ""; + function loadGML(url, reload) { + setStatus("#{I18n.t('browse.start_rjs.loading')}"); + $("browse_content").innerHTML = ""; + + var formatOptions = { + checkTags: true, + interestingTagsExclude: ['source','source_ref','source:ref','history','attribution','created_by','tiger:county','tiger:tlid','tiger:upload_uuid'] + }; - if (!browseDataLayer) { + if (areasHidden) formatOptions.areaTags = []; + + if (!browseDataLayer || reload) { var style = new OpenLayers.Style(); style.addRules([new OpenLayers.Rule({ @@ -208,26 +239,30 @@ page << <= 0; i--) { - var user = nodes[i].getAttribute("user") || "private user"; + var user = nodes[i].getAttribute("user") || "#{I18n.t('browse.start_rjs.private_user')}"; var timestamp = nodes[i].getAttribute("timestamp"); var item = document.createElement("li"); - item.appendChild(document.createTextNode("Edited by " + user + " at " + timestamp)); + item.appendChild(document.createTextNode(i18n("#{I18n.t('browse.start_rjs.edited_by_user_at_timestamp')}", { user: user, timestamp: timestamp }))); history.appendChild(item); } div.appendChild(history); - var link = document.createElement("a"); - link.appendChild(document.createTextNode("History entry for " + this.feature.osm_id)); - link.href = "/browse/"+this.type+"/"+this.feature.osm_id+"/history"; - div.appendChild(link); + $("browse_content").appendChild(div); + } + + function featureType(feature) { + if (feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") { + return "node"; + } else { + return "way"; + } + } - $("browse_object_list").appendChild(div); + function featureTypeName(feature) { + if (featureType(feature) == "node") { + return "#{I18n.t('browse.start_rjs.object_list.type.node')}"; + } else if (featureType(feature) == "way") { + return "#{I18n.t('browse.start_rjs.object_list.type.way')}"; + } } - + + function featureName(feature) { + if (feature.attributes['name:#{I18n.locale}']) { + return feature.attributes['name:#{I18n.locale}']; + } else if (feature.attributes.name) { + return feature.attributes.name; + } else { + return feature.osm_id; + } + } + + function featureNameSelect(feature) { + if (feature.attributes['name:#{I18n.locale}']) { + return feature.attributes['name:#{I18n.locale}']; + } else if (feature.attributes.name) { + return feature.attributes.name; + } else if (featureType(feature) == "node") { + return i18n("#{I18n.t('browse.start_rjs.object_list.selected.type.node')}", { id: feature.osm_id }); + } else if (featureType(feature) == "way") { + return i18n("#{I18n.t('browse.start_rjs.object_list.selected.type.way')}", { id: feature.osm_id }); + } + } + + function featureNameHistory(feature) { + if (feature.attributes['name:#{I18n.locale}']) { + return feature.attributes['name:#{I18n.locale}']; + } else if (feature.attributes.name) { + return feature.attributes.name; + } else if (featureType(feature) == "node") { + return i18n("#{I18n.t('browse.start_rjs.object_list.history.type.node')}", { id: feature.osm_id }); + } else if (featureType(feature) == "way") { + return i18n("#{I18n.t('browse.start_rjs.object_list.history.type.way')}", { id: feature.osm_id }); + } + } + + function setStatus(status) { + $("browse_status").innerHTML = status; + $("browse_status").style.display = "block"; + } + + function clearStatus() { + $("browse_status").innerHTML = ""; + $("browse_status").style.display = "none"; + } + startBrowse(); EOJ