@@ -1,74 +1,21 @@
2− _ _ _
2+ * searx is free software: you can redistribute it and/or modify
3−| |__ ___ ___ | |_ ___| |_ _ __ __ ___ __
3+ * it under the terms of the GNU Affero General Public License as published by
4−| '_ \ / _ \ / _ \| __/ __| __| '__/ _` \ \/ /
4+ * the Free Software Foundation, either version 3 of the License, or
5−| |_) | (_) | (_) | |_\__ | |_| | | (_| |> <
5+ * (at your option) any later version.
6−|_.__/ \___/ \___/ \__|___/\__|_| \__,_/_/\_\.js
6+ *
7−
7+ * searx is distributed in the hope that it will be useful,
8+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
9+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+ * GNU Affero General Public License for more details.
12+ * You should have received a copy of the GNU Affero General Public License
13+ * along with searx. If not, see < http://www.gnu.org/licenses/ >.
15+ * (C) 2014 by Thomas Pointhuber, <thomas.pointhuber@gmx.at>
11−baseUrl: '/static/oscar/js',
17−if(searx.autocompleter) {
18− searx.searchResults = new Bloodhound({
19− datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
20− queryTokenizer: Bloodhound.tokenizers.whitespace,
21− remote: '/autocompleter?q=%QUERY'
23− searx.searchResults.initialize();
26$(document).ready(function(){
18$(document).ready(function(){
27− $('.btn-toggle .btn').click(function() {
28− var btnClass = 'btn-' + $(this).data('btn-class');
29− var btnLabelDefault = $(this).data('btn-label-default');
30− var btnLabelToggled = $(this).data('btn-label-toggled');
31− if(btnLabelToggled != '') {
32− if($(this).hasClass('btn-default')) {
34− var html = $(this).html().replace(btnLabelDefault, btnLabelToggled);
36− var html = $(this).html().replace(btnLabelToggled, btnLabelDefault);
40− $(this).toggleClass(btnClass);
41− $(this).toggleClass('btn-default');
44− $('.btn-collapse').click(function() {
45− var btnTextCollapsed = $(this).data('btn-text-collapsed');
46− var btnTextNotCollapsed = $(this).data('btn-text-not-collapsed');
48− if(btnTextCollapsed != '' && btnTextNotCollapsed != '') {
49− if($(this).hasClass('collapsed')) {
50− var html = $(this).html().replace(btnTextCollapsed, btnTextNotCollapsed);
52− var html = $(this).html().replace(btnTextNotCollapsed, btnTextCollapsed);
58− $(".select-all-on-click").click(function () {
62− if(searx.autocompleter) {
63− $('#q').typeahead(null, {
64− name: 'search-results',
65− displayKey: function(result) {
68− source: searx.searchResults.ttAdapter()
72 $(".searx_overpass_request").on( "click", function( event ) {
19 $(".searx_overpass_request").on( "click", function( event ) {
73 var overpass_url = "https://overpass-api.de/api/interpreter?data=";
20 var overpass_url = "https://overpass-api.de/api/interpreter?data=";
74 var query_start = overpass_url + "[out:json][timeout:25];(";
21 var query_start = overpass_url + "[out:json][timeout:25];(";
@@ -80,7 +27,7 @@ $(document).ready(function(){
80 var result_table_loadicon = "#" + $(this).data('result-table-loadicon');
27 var result_table_loadicon = "#" + $(this).data('result-table-loadicon');
82 // tags which can be ignored
29 // tags which can be ignored
83− var osm_ignore_tags = [ "addr:city", "addr:country", "addr:housenumber", "addr:postcode", "addr:street" ]
30+ var osm_ignore_tags = [ "addr:city", "addr:country", "addr:housenumber", "addr:postcode", "addr:street" ];
85 if(osm_id && osm_type && result_table) {
32 if(osm_id && osm_type && result_table) {
86 result_table = "#" + result_table;
33 result_table = "#" + result_table;
@@ -102,11 +49,11 @@ $(document).ready(function(){
102 //alert(query);
49 //alert(query);
103 var ajaxRequest = $.ajax( query )
50 var ajaxRequest = $.ajax( query )
104 .done(function( html) {
51 .done(function( html) {
105− if(html && html['elements'] && html['elements'][0]) {
52+ if(html && html.elements && html.elements[0]) {
106− var element = html['elements'][0];
53+ var element = html.elements[0];
107 var newHtml = $(result_table).html();
54 var newHtml = $(result_table).html();
108 for (var row in element.tags) {
55 for (var row in element.tags) {
109− if(element.tags["name"] == null || osm_ignore_tags.indexOf(row) == -1) {
56+ if(element.tags.name === null || osm_ignore_tags.indexOf(row) == -1) {
110 newHtml += "<tr><td>" + row + "</td><td>";
57 newHtml += "<tr><td>" + row + "</td><td>";
111 switch(row) {
58 switch(row) {
112 case "phone":
59 case "phone":
@@ -125,11 +72,12 @@ $(document).ready(function(){
126 case "wikipedia":
73 case "wikipedia":
127 if(element.tags[row].indexOf(":") != -1) {
74 if(element.tags[row].indexOf(":") != -1) {
128− newHtml += "<a href=\"https://" + element.tags[row].substring(0,element.tags[row].indexOf(":")) + ".wikipedia.org/wiki/"
75+ 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>";
129− + element.tags[row].substring(element.tags[row].indexOf(":")+1) + "\">" + element.tags[row] + "</a>";
78+ /* jshint ignore:start */
80+ /* jshint ignore:end */
133 newHtml += element.tags[row];
81 newHtml += element.tags[row];
@@ -143,7 +91,7 @@ $(document).ready(function(){
144 .fail(function() {
92 .fail(function() {
145 $(result_table_loadicon).html($(result_table_loadicon).html() + "<p class=\"text-muted\">could not load data!</p>");
93 $(result_table_loadicon).html($(result_table_loadicon).html() + "<p class=\"text-muted\">could not load data!</p>");
@@ -158,12 +106,12 @@ $(document).ready(function(){
158 var map_zoom = $(this).data('map-zoom');
106 var map_zoom = $(this).data('map-zoom');
159 var map_boundingbox = $(this).data('map-boundingbox');
107 var map_boundingbox = $(this).data('map-boundingbox');
160 var map_geojson = $(this).data('map-geojson');
108 var map_geojson = $(this).data('map-geojson');
162 require(['leaflet-0.7.3.min'], function(leaflet) {
110 require(['leaflet-0.7.3.min'], function(leaflet) {
163 if(map_boundingbox) {
111 if(map_boundingbox) {
164− var southWest = L.latLng(map_boundingbox[0], map_boundingbox[2]),
112+ southWest = L.latLng(map_boundingbox[0], map_boundingbox[2]);
165− northEast = L.latLng(map_boundingbox[1], map_boundingbox[3]),
113+ northEast = L.latLng(map_boundingbox[1], map_boundingbox[3]);
166− map_bounds = L.latLngBounds(southWest, northEast);
114+ map_bounds = L.latLngBounds(southWest, northEast);
169 // TODO hack
117 // TODO hack