1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-18 02:10:12 +01:00
searxng/searx/static/themes/oscar/js/searx.min.js
2021-04-24 06:58:22 +02:00

4 lines
7.6 KiB
JavaScript

/*! oscar/searx.min.js | 22-04-2021 | */
window.searx=function(t){"use strict";t.getElementsByTagName("html")[0].className="js";var e,e=t.currentScript||(e=t.getElementsByTagName("script"))[e.length-1];return{autocompleter:"true"===e.getAttribute("data-autocompleter"),method:e.getAttribute("data-method"),translations:JSON.parse(e.getAttribute("data-translations"))}}(document),$(document).ready(function(){var t,a="";searx.autocompleter&&((t=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("value"),queryTokenizer:Bloodhound.tokenizers.whitespace,remote:{url:"./autocompleter?q=%QUERY",wildcard:"%QUERY"}})).initialize(),$("#q").on("keydown",function(t){13==t.which&&(a=$("#q").val())}),$("#q").typeahead({name:"search-results",highlight:!1,hint:!0,displayKey:function(t){return t},classNames:{input:"tt-input",hint:"tt-hint",menu:"tt-dropdown-menu",dataset:"tt-dataset-search-results"}},{name:"autocomplete",source:t}),$("#q").bind("typeahead:select",function(t,e){a&&$("#q").val(a),$("#search_form").submit()}))}),$(document).ready(function(){$("#q.autofocus").focus(),$("#clear_search").click(function(){document.getElementById("q").value=""}),$(".select-all-on-click").click(function(){$(this).select()}),$(".btn-collapse").click(function(){var t=$(this).data("btn-text-collapsed"),e=$(this).data("btn-text-not-collapsed");""!==t&&""!==e&&(new_html=$(this).hasClass("collapsed")?$(this).html().replace(t,e):$(this).html().replace(e,t),$(this).html(new_html))}),$(".btn-toggle .btn").click(function(){var t="btn-"+$(this).data("btn-class"),e=$(this).data("btn-label-default"),a=$(this).data("btn-label-toggled");""!==a&&(new_html=$(this).hasClass("btn-default")?$(this).html().replace(e,a):$(this).html().replace(a,e),$(this).html(new_html)),$(this).toggleClass(t),$(this).toggleClass("btn-default")}),$(".media-loader").click(function(){var t=$(this).data("target"),e=$(t+" > iframe"),t=e.attr("src");void 0!==t&&!1!==t||e.attr("src",e.data("src"))}),$(".btn-sm").dblclick(function(){var t="btn-"+$(this).data("btn-class");$(this).hasClass("btn-default")?($(".btn-sm > input").attr("checked","checked"),$(".btn-sm > input").prop("checked",!0),$(".btn-sm").addClass(t),$(".btn-sm").addClass("active"),$(".btn-sm").removeClass("btn-default")):($(".btn-sm > input").attr("checked",""),$(".btn-sm > input").removeAttr("checked"),$(".btn-sm > input").checked=!1,$(".btn-sm").removeClass(t),$(".btn-sm").removeClass("active"),$(".btn-sm").addClass("btn-default"))}),$(".nav-tabs").click(function(t){$(t.target).parents("ul").children().attr("aria-selected","false"),$(t.target).parent().attr("aria-selected","true")}),searx.image_thumbnail_layout=new searx.ImageLayout("#main_results","#main_results .result-images","img.img-thumbnail",15,200),searx.image_thumbnail_layout.watch()}),window.addEventListener("load",function(){$(".infobox").each(function(){var t=$(this).find(".infobox_body");t.prop("scrollHeight")+t.find("img.infobox_part").height()<=t.css("max-height").replace("px","")&&$(this).find(".infobox_toggle").hide()})}),$(document).ready(function(){$(".searx_overpass_request").on("click",function(t){var e="https://overpass-api.de/api/interpreter?data=[out:json][timeout:25];(",a=");out meta;",s=$(this).data("osm-id"),i=$(this).data("osm-type"),n=$(this).data("result-table"),o="#"+$(this).data("result-table-loadicon"),r=["addr:city","addr:country","addr:housenumber","addr:postcode","addr:street"];if(s&&i&&n){var n="#"+n,l=null;switch(i){case"node":l=e+"node("+s+");"+a;break;case"way":l=e+"way("+s+");"+a;break;case"relation":l=e+"relation("+s+");"+a}l&&$.ajax(l).done(function(t){if(t&&t.elements&&t.elements[0]){var e,a=t.elements[0],s=$(n).html();for(e in a.tags)if(null===a.tags.name||-1==r.indexOf(e)){switch(s+="<tr><td>"+e+"</td><td>",e){case"phone":case"fax":s+='<a href="tel:'+a.tags[e].replace(/ /g,"")+'">'+a.tags[e]+"</a>";break;case"email":s+='<a href="mailto:'+a.tags[e]+'">'+a.tags[e]+"</a>";break;case"website":case"url":s+='<a href="'+a.tags[e]+'">'+a.tags[e]+"</a>";break;case"wikidata":s+='<a href="https://www.wikidata.org/wiki/'+a.tags[e]+'">'+a.tags[e]+"</a>";break;case"wikipedia":if(-1!=a.tags[e].indexOf(":")){s+='<a href="https://'+a.tags[e].substring(0,a.tags[e].indexOf(":"))+".wikipedia.org/wiki/"+a.tags[e].substring(a.tags[e].indexOf(":")+1)+'">'+a.tags[e]+"</a>";break}default:s+=a.tags[e]}s+="</td></tr>"}$(n).html(s),$(n).removeClass("hidden"),$(o).addClass("hidden")}}).fail(function(){$(o).html($(o).html()+'<p class="text-muted">'+searx.translations.could_not_load+"</p>")})}$(this).off(t)}),$(".searx_init_map").on("click",function(t){var e=$(this).data("leaflet-target"),a=$(this).data("map-lon"),s=$(this).data("map-lat"),i=$(this).data("map-zoom"),n=$(this).data("map-boundingbox"),o=$(this).data("map-geojson");n&&(southWest=L.latLng(n[0],n[2]),northEast=L.latLng(n[1],n[3]),map_bounds=L.latLngBounds(southWest,northEast)),L.Icon.Default.imagePath="./static/themes/oscar/css/images/";var r=L.map(e),e=new L.TileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{minZoom:1,maxZoom:19,attribution:'Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors'});new L.TileLayer("https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png",{minZoom:1,maxZoom:19,attribution:'Wikimedia maps beta | Maps data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors'});setTimeout(function(){map_bounds?r.fitBounds(map_bounds,{maxZoom:17}):a&&s&&(i?r.setView(new L.LatLng(s,a),i):r.setView(new L.LatLng(s,a),8))},0),r.addLayer(e),L.control.layers({"OSM Mapnik":e}).addTo(r),o&&L.geoJson(o).addTo(r),$(this).off(t)})}),$(document).ready(function(){$("#allow-all-engines").click(function(){$(".onoffswitch-checkbox").each(function(){this.checked=!1})}),$("#disable-all-engines").click(function(){$(".onoffswitch-checkbox").each(function(){this.checked=!0})})}),function(o,c){function t(t,e,a,s,i){this.container_selector=t,this.results_selector=e,this.img_selector=a,this.margin=s,this.maxHeight=i,this.isAlignDone=!0}t.prototype._getHeigth=function(t,e){for(var a,s=0,i=0;i<t.length;i++)0<(a=t[i]).naturalWidth&&0<a.naturalHeight?s+=a.naturalWidth/a.naturalHeight:s+=1;return(e-t.length*this.margin)/s},t.prototype._setSize=function(t,e){for(var a,s,i=t.length,n=0;n<i;n++)a=0<(s=t[n]).naturalWidth&&0<s.naturalHeight?e*s.naturalWidth/s.naturalHeight:e,s.style.width=a+"px",s.style.height=e+"px",s.style.marginLeft="3px",s.style.marginTop="3px",s.style.marginRight=this.margin-7+"px",s.style.marginBottom=this.margin-7+"px",(s=s.parentNode.parentNode).classList.contains("js")||s.classList.add("js")},t.prototype._alignImgs=function(t){for(var e,a,s,i,n=c.querySelector(this.container_selector),o=window.getComputedStyle(n),r=parseInt(o.getPropertyValue("padding-left"),10),o=parseInt(o.getPropertyValue("padding-right"),10),l=n.clientWidth-r-o;0<t.length;){for(e=!0,s=1;s<=t.length&&e;s++)a=t.slice(0,s),(i=this._getHeigth(a,l))<this.maxHeight&&(this._setSize(a,i),t=t.slice(s),e=!1);if(e){this._setSize(a,Math.min(this.maxHeight,i));break}}},t.prototype.align=function(){for(var t=c.querySelectorAll(this.results_selector),e=t.length,a=null,s=null,i=[],n=0;n<e;n++)(s=t[n]).previousElementSibling!==a&&0<i.length&&(this._alignImgs(i),i=[]),i.push(s.querySelector(this.img_selector)),a=s;0<i.length&&this._alignImgs(i)},t.prototype.watch=function(){var t,e,a=this,s=c.querySelectorAll(this.results_selector),i=s.length;function n(){a.isAlignDone&&(a.isAlignDone=!1,setTimeout(function(){a.align(),a.isAlignDone=!0},100))}for(o.addEventListener("pageshow",n),o.addEventListener("load",n),o.addEventListener("resize",n),t=0;t<i;t++)null!=(e=s[t].querySelector(this.img_selector))&&(e.addEventListener("load",n),e.addEventListener("error",n))},o.searx.ImageLayout=t}(window,document);
//# sourceMappingURL=searx.min.js.map