X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/88105d9c643519e02082ba9cc5044bb0dfdcb7b9..d99f08314cd0302cd153517e4d0d7430abedf40a:/app/views/browse/start.rjs?ds=sidebyside diff --git a/app/views/browse/start.rjs b/app/views/browse/start.rjs index 35cd56591..b045bc9ea 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(); } 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(); @@ -70,13 +64,18 @@ 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 > #{APP_CONFIG['max_request_area']}) { + setStatus(i18n("#{I18n.t('browse.start_rjs.unable_to_load_size', :max_bbox_size => APP_CONFIG['max_request_area'])}", { bbox_size: size })); } else { - loadGML("/api/0.5/map?bbox=" + projected.toBBOX()); + loadGML("/api/#{API_VERSION}/map?bbox=" + projected.toBBOX()); } } function loadGML(url) { - $("browse_status").innerHTML = "Loading..."; - $("browse_object_list").innerHTML = ""; + setStatus("#{I18n.t('browse.start_rjs.loading')}"); + $("browse_content").innerHTML = ""; if (!browseDataLayer) { var style = new OpenLayers.Style(); @@ -210,21 +209,24 @@ 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); + } - $("browse_object_list").appendChild(div); + function featureType(feature) { + if (feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") { + return "node"; + } else { + return "way"; + } } - + + 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