]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - src/assets/js/base.js
javascript: indent 2 space, not 4 space
[nominatim-ui.git] / src / assets / js / base.js
index 5754e3dcd916340a9b871c838d7e61eb52b58d1f..8c7696d99e3f4496317176cf66eb0e0a454b1a6f 100644 (file)
@@ -7,47 +7,47 @@ var last_click_latlng;
 *********************************************************/
 
 function get_config_value(str, default_val) {
-    return (typeof Nominatim_Config[str] !== 'undefined' ? Nominatim_Config[str] :  default_val);
+  return (typeof Nominatim_Config[str] !== 'undefined' ? Nominatim_Config[str] :  default_val);
 }
 
 function parse_and_normalize_geojson_string(part){
-    // normalize places the geometry into a featurecollection, similar to
-    // https://github.com/mapbox/geojson-normalize
-    var parsed_geojson = {
-        type: "FeatureCollection",
-        features: [
-            {
-                type: "Feature",
-                geometry: part,
-                properties: {}
-            }
-        ]
-    };
-    return parsed_geojson;
+  // normalize places the geometry into a featurecollection, similar to
+  // https://github.com/mapbox/geojson-normalize
+  var parsed_geojson = {
+    type: "FeatureCollection",
+    features: [
+      {
+        type: "Feature",
+        geometry: part,
+        properties: {}
+      }
+    ]
+  };
+  return parsed_geojson;
 }
 
 function map_link_to_osm(){
-    return "https://openstreetmap.org/#map=" + map.getZoom() + "/" + map.getCenter().lat + "/" + map.getCenter().lng;
+  return "https://openstreetmap.org/#map=" + map.getZoom() + "/" + map.getCenter().lat + "/" + map.getCenter().lng;
 }
 
 function map_viewbox_as_string() {
-    var bounds = map.getBounds();
-    var west = bounds.getWest();
-    var east = bounds.getEast();
-
-    if ((east - west) >= 360) { // covers more than whole planet
-        west = map.getCenter().lng-179.999;
-        east = map.getCenter().lng+179.999;
-    }
-    east = L.latLng(77, east).wrap().lng;
-    west = L.latLng(77, west).wrap().lng;
-
-    return [
-        west.toFixed(5), // left
-        bounds.getNorth().toFixed(5), // top
-        east.toFixed(5), // right
-        bounds.getSouth().toFixed(5) // bottom
-    ].join(',');
+  var bounds = map.getBounds();
+  var west = bounds.getWest();
+  var east = bounds.getEast();
+
+  if ((east - west) >= 360) { // covers more than whole planet
+    west = map.getCenter().lng-179.999;
+    east = map.getCenter().lng+179.999;
+  }
+  east = L.latLng(77, east).wrap().lng;
+  west = L.latLng(77, west).wrap().lng;
+
+  return [
+    west.toFixed(5), // left
+    bounds.getNorth().toFixed(5), // top
+    east.toFixed(5), // right
+    bounds.getSouth().toFixed(5) // bottom
+  ].join(',');
 }
 
 
@@ -57,50 +57,50 @@ function map_viewbox_as_string() {
 
 function fetch_from_api(endpoint_name, params, callback) {
 
-    // `&a=&b=&c=1` => '&c='
-    for(var k in params) {
-        if (typeof(params[k]) === 'undefined' || params[k] === '' || params[k] === null ) delete params[k];
-    }
-
-    var api_url = get_config_value('Nominatim_API_Endpoint') + endpoint_name + '.php?' + $.param(params);
-    if (endpoint_name !== 'status') {
-        $('#api-request-link').attr('href', api_url);
-    }
-    $.get(api_url, function(data){
-        callback(data);
-    });
+  // `&a=&b=&c=1` => '&c='
+  for(var k in params) {
+    if (typeof(params[k]) === 'undefined' || params[k] === '' || params[k] === null ) delete params[k];
+  }
+
+  var api_url = get_config_value('Nominatim_API_Endpoint') + endpoint_name + '.php?' + $.param(params);
+  if (endpoint_name !== 'status') {
+    $('#api-request-link').attr('href', api_url);
+  }
+  $.get(api_url, function(data){
+    callback(data);
+  });
 }
 
 function update_data_date() {
-    fetch_from_api('status', {format: 'json'}, function(data){
-        $('#data-date').text(data.data_updated);
-    });
+  fetch_from_api('status', {format: 'json'}, function(data){
+    $('#data-date').text(data.data_updated);
+  });
 }
 
 function render_template(el, template_name, page_context) {
-    var template_source = $('#' + template_name).text();
-    var template = Handlebars.compile(template_source);
-    var html    = template(page_context);
-    el.html(html);
+  var template_source = $('#' + template_name).text();
+  var template = Handlebars.compile(template_source);
+  var html    = template(page_context);
+  el.html(html);
 }
 
 function show_error(html) {
-    $('#error-overlay').html(html).show();   
+  $('#error-overlay').html(html).show();   
 }
 
 function hide_error() {
-    $('#error-overlay').empty().hide();    
+  $('#error-overlay').empty().hide();    
 }
 
 
 $(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
-    // console.log(thrownError);
-    // console.log(ajaxSettings);
-    show_error('Error fetching results from <a href="' + ajaxSettings.url + '">' + ajaxSettings.url + '</a>');
+  // console.log(thrownError);
+  // console.log(ajaxSettings);
+  show_error('Error fetching results from <a href="' + ajaxSettings.url + '">' + ajaxSettings.url + '</a>');
 });
 
 
 jQuery(document).ready(function(){
-    hide_error();
+  hide_error();
 });