X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/ceb6a86430343b379e09771d7f040c223adde69d..35785067979a410f2a3f78927d50869ee398f349:/app/views/browse/start.rjs diff --git a/app/views/browse/start.rjs b/app/views/browse/start.rjs index c7a795b98..64e4431a4 100644 --- a/app/views/browse/start.rjs +++ b/app/views/browse/start.rjs @@ -131,7 +131,7 @@ page << < '{{num_features}}')}", { num_features: browseFeatureList.length }))); div.appendChild(p); var input = document.createElement("input"); @@ -186,8 +186,8 @@ page << < 0.25) { - setStatus("#{I18n.t('browse.start_rjs.unable_to_load')} " + size + " #{I18n.t('browse.start_rjs.must_be_smaller')}"); + if (size > #{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 })); } else { loadGML("/api/#{API_VERSION}/map?bbox=" + projected.toBBOX()); } @@ -245,7 +245,7 @@ page << < '{{feature}}')}", { feature: featureNameHistory(this.feature) }))); tr.appendChild(heading); var td = document.createElement("td"); @@ -442,7 +442,7 @@ page << < '{{user}}', :timestamp => '{{timestamp}}')}", { user: user, timestamp: timestamp }))); history.appendChild(item); } div.appendChild(history); @@ -457,15 +457,51 @@ page << < '{{id}}')}", { 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 }); + } + } + + function featureNameHistory(feature) { + 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 }); + } else if (featureType(feature) == "way") { + return i18n_js("#{I18n.t('browse.start_rjs.object_list.history.type.way', :id => '{{id}}')}", { 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"; @@ -476,9 +512,5 @@ page << <