X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/cc5694da1ca047c3e7c57f4de287367788328783..ff9fb4f9c2423aa9ddada69ea867031ac65d36fd:/app/views/browse/start.rjs diff --git a/app/views/browse/start.rjs b/app/views/browse/start.rjs index 64e4431a4..b96e8c39c 100644 --- a/app/views/browse/start.rjs +++ b/app/views/browse/start.rjs @@ -2,7 +2,6 @@ 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 { setStatus("#{I18n.t('browse.start_rjs.zoom_or_select')}"); } @@ -47,8 +51,8 @@ page << < '{{num_features}}')}", { num_features: browseFeatureList.length }))); + p.appendChild(document.createTextNode(i18n("#{I18n.t('browse.start_rjs.loaded_an_area_with_num_features')}", { num_features: browseFeatureList.length }))); div.appendChild(p); var input = document.createElement("input"); @@ -154,7 +178,7 @@ page << < #{APP_CONFIG['max_request_area']}) { - setStatus(i18n_js("#{I18n.t('browse.start_rjs.unable_to_load_size', :bbox_size => '{{bbox_size}}', :max_bbox_size => APP_CONFIG['max_request_area'])}", { bbox_size: size })); + 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/#{API_VERSION}/map?bbox=" + projected.toBBOX()); + loadGML("/api/#{API_VERSION}/map?bbox=" + projected.toBBOX(), reload); } } - function loadGML(url) { + function loadGML(url, reload) { setStatus("#{I18n.t('browse.start_rjs.loading')}"); $("browse_content").innerHTML = ""; - if (!browseDataLayer) { + var formatOptions = { + checkTags: true, + interestingTagsExclude: ['source','source_ref','source:ref','history','attribution','created_by','tiger:county','tiger:tlid','tiger:upload_uuid'] + }; + + if (areasHidden) formatOptions.areaTags = []; + + if (!browseDataLayer || reload) { var style = new OpenLayers.Style(); style.addRules([new OpenLayers.Rule({ @@ -208,12 +239,11 @@ page << < '{{feature}}')}", { feature: featureNameHistory(this.feature) }))); + heading.appendChild(document.createTextNode(i18n("#{I18n.t('browse.start_rjs.history_for_feature')}", { feature: featureNameHistory(this.feature) }))); tr.appendChild(heading); var td = document.createElement("td"); @@ -442,7 +474,7 @@ page << < '{{user}}', :timestamp => '{{timestamp}}')}", { user: user, timestamp: 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); @@ -466,42 +498,40 @@ page << < '{{id}}')}", { id: feature.osm_id }); + return i18n("#{I18n.t('browse.start_rjs.object_list.selected.type.node')}", { id: feature.osm_id }); } else if (featureType(feature) == "way") { - return i18n_js("#{I18n.t('browse.start_rjs.object_list.selected.type.way', :id => '{{id}}')}", { id: feature.osm_id }); + return i18n("#{I18n.t('browse.start_rjs.object_list.selected.type.way')}", { id: feature.osm_id }); } } function featureNameHistory(feature) { - if (feature.attributes.name) { + 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_js("#{I18n.t('browse.start_rjs.object_list.history.type.node', :id => '{{id}}')}", { id: feature.osm_id }); + return i18n("#{I18n.t('browse.start_rjs.object_list.history.type.node')}", { id: feature.osm_id }); } else if (featureType(feature) == "way") { - return i18n_js("#{I18n.t('browse.start_rjs.object_list.history.type.way', :id => '{{id}}')}", { id: feature.osm_id }); + return i18n("#{I18n.t('browse.start_rjs.object_list.history.type.way')}", { id: feature.osm_id }); } } - /* - This is a hack so that we can interpolate JavaScript variables in - translation strings from Ruby, doing the string replacement - client-side instead of on the server. - */ - function i18n_js(string, keys) { - for (var key in keys) { - var re_key = '\{\{' + key + '\}\}'; - var re = new RegExp(re_key, "g"); - - string = string.replace(re, keys[key]); - } - - return string; - } - function setStatus(status) { $("browse_status").innerHTML = status; $("browse_status").style.display = "block";