#!/bin/bash
-rsync --quiet --recursive src/assets dist/
+rsync --quiet --recursive src/assets/css dist/css/
+rsync --quiet --recursive src/assets/images/ dist/images/
+cat src/assets/js/base.js src/assets/js/detailpage.js src/assets/js/searchpage.js > dist/assets/js/nominatim-ui.js
+
rsync --quiet --recursive src/vendor/js/* dist/assets/js/
rsync --quiet --recursive src/vendor/css/* dist/assets/css/
# rsync --quiet --recursive src/vendor/images/* dist/assets/images/
--- /dev/null
+var map;
+var last_click_latlng;
+
+
+/*********************************************************
+* HELPERS
+*********************************************************/
+
+function get_config_value(str, default_val) {
+ return (typeof Nominatim_Config[str] !== 'undefined' ? Nominatim_Config[str] : default_val);
+}
+
+function parse_and_normalize_geojson_string(raw_string){
+ // normalize places the geometry into a featurecollection, similar to
+ // https://github.com/mapbox/geojson-normalize
+ var parsed_geojson = {
+ type: "FeatureCollection",
+ features: [
+ {
+ type: "Feature",
+ geometry: JSON.parse(raw_string),
+ properties: {}
+ }
+ ]
+ };
+ return parsed_geojson;
+}
+
+function map_link_to_osm(){
+ return "https://openstreetmap.org/#map=" + map.getZoom() + "/" + map.getCenter().lat + "/" + map.getCenter().lng;
+}
+
+function map_viewbox_as_string() {
+ // since .toBBoxString() doesn't round numbers
+ return [
+ map.getBounds().getSouthWest().lng.toFixed(5), // left
+ map.getBounds().getNorthEast().lat.toFixed(5), // top
+ map.getBounds().getNorthEast().lng.toFixed(5), // right
+ map.getBounds().getSouthWest().lat.toFixed(5) // bottom
+ ].join(',');
+}
+
+
+/*********************************************************
+* PAGE HELPERS
+*********************************************************/
+
+function fetch_from_api(endpoint_name, params, callback) {
+ 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_last_updated.formatted);
+ });
+}
+
+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);
+}
+
+function show_error(html) {
+ $('#error-overlay').html(html).show();
+}
+
+function hide_error() {
+ $('#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>');
+});
+
+
+jQuery(document).ready(function(){
+ hide_error();
+});
+
--- /dev/null
+/*********************************************************
+* DETAILS PAGE
+*********************************************************/
+
+
+
+function init_map_on_detail_page(lat, lon, geojson) {
+ map = new L.map('map', {
+ // center: [nominatim_map_init.lat, nominatim_map_init.lon],
+ // zoom: nominatim_map_init.zoom,
+ attributionControl: (get_config_value('Map_Tile_Attribution') && get_config_value('Map_Tile_Attribution').length),
+ scrollWheelZoom: true, // !L.Browser.touch,
+ touchZoom: false,
+ });
+
+ L.tileLayer(get_config_value('Map_Tile_URL'), {
+ // moved to footer
+ attribution: (get_config_value('Map_Tile_Attribution') || null ) //'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
+ }).addTo(map);
+
+ var layerGroup = new L.layerGroup().addTo(map);
+
+ var circle = L.circleMarker([lat,lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75});
+ map.addLayer(circle);
+
+ if (geojson) {
+ var geojson_layer = L.geoJson(
+ // http://leafletjs.com/reference-1.0.3.html#path-option
+ parse_and_normalize_geojson_string(geojson),
+ {
+ style: function(feature) {
+ return { interactive: false, color: 'blue' };
+ }
+ }
+ );
+ map.addLayer(geojson_layer);
+ map.fitBounds(geojson_layer.getBounds());
+ } else {
+ map.setView([lat,lon],10);
+ }
+
+ var osm2 = new L.TileLayer(get_config_value('Map_Tile_URL'), {minZoom: 0, maxZoom: 13, attribution: (get_config_value('Map_Tile_Attribution') || null )});
+ var miniMap = new L.Control.MiniMap(osm2, {toggleDisplay: true}).addTo(map);
+}
+
+
+
+jQuery(document).ready(function(){
+
+ if ( !$('#details-page').length ){ return; }
+
+ var search_params = new URLSearchParams(location.search);
+ // var place_id = search_params.get('place_id');
+
+ var api_request_params = {
+ place_id: search_params.get('place_id'),
+ place_id: search_params.get('osmtype'),
+ place_id: search_params.get('osmid'),
+ group_parents: 1,
+ format: 'json'
+ };
+
+ fetch_from_api('details', api_request_params, function(aFeature){
+
+ var context = { aPlace: aFeature };
+
+ render_template($('main'), 'detailspage-template', context);
+
+ update_data_date();
+
+ init_map_on_detail_page(aFeature.lat, aFeature.lon, aFeature.asgeojson);
+ });
+});
\ No newline at end of file
-var map;
-var last_click_latlng;
-
-
-/*********************************************************
-* HELPERS
-*********************************************************/
-
-function get_config_value(str, default_val) {
- return (typeof Nominatim_Config[str] !== 'undefined' ? Nominatim_Config[str] : default_val);
-}
-
-function parse_and_normalize_geojson_string(raw_string){
- // normalize places the geometry into a featurecollection, similar to
- // https://github.com/mapbox/geojson-normalize
- var parsed_geojson = {
- type: "FeatureCollection",
- features: [
- {
- type: "Feature",
- geometry: JSON.parse(raw_string),
- properties: {}
- }
- ]
- };
- return parsed_geojson;
-}
-
-function map_link_to_osm(){
- return "https://openstreetmap.org/#map=" + map.getZoom() + "/" + map.getCenter().lat + "/" + map.getCenter().lng;
-}
-
-function map_viewbox_as_string() {
- // since .toBBoxString() doesn't round numbers
- return [
- map.getBounds().getSouthWest().lng.toFixed(5), // left
- map.getBounds().getNorthEast().lat.toFixed(5), // top
- map.getBounds().getNorthEast().lng.toFixed(5), // right
- map.getBounds().getSouthWest().lat.toFixed(5) // bottom
- ].join(',');
-}
-
-
-/*********************************************************
-* PAGE HELPERS
-*********************************************************/
-
-function fetch_from_api(endpoint_name, params, callback) {
- 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_last_updated.formatted);
- });
-}
-
-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);
-}
-
-function show_error(html) {
- $('#error-overlay').html(html).show();
-}
-
-function hide_error() {
- $('#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>');
-});
/*********************************************************
* FORWARD/REVERSE SEARCH PAGE
-jQuery(document).ready(function(){
- hide_error();
-});
-
-
jQuery(document).ready(function(){
});
-/*********************************************************
-* DETAILS PAGE
-*********************************************************/
-
-
-
-function init_map_on_detail_page(lat, lon, geojson) {
- map = new L.map('map', {
- // center: [nominatim_map_init.lat, nominatim_map_init.lon],
- // zoom: nominatim_map_init.zoom,
- attributionControl: (get_config_value('Map_Tile_Attribution') && get_config_value('Map_Tile_Attribution').length),
- scrollWheelZoom: true, // !L.Browser.touch,
- touchZoom: false,
- });
-
- L.tileLayer(get_config_value('Map_Tile_URL'), {
- // moved to footer
- attribution: (get_config_value('Map_Tile_Attribution') || null ) //'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
- }).addTo(map);
-
- var layerGroup = new L.layerGroup().addTo(map);
-
- var circle = L.circleMarker([lat,lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75});
- map.addLayer(circle);
- if (geojson) {
- var geojson_layer = L.geoJson(
- // http://leafletjs.com/reference-1.0.3.html#path-option
- parse_and_normalize_geojson_string(geojson),
- {
- style: function(feature) {
- return { interactive: false, color: 'blue' };
- }
- }
- );
- map.addLayer(geojson_layer);
- map.fitBounds(geojson_layer.getBounds());
- } else {
- map.setView([lat,lon],10);
- }
-
- var osm2 = new L.TileLayer(get_config_value('Map_Tile_URL'), {minZoom: 0, maxZoom: 13, attribution: (get_config_value('Map_Tile_Attribution') || null )});
- var miniMap = new L.Control.MiniMap(osm2, {toggleDisplay: true}).addTo(map);
-}
-
-jQuery(document).ready(function(){
-
- if ( !$('#details-page').length ){ return; }
-
- var search_params = new URLSearchParams(location.search);
- // var place_id = search_params.get('place_id');
-
- var api_request_params = {
- place_id: search_params.get('place_id'),
- place_id: search_params.get('osmtype'),
- place_id: search_params.get('osmid'),
- group_parents: 1,
- format: 'json'
- };
-
- fetch_from_api('details', api_request_params, function(aFeature){
-
- var context = { aPlace: aFeature };
-
- render_template($('main'), 'detailspage-template', context);
-
- update_data_date();
-
- init_map_on_detail_page(aFeature.lat, aFeature.lon, aFeature.asgeojson);
- });
-});