@@ -1,74 +1,21 @@
11/**
2− _ _ _
3−| |__ ___ ___ | |_ ___| |_ _ __ __ ___ __
4−| '_ \ / _ \ / _ \| __/ __| __| '__/ _` \ \/ /
5−| |_) | (_) | (_) | |_\__ | |_| | | (_| |> <
6−|_.__/ \___/ \___/ \__|___/\__|_| \__,_/_/\_\.js
7−
8−*/
9−
10−requirejs.config({
11−baseUrl: '/static/oscar/js',
12−paths: {
13−app: '../app'
14−}
15−});
16−
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'
22− });
23− searx.searchResults.initialize();
24−}
2+ * searx is free software: you can redistribute it and/or modify
3+ * it under the terms of the GNU Affero General Public License as published by
4+ * the Free Software Foundation, either version 3 of the License, or
5+ * (at your option) any later version.
6+ *
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.
11+ *
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/ >.
14+ *
15+ * (C) 2014 by Thomas Pointhuber, <thomas.pointhuber@gmx.at>
16+ */
2517
2618$(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')) {
33−
34− var html = $(this).html().replace(btnLabelDefault, btnLabelToggled);
35− } else {
36− var html = $(this).html().replace(btnLabelToggled, btnLabelDefault);
37− }
38− $(this).html(html);
39− }
40− $(this).toggleClass(btnClass);
41− $(this).toggleClass('btn-default');
42− });
43−
44− $('.btn-collapse').click(function() {
45− var btnTextCollapsed = $(this).data('btn-text-collapsed');
46− var btnTextNotCollapsed = $(this).data('btn-text-not-collapsed');
47−
48− if(btnTextCollapsed != '' && btnTextNotCollapsed != '') {
49− if($(this).hasClass('collapsed')) {
50− var html = $(this).html().replace(btnTextCollapsed, btnTextNotCollapsed);
51− } else {
52− var html = $(this).html().replace(btnTextNotCollapsed, btnTextCollapsed);
53− }
54− $(this).html(html);
55− }
56− });
57−
58− $(".select-all-on-click").click(function () {
59− $(this).select();
60− });
61−
62− if(searx.autocompleter) {
63− $('#q').typeahead(null, {
64− name: 'search-results',
65− displayKey: function(result) {
66− return result;
67− },
68− source: searx.searchResults.ttAdapter()
69− });
70− }
71−
7219 $(".searx_overpass_request").on( "click", function( event ) {
7320 var overpass_url = "https://overpass-api.de/api/interpreter?data=";
7421 var query_start = overpass_url + "[out:json][timeout:25];(";
@@ -80,7 +27,7 @@ $(document).ready(function(){
8027 var result_table_loadicon = "#" + $(this).data('result-table-loadicon');
8128
8229 // 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" ];
8431
8532 if(osm_id && osm_type && result_table) {
8633 result_table = "#" + result_table;
@@ -102,11 +49,11 @@ $(document).ready(function(){
10249 //alert(query);
10350 var ajaxRequest = $.ajax( query )
10451 .done(function( html) {
105− if(html && html['elements'] && html['elements'][0]) {
106− var element = html['elements'][0];
52+ if(html && html.elements && html.elements[0]) {
53+ var element = html.elements[0];
10754 var newHtml = $(result_table).html();
10855 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) {
11057 newHtml += "<tr><td>" + row + "</td><td>";
11158 switch(row) {
11259 case "phone":
@@ -125,11 +72,12 @@ $(document).ready(function(){
12572 break;
12673 case "wikipedia":
12774 if(element.tags[row].indexOf(":") != -1) {
128− newHtml += "<a href=\"https://" + element.tags[row].substring(0,element.tags[row].indexOf(":")) + ".wikipedia.org/wiki/"
129− + element.tags[row].substring(element.tags[row].indexOf(":")+1) + "\">" + element.tags[row] + "</a>";
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>";
13076 break;
13177 }
78+ /* jshint ignore:start */
13279 default:
80+ /* jshint ignore:end */
13381 newHtml += element.tags[row];
13482 break;
13583 }
@@ -143,7 +91,7 @@ $(document).ready(function(){
14391 })
14492 .fail(function() {
14593 $(result_table_loadicon).html($(result_table_loadicon).html() + "<p class=\"text-muted\">could not load data!</p>");
146− })
94+ });
14795 }
14896 }
14997
@@ -158,12 +106,12 @@ $(document).ready(function(){
158106 var map_zoom = $(this).data('map-zoom');
159107 var map_boundingbox = $(this).data('map-boundingbox');
160108 var map_geojson = $(this).data('map-geojson');
161−
109+
162110 require(['leaflet-0.7.3.min'], function(leaflet) {
163111 if(map_boundingbox) {
164− var southWest = L.latLng(map_boundingbox[0], map_boundingbox[2]),
165− northEast = L.latLng(map_boundingbox[1], map_boundingbox[3]),
166− map_bounds = L.latLngBounds(southWest, northEast);
112+ southWest = L.latLng(map_boundingbox[0], map_boundingbox[2]);
113+ northEast = L.latLng(map_boundingbox[1], map_boundingbox[3]);
114+ map_bounds = L.latLngBounds(southWest, northEast);
167115 }
168116
169117 // TODO hack