|
|
@ -68,6 +68,88 @@ $(document).ready(function(){
|
|
|
|
source: searx.searchResults.ttAdapter()
|
|
|
|
source: searx.searchResults.ttAdapter()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".searx_overpass_request").on( "click", function( event ) {
|
|
|
|
|
|
|
|
var overpass_url = "http://overpass-api.de/api/interpreter?data=";
|
|
|
|
|
|
|
|
var query_start = overpass_url + "[out:json][timeout:25];(";
|
|
|
|
|
|
|
|
var query_end = ");out meta;";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var osm_id = $(this).data('osm-id');
|
|
|
|
|
|
|
|
var osm_type = $(this).data('osm-type');
|
|
|
|
|
|
|
|
var result_table = $(this).data('result-table');
|
|
|
|
|
|
|
|
var result_table_loadicon = "#" + $(this).data('result-table-loadicon');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tags which can be ignored
|
|
|
|
|
|
|
|
var osm_ignore_tags = [ "addr:city", "addr:country", "addr:housenumber", "addr:postcode", "addr:street" ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(osm_id && osm_type && result_table) {
|
|
|
|
|
|
|
|
result_table = "#" + result_table;
|
|
|
|
|
|
|
|
var query = null;
|
|
|
|
|
|
|
|
switch(osm_type) {
|
|
|
|
|
|
|
|
case 'node':
|
|
|
|
|
|
|
|
query = query_start + "node(" + osm_id + ");" + query_end;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'way':
|
|
|
|
|
|
|
|
query = query_start + "way(" + osm_id + ");" + query_end;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'relation':
|
|
|
|
|
|
|
|
query = query_start + "relation(" + osm_id + ");" + query_end;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(query) {
|
|
|
|
|
|
|
|
//alert(query);
|
|
|
|
|
|
|
|
var ajaxRequest = $.ajax( query )
|
|
|
|
|
|
|
|
.done(function( html) {
|
|
|
|
|
|
|
|
if(html && html['elements'] && html['elements'][0]) {
|
|
|
|
|
|
|
|
var element = html['elements'][0];
|
|
|
|
|
|
|
|
var newHtml = $(result_table).html();
|
|
|
|
|
|
|
|
for (var row in element.tags) {
|
|
|
|
|
|
|
|
if(element.tags["name"] == null || osm_ignore_tags.indexOf(row) == -1) {
|
|
|
|
|
|
|
|
newHtml += "<tr><td>" + row + "</td><td>";
|
|
|
|
|
|
|
|
switch(row) {
|
|
|
|
|
|
|
|
case "phone":
|
|
|
|
|
|
|
|
case "fax":
|
|
|
|
|
|
|
|
newHtml += "<a href=\"tel:" + element.tags[row].replace(/ /g,'') + "\">" + element.tags[row] + "</a>";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "email":
|
|
|
|
|
|
|
|
newHtml += "<a href=\"mailto:" + element.tags[row] + "\">" + element.tags[row] + "</a>";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "website":
|
|
|
|
|
|
|
|
case "url":
|
|
|
|
|
|
|
|
newHtml += "<a href=\"" + element.tags[row] + "\">" + element.tags[row] + "</a>";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "wikidata":
|
|
|
|
|
|
|
|
newHtml += "<a href=\"https://www.wikidata.org/wiki/" + element.tags[row] + "\">" + element.tags[row] + "</a>";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "wikipedia":
|
|
|
|
|
|
|
|
if(element.tags[row].indexOf(":") != -1) {
|
|
|
|
|
|
|
|
newHtml += "<a href=\"https://" + element.tags[row].substring(0,element.tags[row].indexOf(":")) + ".wikipedia.org/wiki/"
|
|
|
|
|
|
|
|
+ element.tags[row].substring(element.tags[row].indexOf(":")+1) + "\">" + element.tags[row] + "</a>";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
newHtml += element.tags[row];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
newHtml += "</td></tr>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$(result_table).html(newHtml);
|
|
|
|
|
|
|
|
$(result_table).removeClass('hidden');
|
|
|
|
|
|
|
|
$(result_table_loadicon).addClass('hidden');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.fail(function() {
|
|
|
|
|
|
|
|
alert( "could not load " );
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this event occour only once per element
|
|
|
|
|
|
|
|
$( this ).off( event );
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(".searx_init_map").on( "click", function( event ) {
|
|
|
|
$(".searx_init_map").on( "click", function( event ) {
|
|
|
|
var leaflet_target = $(this).data('leaflet-target');
|
|
|
|
var leaflet_target = $(this).data('leaflet-target');
|
|
|
@ -119,7 +201,7 @@ $(document).ready(function(){
|
|
|
|
map.setView(new L.LatLng(map_lat, map_lon),8);
|
|
|
|
map.setView(new L.LatLng(map_lat, map_lon),8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
map.addLayer(osmMapnik);
|
|
|
|
map.addLayer(osmMapquest);
|
|
|
|
|
|
|
|
|
|
|
|
var baseLayers = {
|
|
|
|
var baseLayers = {
|
|
|
|
"OSM Mapnik": osmMapnik,
|
|
|
|
"OSM Mapnik": osmMapnik,
|
|
|
|