forked from zaclys/searxng
25 lines
23 KiB
JavaScript
25 lines
23 KiB
JavaScript
/*! simple/searx.min.js | 28-05-2019 | https://github.com/asciimoo/searx */
|
||
|
||
(function(t,a,o){"use strict";if(t.Element){(function(e){e.matches=e.matches||e.matchesSelector||e.webkitMatchesSelector||e.msMatchesSelector||function(e){var t=this,n=(t.parentNode||t.document).querySelectorAll(e),i=-1;while(n[++i]&&n[i]!=t);return!!n[i]}})(Element.prototype)}function s(e,t,n){try{e.call(t,n)}catch(e){console.log(e)}}o=o||{};o.on=function(i,e,r,t){t=t||false;if(typeof i!=="string"){i.addEventListener(e,r,t)}else{a.addEventListener(e,function(e){var t=e.target||e.srcElement,n=false;while(t&&t.matches&&t!==a&&!(n=t.matches(i)))t=t.parentElement;if(n)s(r,t,e)},t)}};o.ready=function(e){if(document.readyState!="loading"){e.call(t)}else{t.addEventListener("DOMContentLoaded",e.bind(t))}};o.http=function(e,t,n){var i=new XMLHttpRequest,r=function(){},a=function(){},o={then:function(e){r=e;return o},catch:function(e){a=e;return o}};try{i.open(e,t,true);i.onload=function(){if(i.status==200){r(i.response,i.responseType)}else{a(Error(i.statusText))}};i.onerror=function(){a(Error("Network Error"))};i.onabort=function(){a(Error("Transaction is aborted"))};i.send()}catch(e){a(e)}return o};o.loadStyle=function(e){var t=o.staticPath+e,n="style_"+e.replace(".","_"),i=a.getElementById(n);if(i===null){i=a.createElement("link");i.setAttribute("id",n);i.setAttribute("rel","stylesheet");i.setAttribute("type","text/css");i.setAttribute("href",t);a.body.appendChild(i)}};o.loadScript=function(e,t){var n=o.staticPath+e,i="script_"+e.replace(".","_"),r=a.getElementById(i);if(r===null){r=a.createElement("script");r.setAttribute("id",i);r.setAttribute("src",n);r.onload=t;r.onerror=function(){r.setAttribute("error","1")};a.body.appendChild(r)}else if(!r.hasAttribute("error")){try{t.apply(r,[])}catch(e){console.log(e)}}else{console.log("callback not executed : script '"+n+"' not loaded.")}};o.insertBefore=function(e,t){element.parentNode.insertBefore(e,t)};o.insertAfter=function(e,t){t.parentNode.insertBefore(e,t.nextSibling)};o.on(".close","click",function(e){var t=e.target||e.srcElement;this.parentNode.classList.add("invisible")});return o})(window,document,window.searx);(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.AutoComplete=e()}})(function(){var e,t,n;return function a(o,s,l){function u(n,e){if(!s[n]){if(!o[n]){var t=typeof require=="function"&&require;if(!e&&t)return t(n,!0);if(c)return c(n,!0);var i=new Error("Cannot find module '"+n+"'");throw i.code="MODULE_NOT_FOUND",i}var r=s[n]={exports:{}};o[n][0].call(r.exports,function(e){var t=o[n][1][e];return u(t?t:e)},r,r.exports,a,o,s,l)}return s[n].exports}var c=typeof require=="function"&&require;for(var e=0;e<l.length;e++)u(l[e]);return u}({1:[function(e,t,n){
|
||
/*
|
||
* @license MIT
|
||
*
|
||
* Autocomplete.js v2.6.3
|
||
* Developed by Baptiste Donaux
|
||
* http://autocomplete-js.com
|
||
*
|
||
* (c) 2017, Baptiste Donaux
|
||
*/
|
||
"use strict";var l;(function(e){e[e["AND"]=0]="AND";e[e["OR"]=1]="OR"})(l||(l={}));var a;(function(e){e[e["KEYDOWN"]=0]="KEYDOWN";e[e["KEYUP"]=1]="KEYUP"})(a||(a={}));var i=function(){function s(t,e){if(t===void 0){t={}}if(e===void 0){e="[data-autocomplete]"}if(Array.isArray(e)){e.forEach(function(e){new s(t,e)})}else if(typeof e=="string"){var n=document.querySelectorAll(e);Array.prototype.forEach.call(n,function(e){new s(t,e)})}else{var i=s.merge(s.defaults,t,{DOMResults:document.createElement("div")});s.prototype.create(i,e);return i}}s.prototype.create=function(e,t){e.Input=t;if(e.Input.nodeName.match(/^INPUT$/i)&&(e.Input.hasAttribute("type")===false||e.Input.getAttribute("type").match(/^TEXT|SEARCH$/i))){e.Input.setAttribute("autocomplete","off");e._Position(e);e.Input.parentNode.appendChild(e.DOMResults);e.$Listeners={blur:e._Blur.bind(e),destroy:s.prototype.destroy.bind(null,e),focus:e._Focus.bind(e),keyup:s.prototype.event.bind(null,e,a.KEYUP),keydown:s.prototype.event.bind(null,e,a.KEYDOWN),position:e._Position.bind(e)};for(var n in e.$Listeners){e.Input.addEventListener(n,e.$Listeners[n])}}};s.prototype.getEventsByType=function(e,t){var n={};for(var i in e.KeyboardMappings){var r=a.KEYUP;if(e.KeyboardMappings[i].Event!==undefined){r=e.KeyboardMappings[i].Event}if(r==t){n[i]=e.KeyboardMappings[i]}}return n};s.prototype.event=function(e,t,n){var i=function(e){if(o===true&&a.Operator==l.AND||o===false&&a.Operator==l.OR){e=s.merge({Not:false},e);if(e.hasOwnProperty("Is")){if(e.Is==n.keyCode){o=!e.Not}else{o=e.Not}}else if(e.hasOwnProperty("From")&&e.hasOwnProperty("To")){if(n.keyCode>=e.From&&n.keyCode<=e.To){o=!e.Not}else{o=e.Not}}}};for(var r in s.prototype.getEventsByType(e,t)){var a=s.merge({Operator:l.AND},e.KeyboardMappings[r]),o=l.AND==a.Operator;a.Conditions.forEach(i);if(o===true){a.Callback.call(e,n)}}};s.prototype.makeRequest=function(e,t){var n=Object.getOwnPropertyNames(e.HttpHeaders),i=new XMLHttpRequest,r=e._HttpMethod(),a=e._Url(),o=e._Pre(),s=encodeURIComponent(e._QueryArg())+"="+encodeURIComponent(o);if(r.match(/^GET$/i)){if(a.indexOf("?")!==-1){a+="&"+s}else{a+="?"+s}}i.open(r,a,true);for(var l=n.length-1;l>=0;l--){i.setRequestHeader(n[l],e.HttpHeaders[n[l]])}i.onreadystatechange=function(){if(i.readyState==4&&i.status==200){e.$Cache[o]=i.response;t(i.response)}};return i};s.prototype.ajax=function(e,t,n){if(n===void 0){n=true}if(e.$AjaxTimer){window.clearTimeout(e.$AjaxTimer)}if(n===true){e.$AjaxTimer=window.setTimeout(s.prototype.ajax.bind(null,e,t,false),e.Delay)}else{if(e.Request){e.Request.abort()}e.Request=t;e.Request.send(e._QueryArg()+"="+e._Pre())}};s.prototype.cache=function(e,t){var n=e._Cache(e._Pre());if(n===undefined){var i=s.prototype.makeRequest(e,t);s.prototype.ajax(e,i)}else{t(n)}};s.prototype.destroy=function(e){for(var t in e.$Listeners){e.Input.removeEventListener(t,e.$Listeners[t])}e.DOMResults.parentNode.removeChild(e.DOMResults)};return s}();i.merge=function(){var e={},t;for(var n=0;n<arguments.length;n++){for(t in arguments[n]){e[t]=arguments[n][t]}}return e};i.defaults={Delay:150,EmptyMessage:"No result here",Highlight:{getRegex:function(e){return new RegExp(e,"ig")},transform:function(e){return"<strong>"+e+"</strong>"}},HttpHeaders:{"Content-type":"application/x-www-form-urlencoded"},Limit:0,MinChars:0,HttpMethod:"GET",QueryArg:"q",Url:null,KeyboardMappings:{Enter:{Conditions:[{Is:13,Not:false}],Callback:function(e){if(this.DOMResults.getAttribute("class").indexOf("open")!=-1){var t=this.DOMResults.querySelector("li.active");if(t!==null){e.preventDefault();this._Select(t);this.DOMResults.setAttribute("class","autocomplete")}}},Operator:l.AND,Event:a.KEYDOWN},KeyUpAndDown_down:{Conditions:[{Is:38,Not:false},{Is:40,Not:false}],Callback:function(e){e.preventDefault()},Operator:l.OR,Event:a.KEYDOWN},KeyUpAndDown_up:{Conditions:[{Is:38,Not:false},{Is:40,Not:false}],Callback:function(e){e.preventDefault();var t=this.DOMResults.querySelector("li:first-child:not(.locked)"),n=this.DOMResults.querySelector("li:last-child:not(.locked)"),i=this.DOMResults.querySelector("li.active");if(i){var r=Array.prototype.indexOf.call(i.parentNode.children,i),a=r+(e.keyCode-39),o=this.DOMResults.getElementsByTagName("li").length;if(a<0){a=o-1}else if(a>=o){a=0}i.classList.remove("active");i.parentElement.children.item(a).classList.add("active")}else if(n&&e.keyCode==38){n.classList.add("active")}else if(t){t.classList.add("active")}},Operator:l.OR,Event:a.KEYUP},AlphaNum:{Conditions:[{Is:13,Not:true},{From:35,To:40,Not:true}],Callback:function(){var e=this.Input.getAttribute("data-autocomplete-old-value"),t=this._Pre();if(t!==""&&t.length>=this._MinChars()){if(!e||t!=e){this.DOMResults.setAttribute("class","autocomplete open")}i.prototype.cache(this,function(e){this._Render(this._Post(e));this._Open()}.bind(this))}},Operator:l.AND,Event:a.KEYUP}},DOMResults:null,Request:null,Input:null,_EmptyMessage:function(){var e="";if(this.Input.hasAttribute("data-autocomplete-empty-message")){e=this.Input.getAttribute("data-autocomplete-empty-message")}else if(this.EmptyMessage!==false){e=this.EmptyMessage}else{e=""}return e},_Limit:function(){var e=this.Input.getAttribute("data-autocomplete-limit");if(isNaN(e)||e===null){return this.Limit}return parseInt(e,10)},_MinChars:function(){var e=this.Input.getAttribute("data-autocomplete-minchars");if(isNaN(e)||e===null){return this.MinChars}return parseInt(e,10)},_Highlight:function(e){return e.replace(this.Highlight.getRegex(this._Pre()),this.Highlight.transform)},_HttpMethod:function(){if(this.Input.hasAttribute("data-autocomplete-method")){return this.Input.getAttribute("data-autocomplete-method")}return this.HttpMethod},_QueryArg:function(){if(this.Input.hasAttribute("data-autocomplete-param-name")){return this.Input.getAttribute("data-autocomplete-param-name")}return this.QueryArg},_Url:function(){if(this.Input.hasAttribute("data-autocomplete")){return this.Input.getAttribute("data-autocomplete")}return this.Url},_Blur:function(e){if(e===true){this.DOMResults.setAttribute("class","autocomplete");this.Input.setAttribute("data-autocomplete-old-value",this.Input.value)}else{var t=this;setTimeout(function(){t._Blur(true)},150)}},_Cache:function(e){return this.$Cache[e]},_Focus:function(){var e=this.Input.getAttribute("data-autocomplete-old-value");if((!e||this.Input.value!=e)&&this._MinChars()<=this.Input.value.length){this.DOMResults.setAttribute("class","autocomplete open")}},_Open:function(){var n=this;Array.prototype.forEach.call(this.DOMResults.getElementsByTagName("li"),function(t){if(t.getAttribute("class")!="locked"){t.onclick=function(e){n._Select(t)};t.onmouseenter=function(){var e=n.DOMResults.querySelector("li.active");if(e!==t){if(e!==null){e.classList.remove("active")}t.classList.add("active")}}}})},_Position:function(){this.DOMResults.setAttribute("class","autocomplete");this.DOMResults.setAttribute("style","top:"+(this.Input.offsetTop+this.Input.offsetHeight)+"px;left:"+this.Input.offsetLeft+"px;width:"+this.Input.clientWidth+"px;")},_Render:function(e){var t;if(typeof e=="string"){t=this._RenderRaw(e)}else{t=this._RenderResponseItems(e)}if(this.DOMResults.hasChildNodes()){this.DOMResults.removeChild(this.DOMResults.childNodes[0])}this.DOMResults.appendChild(t)},_RenderResponseItems:function(e){var t=document.createElement("ul"),n=document.createElement("li"),i=this._Limit();if(i<0){e=e.reverse()}else if(i===0){i=e.length}for(var r=0;r<Math.min(Math.abs(i),e.length);r++){n.innerHTML=e[r].Label;n.setAttribute("data-autocomplete-value",e[r].Value);t.appendChild(n);n=document.createElement("li")}return t},_RenderRaw:function(e){var t=document.createElement("ul"),n=document.createElement("li");if(e.length>0){this.DOMResults.innerHTML=e}else{var i=this._EmptyMessage();if(i!==""){n.innerHTML=i;n.setAttribute("class","locked");t.appendChild(n)}}return t},_Post:function(t){try{var e=[];var n=JSON.parse(t);if(Object.keys(n).length===0){return""}if(Array.isArray(n)){for(var i=0;i<Object.keys(n).length;i++){e[e.length]={Value:n[i],Label:this._Highlight(n[i])}}}else{for(var r in n){e.push({Value:r,Label:this._Highlight(n[r])})}}return e}catch(e){return t}},_Pre:function(){return this.Input.value},_Select:function(e){console.log("test test test");if(e.hasAttribute("data-autocomplete-value")){this.Input.value=e.getAttribute("data-autocomplete-value")}else{this.Input.value=e.innerHTML}this.Input.setAttribute("data-autocomplete-old-value",this.Input.value)},$AjaxTimer:null,$Cache:{},$Listeners:{}};t.exports=i},{}]},{},[1])(1)});
|
||
/**
|
||
*
|
||
* Google Image Layout v0.0.1
|
||
* Description, by Anh Trinh.
|
||
* Heavily modified for searx
|
||
* http://trinhtrunganh.com
|
||
*
|
||
* @license Free to use under the MIT License.
|
||
*
|
||
*/
|
||
(function(u,c){"use strict";function e(e,t,n,i){this.container_selector=e;this.results_selector=t;this.img_selector=n;this.margin=10;this.maxHeight=i;this._alignAllDone=true}e.prototype._getHeigth=function(e,t){var n=0,i;t-=e.length*this.margin;for(var r=0;r<e.length;r++){i=e[r];if(i.naturalWidth>0&&i.naturalHeight>0){n+=i.naturalWidth/i.naturalHeight}else{n+=1}}return t/n};e.prototype._setSize=function(e,t){var n,i,r=e.length;for(var a=0;a<r;a++){n=e[a];if(n.naturalWidth>0&&n.naturalHeight>0){i=t*n.naturalWidth/n.naturalHeight}else{i=t}n.style.width=i+"px";n.style.height=t+"px";n.style.marginLeft="3px";n.style.marginTop="3px";n.style.marginRight=this.margin-7+"px";n.style.marginBottom=this.margin-7+"px"}};e.prototype._alignImgs=function(e){var t,n,i=c.querySelector(this.container_selector).clientWidth;e:while(e.length>0){for(var r=1;r<=e.length;r++){t=e.slice(0,r);n=this._getHeigth(t,i);if(n<this.maxHeight){this._setSize(t,n);e=e.slice(r);continue e}}this._setSize(t,Math.min(this.maxHeight,n));break}};e.prototype.align=function(e){var t=c.querySelectorAll(this.results_selector),n=t.length,i=null,r=null,a=[];for(var o=0;o<n;o++){r=t[o];if(r.previousElementSibling!==i&&a.length>0){this._alignImgs(a);a=[]}a.push(r.querySelector(this.img_selector));i=r}if(a.length>0){this._alignImgs(a)}};e.prototype.watch=function(){var e,t,n,i,r=this,a=c.querySelectorAll(this.results_selector),o=a.length;function s(e){r.align()}function l(e){if(r._alignAllDone){r._alignAllDone=false;setTimeout(function(){r.align();r._alignAllDone=true},100)}}u.addEventListener("resize",l);u.addEventListener("pageshow",s);for(e=0;e<o;e++){t=a[e].querySelector(this.img_selector);if(typeof t!=="undefined"){t.addEventListener("load",l);t.addEventListener("error",l)}}};u.searx.ImageLayout=e})(window,document);searx.ready(function(){searx.on(".result","click",function(){n(this)(true)});searx.on(".result a","focus",function(e){var t=e.target;while(t!==undefined){if(t.classList.contains("result")){if(t.getAttribute("data-vim-selected")===null){n(t)(true)}break}t=t.parentNode}},true);var d={27:{key:"Escape",fun:t,des:"remove focus from the focused input",cat:"Control"},73:{key:"i",fun:o,des:"focus on the search input",cat:"Control"},66:{key:"b",fun:r(-window.innerHeight),des:"scroll one page up",cat:"Navigation"},70:{key:"f",fun:r(window.innerHeight),des:"scroll one page down",cat:"Navigation"},85:{key:"u",fun:r(-window.innerHeight/2),des:"scroll half a page up",cat:"Navigation"},68:{key:"d",fun:r(window.innerHeight/2),des:"scroll half a page down",cat:"Navigation"},71:{key:"g",fun:a(-document.body.scrollHeight,"top"),des:"scroll to the top of the page",cat:"Navigation"},86:{key:"v",fun:a(document.body.scrollHeight,"bottom"),des:"scroll to the bottom of the page",cat:"Navigation"},75:{key:"k",fun:n("up"),des:"select previous search result",cat:"Results"},74:{key:"j",fun:n("down"),des:"select next search result",cat:"Results"},80:{key:"p",fun:i(0),des:"go to previous page",cat:"Results"},78:{key:"n",fun:i(1),des:"go to next page",cat:"Results"},79:{key:"o",fun:s(false),des:"open search result",cat:"Results"},84:{key:"t",fun:s(true),des:"open the result in a new tab",cat:"Results"},82:{key:"r",fun:e,des:"reload page from the server",cat:"Control"},72:{key:"h",fun:u,des:"toggle help window",cat:"Other"}};searx.on(document,"keydown",function(e){if(d.hasOwnProperty(e.keyCode)&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey){var t=e.target.tagName.toLowerCase();if(e.keyCode===27){if(t==="input"||t==="select"||t==="textarea"){d[e.keyCode].fun()}}else{if(e.target===document.body||t==="a"||t==="button"){e.preventDefault();d[e.keyCode].fun()}}}});function n(d){return function(e){var t=document.querySelector(".result[data-vim-selected]"),n=d;if(t===null){t=document.querySelector(".result");if(t===null){return}if(d==="down"||d==="up"){n=t}}var i,r=document.querySelectorAll(".result");if(typeof n!=="string"){i=n}else{switch(n){case"visible":var a=document.documentElement.scrollTop||document.body.scrollTop;var o=a+document.documentElement.clientHeight;for(var s=0;s<r.length;s++){i=r[s];var l=i.offsetTop;var u=l+i.clientHeight;if(u<=o&&l>a){break}}break;case"down":i=t.nextElementSibling;if(i===null){i=r[0]}break;case"up":i=t.previousElementSibling;if(i===null){i=r[r.length-1]}break;case"bottom":i=r[r.length-1];break;case"top":default:i=r[0]}}if(i){t.removeAttribute("data-vim-selected");i.setAttribute("data-vim-selected","true");var c=i.querySelector("h3 a")||i.querySelector("a");if(c!==null){c.focus()}if(!e){f()}}}}function e(){document.location.reload(true)}function t(){if(document.activeElement){document.activeElement.blur()}}function i(t){return function(){var e=$('div#pagination button[type="submit"]');if(e.length!==2){console.log("page navigation with this theme is not supported");return}if(t>=0&&t<e.length){e[t].click()}else{console.log("pageButtonClick(): invalid argument")}}}function f(){var e=document.querySelector(".result[data-vim-selected]");if(e===null){return}var t=document.documentElement.scrollTop||document.body.scrollTop,n=document.documentElement.clientHeight,i=e.offsetTop,r=i+e.clientHeight,a=120;if(e.previousElementSibling===null&&r<n){window.scroll(window.scrollX,0);return}if(t>i-a){window.scroll(window.scrollX,i-a)}else{var o=t+n;if(o<r+a){window.scroll(window.scrollX,r-n+a)}}}function r(e){return function(){window.scrollBy(0,e);n("visible")()}}function a(e,t){return function(){window.scrollTo(0,e);n(t)()}}function o(){window.scrollTo(0,0);document.querySelector("#q").focus()}function s(n){return function(){var e=document.querySelector(".result[data-vim-selected] h3 a");if(e!==null){var t=e.getAttribute("href");if(n){window.open(t)}else{window.location.href=t}}}}function l(e){var n={};for(var t in d){var i=d[t];n[i.cat]=n[i.cat]||[];n[i.cat].push(i)}var r=Object.keys(n).sort(function(e,t){return n[t].length-n[e].length});if(r.length===0){return}var a='<a href="#" class="close" aria-label="close" title="close">×</a>';a+="<h3>How to navigate searx with Vim-like hotkeys</h3>";a+="<table>";for(var o=0;o<r.length;o++){var s=n[r[o]];var l=o===r.length-1;var u=o%2===0;if(u){a+="<tr>"}a+="<td>";a+="<h4>"+s[0].cat+"</h4>";a+='<ul class="list-unstyled">';for(var c in s){a+="<li><kbd>"+s[c].key+"</kbd> "+s[c].des+"</li>"}a+="</ul>";a+="</td>";if(!u||l){a+="</tr>"}}a+="</table>";e.innerHTML=a}function u(){var e=document.querySelector("#vim-hotkeys-help");console.log(e);if(e===undefined||e===null){e=document.createElement("div");e.id="vim-hotkeys-help";e.className="dialog-modal";e.style="width: 40%";l(e);var t=document.getElementsByTagName("body")[0];t.appendChild(e)}else{e.classList.toggle("invisible");return}}});(function(e,c,v){"use strict";v.ready(function(){v.on(".searx_overpass_request","click",function(e){this.classList.remove("searx_overpass_request");var t="https://overpass-api.de/api/interpreter?data=";var n=t+"[out:json][timeout:25];(";var i=");out meta;";var r=this.dataset.osmId;var a=this.dataset.osmType;var o=c.querySelector("#"+this.dataset.resultTable);var s=c.querySelector("#"+this.dataset.resultTableLoadicon);var l=["addr:city","addr:country","addr:housenumber","addr:postcode","addr:street"];if(r&&a&&o){var u=null;switch(a){case"node":u=n+"node("+r+");"+i;break;case"way":u=n+"way("+r+");"+i;break;case"relation":u=n+"relation("+r+");"+i;break;default:break}if(u){v.http("GET",u).then(function(e,t){e=JSON.parse(e);if(e&&e.elements&&e.elements[0]){var n=e.elements[0];var i="";for(var r in n.tags){if(n.tags.name===null||l.indexOf(r)==-1){i+="<tr><td>"+r+"</td><td>";switch(r){case"phone":case"fax":i+='<a href="tel:'+n.tags[r].replace(/ /g,"")+'">'+n.tags[r]+"</a>";break;case"email":i+='<a href="mailto:'+n.tags[r]+'">'+n.tags[r]+"</a>";break;case"website":case"url":i+='<a href="'+n.tags[r]+'">'+n.tags[r]+"</a>";break;case"wikidata":i+='<a href="https://www.wikidata.org/wiki/'+n.tags[r]+'">'+n.tags[r]+"</a>";break;case"wikipedia":if(n.tags[r].indexOf(":")!=-1){i+='<a href="https://'+n.tags[r].substring(0,n.tags[r].indexOf(":"))+".wikipedia.org/wiki/"+n.tags[r].substring(n.tags[r].indexOf(":")+1)+'">'+n.tags[r]+"</a>";break}default:i+=n.tags[r];break}i+="</td></tr>"}}s.parentNode.removeChild(s);o.classList.remove("invisible");o.querySelector("tbody").innerHTML=i}}).catch(function(){s.classList.remove("invisible");s.innerHTML="could not load data!"})}}e.preventDefault()});v.on(".searx_init_map","click",function(e){this.classList.remove("searx_init_map");var d=this.dataset.leafletTarget;var f=parseFloat(this.dataset.mapLon);var p=parseFloat(this.dataset.mapLat);var h=parseFloat(this.dataset.mapZoom);var m=JSON.parse(this.dataset.mapBoundingbox);var g=JSON.parse(this.dataset.mapGeojson);v.loadStyle("leaflet/leaflet.css");v.loadScript("leaflet/leaflet.js",function(){var e=null;if(m){var t=L.latLng(m[0],m[2]);var n=L.latLng(m[1],m[3]);e=L.latLngBounds(t,n)}var i=L.map(d);var r="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";var a='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';var o=new L.TileLayer(r,{minZoom:1,maxZoom:19,attribution:a});var s="https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png";var l='Wikimedia maps beta | Maps data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';var u=new L.TileLayer(s,{minZoom:1,maxZoom:19,attribution:l});if(e){setTimeout(function(){i.fitBounds(e,{maxZoom:17})},0)}else if(f&&p){if(h){i.setView(new L.latLng(p,f),h)}else{i.setView(new L.latLng(p,f),8)}}i.addLayer(o);var c={"OSM Mapnik":o};L.control.layers(c).addTo(i);if(g){L.geoJson(g).addTo(i)}});e.preventDefault()})})})(window,document,window.searx);(function(e,o,t){"use strict";t.ready(function(){t.image_thumbnail_layout=new t.ImageLayout("#urls","#urls .result-images","img.image_thumbnail",200);t.image_thumbnail_layout.watch();t.on(".btn-collapse","click",function(e){var t=this.getAttribute("data-btn-text-collapsed");var n=this.getAttribute("data-btn-text-not-collapsed");var i=this.getAttribute("data-target");var r=o.querySelector(i);var a=this.innerHTML;if(this.classList.contains("collapsed")){a=a.replace(t,n)}else{a=a.replace(n,t)}this.innerHTML=a;this.classList.toggle("collapsed");r.classList.toggle("invisible")});t.on(".media-loader","click",function(e){var t=this.getAttribute("data-target");var n=o.querySelector(t+" > iframe");var i=n.getAttribute("src");if(i===null||i===undefined||i===false){n.setAttribute("src",n.getAttribute("data-src"))}});e.addEventListener("scroll",function(){var e=o.getElementById("backToTop"),t=document.documentElement.scrollTop||document.body.scrollTop;if(e!==null){if(t>=200){e.style.opacity=1}else{e.style.opacity=0}}})})})(window,document,window.searx);(function(t,i,n){"use strict";var r=true,a="q",o;function s(e){if(e.setSelectionRange){var t=e.value.length;e.setSelectionRange(t,t)}}function l(){if(o.value.length>0){var e=document.getElementById("search");setTimeout(e.submit.bind(e),0)}}function u(e){var t=document.getElementById("clear_search");var n=function(){if(e.value.length===0){t.classList.add("empty")}else{t.classList.remove("empty")}};n();t.addEventListener("click",function(){e.value="";e.focus();n()});e.addEventListener("keyup",n,false)}n.ready(function(){o=i.getElementById(a);function e(e){if(r){s(o);r=false}else{}}if(o!==null){u(o);if(n.autocompleter){n.autocomplete=AutoComplete.call(t,{Url:"./autocompleter",EmptyMessage:n.noItemFound,HttpMethod:n.method,MinChars:4,Delay:300},"#"+a);t.addEventListener("resize",function(){var e=new CustomEvent("position");o.dispatchEvent(e)})}o.addEventListener("focus",e,false);o.focus()}if(o!==null&&n.search_on_category_select){i.querySelector(".help").className="invisible";n.on("#categories input","change",function(e){var t,n=i.querySelectorAll('#categories input[type="checkbox"]');for(t=0;t<n.length;t++){if(n[t]!==this&&n[t].checked){n[t].click()}}if(!this.checked){this.click()}l();return false});n.on(i.getElementById("time_range"),"change",l);n.on(i.getElementById("language"),"change",l)}})})(window,document,window.searx);
|
||
//# sourceMappingURL=searx.min.js.map
|