/** * @license * (C) Copyright Contributors to the SearXNG project. * (C) Copyright Contributors to the searx project (2014 - 2021). * SPDX-License-Identifier: AGPL-3.0-or-later */ window.searxng=function(t,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 a(e,t,n){try{e.call(t,n)}catch(e){console.log(e)}}var s=window.searxng||{};s.on=function(i,e,r,t){t=t||false;if(typeof i!=="string"){i.addEventListener(e,r,t)}else{o.addEventListener(e,function(e){var t=e.target||e.srcElement,n=false;while(t&&t.matches&&t!==o&&!(n=t.matches(i)))t=t.parentElement;if(n)a(r,t,e)},t)}};s.ready=function(e){if(document.readyState!="loading"){e.call(t)}else{t.addEventListener("DOMContentLoaded",e.bind(t))}};s.http=function(e,t){var n=new XMLHttpRequest,i=function(){},r=function(){},o={then:function(e){i=e;return o},catch:function(e){r=e;return o}};try{n.open(e,t,true);n.onload=function(){if(n.status==200){i(n.response,n.responseType)}else{r(Error(n.statusText))}};n.onerror=function(){r(Error("Network Error"))};n.onabort=function(){r(Error("Transaction is aborted"))};n.send()}catch(e){r(e)}return o};s.loadStyle=function(e){var t=s.static_path+e,n="style_"+e.replace(".","_"),i=o.getElementById(n);if(i===null){i=o.createElement("link");i.setAttribute("id",n);i.setAttribute("rel","stylesheet");i.setAttribute("type","text/css");i.setAttribute("href",t);o.body.appendChild(i)}};s.loadScript=function(e,t){var n=s.static_path+e,i="script_"+e.replace(".","_"),r=o.getElementById(i);if(r===null){r=o.createElement("script");r.setAttribute("id",i);r.setAttribute("src",n);r.onload=t;r.onerror=function(){r.setAttribute("error","1")};o.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.")}};s.insertBefore=function(e,t){t.parentNode.insertBefore(e,t)};s.insertAfter=function(e,t){t.parentNode.insertAfter(e,t.nextSibling)};s.on(".close","click",function(){this.parentNode.classList.add("invisible")});return s}(window,document);searxng.ready(function(){function e(e){while(e!==undefined){if(e.classList.contains("detail")){return true}if(e.classList.contains("result")){return false}e=e.parentNode}return false}function n(e){while(e!==undefined){if(e.classList.contains("result")){return e}e=e.parentNode}return undefined}function i(e){return e&&e.classList.contains("result-images")}searxng.on(".result","click",function(t){if(!e(t.target)){r(this)(true);let e=n(t.target);if(i(e)){t.preventDefault();searxng.selectImage(e)}}});searxng.on(".result a","focus",function(t){if(!e(t.target)){let e=n(t.target);if(e&&e.getAttribute("data-vim-selected")===null){r(e)(true)}if(i(e)){searxng.selectImage(e)}}},true);var d={27:{key:"Escape",fun:u,des:"remove focus from the focused input",cat:"Control"},73:{key:"i",fun:h,des:"focus on the search input",cat:"Control"},66:{key:"b",fun:o(-window.innerHeight),des:"scroll one page up",cat:"Navigation"},70:{key:"f",fun:o(window.innerHeight),des:"scroll one page down",cat:"Navigation"},85:{key:"u",fun:o(-window.innerHeight/2),des:"scroll half a page up",cat:"Navigation"},68:{key:"d",fun:o(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:r("up"),des:"select previous search result",cat:"Results"},74:{key:"j",fun:r("down"),des:"select next search result",cat:"Results"},80:{key:"p",fun:p(),des:"go to previous page",cat:"Results"},78:{key:"n",fun:c(),des:"go to next page",cat:"Results"},79:{key:"o",fun:g(false),des:"open search result",cat:"Results"},84:{key:"t",fun:g(true),des:"open the result in a new tab",cat:"Results"},82:{key:"r",fun:l,des:"reload page from the server",cat:"Control"},72:{key:"h",fun:m,des:"toggle help window",cat:"Other"}};if(searxng.hotkeys){searxng.on(document,"keydown",function(e){if(Object.prototype.hasOwnProperty.call(d,e.keyCode)&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey){var t=e.target.tagName.toLowerCase();if(e.keyCode===27){d[e.keyCode].fun(e)}else{if(e.target===document.body||t==="a"||t==="button"){e.preventDefault();d[e.keyCode].fun()}}}})}function r(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 o=document.documentElement.scrollTop||document.body.scrollTop;var a=o+document.documentElement.clientHeight;for(var s=0;so){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 u=i.querySelector("h3 a")||i.querySelector("a");if(u!==null){u.focus()}if(!e){f()}}}}function l(){document.location.reload(true)}function u(e){const t=e.target.tagName.toLowerCase();if(document.activeElement&&(t==="input"||t==="select"||t==="textarea")){document.activeElement.blur()}else{searxng.closeDetail()}}function t(t){return function(){var e=document.querySelector(t);if(e){e.click()}}}function c(){return t('nav#pagination .next_page button[type="submit"]')}function p(){return t('nav#pagination .previous_page button[type="submit"]')}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,o=120;if(e.previousElementSibling===null&&ri-o){window.scroll(window.scrollX,i-o)}else{var a=t+n;if(a a")}if(e!==null){var t=e.getAttribute("href");if(n){window.open(t)}else{window.location.href=t}}}}function s(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 o='×';o+="

How to navigate searx with Vim-like hotkeys

";o+="";for(var a=0;a"}o+="";if(!l||c){o+=""}}o+="
";o+="

"+s[0].cat+"

";o+='
    ';for(var u in s){o+="
  • "+s[u].key+" "+s[u].des+"
  • "}o+="
";o+="
";e.innerHTML=o}function m(){var e=document.querySelector("#vim-hotkeys-help");if(e===undefined||e===null){e=document.createElement("div");e.id="vim-hotkeys-help";e.className="dialog-modal";s(e);s(e);s(e);var t=document.getElementsByTagName("body")[0];t.appendChild(e)}else{e.classList.toggle("invisible");return}}searxng.scrollPageToSelected=f;searxng.selectNext=r("down");searxng.selectPrevious=r("up")});(function(e,t,n){"use strict";n.ready(function(){n.on(".searxng_init_map","click",function(e){this.classList.remove("searxng_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 g=JSON.parse(this.dataset.mapBoundingbox);var m=JSON.parse(this.dataset.mapGeojson);n.loadStyle("css/leaflet.css");n.loadScript("js/leaflet.js",function(){var e=null;if(g){var t=L.latLng(g[0],g[2]);var n=L.latLng(g[1],g[3]);e=L.latLngBounds(t,n)}var i=L.map(d);var r="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";var o='Map data © OpenStreetMap contributors';var a=new L.TileLayer(r,{minZoom:1,maxZoom:19,attribution:o});var s="https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png";var l='Wikimedia maps | Maps data © OpenStreetMap 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(a);var c={"OSM Mapnik":a,"OSM Wikimedia":u};L.control.layers(c).addTo(i);if(m){L.geoJson(m).addTo(i)}});e.preventDefault()})})})(window,document,window.searxng);(function(e,o,a){"use strict";a.ready(function(){let r=null;function e(){if(r==null){a.http("GET","engine_descriptions.json").then(function(e){r=JSON.parse(e);for(const[t,n]of Object.entries(r)){let e=o.querySelectorAll('[data-engine-name="'+t+'"] .engine-description');for(const i of e){let e=" ("+a.translations["Source"]+": "+n[1]+")";i.innerHTML=n[0]+e}}})}}if(o.querySelector('body[class="preferences_endpoint"]')){for(const t of o.querySelectorAll("[data-engine-name]")){a.on(t,"mouseenter",e)}}})})(window,document,window.searxng);(function(e,s,l){"use strict";l.ready(function(){l.image_thumbnail_layout=new l.ImageLayout("#urls","#urls .result-images","img.image_thumbnail",14,6,200);l.image_thumbnail_layout.watch();s.querySelectorAll("#urls img.image").forEach(e=>e.addEventListener("error",()=>{e.style.display="none";e.error=null}));l.on(".btn-collapse","click",function(){var e=this.getAttribute("data-btn-text-collapsed");var t=this.getAttribute("data-btn-text-not-collapsed");var n=this.getAttribute("data-target");var i=s.querySelector(n);var r=this.innerHTML;if(this.classList.contains("collapsed")){r=r.replace(e,t)}else{r=r.replace(t,e)}this.innerHTML=r;this.classList.toggle("collapsed");i.classList.toggle("invisible")});l.on(".media-loader","click",function(){var e=this.getAttribute("data-target");var t=s.querySelector(e+" > iframe");var n=t.getAttribute("src");if(n===null||n===undefined||n===false){t.setAttribute("src",t.getAttribute("data-src"))}});l.selectImage=function(e){if(e){const t=e.querySelector(".result-images-source img");const n=e.querySelector(".image_thumbnail");const i=e.querySelector(".detail");if(t){const r=t.getAttribute("data-src");if(r){const o=s.createElement("div");const a=new Image;o.classList.add("loader");i.appendChild(o);a.onload=e=>{t.src=r;o.remove()};a.onerror=e=>{o.remove()};a.src=r;t.src=n.src;t.removeAttribute("data-src")}}}s.getElementById("results").classList.add("image-detail-open");l.image_thumbnail_layout.align();l.scrollPageToSelected()};l.closeDetail=function(e){s.getElementById("results").classList.remove("image-detail-open");l.image_thumbnail_layout.align();l.scrollPageToSelected()};l.on(".result-detail-close","click",e=>{e.preventDefault();l.closeDetail()});l.on(".result-detail-previous","click",e=>l.selectPrevious(false));l.on(".result-detail-next","click",e=>l.selectNext(false));e.addEventListener("scroll",function(){var e=s.getElementById("backToTop"),t=document.documentElement.scrollTop||document.body.scrollTop,n=s.getElementById("results");if(e!==null){if(t>=100){n.classList.add("scrolling")}else{n.classList.remove("scrolling")}}},true)})})(window,document,window.searxng);(function(t,n,i){"use strict";var r=true,o="q",a;function s(e){if(e.setSelectionRange){var t=e.value.length;e.setSelectionRange(t,t)}}function l(){if(a.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)}i.ready(function(){a=n.getElementById(o);function e(){if(r){s(a);r=false}else{}}if(a!==null){u(a);if(i.autocompleter){i.autocomplete=AutoComplete.call(t,{Url:"./autocompleter",EmptyMessage:i.translations.no_item_found,HttpMethod:i.method,HttpHeaders:{"Content-type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},MinChars:4,Delay:300,_Position:function(){this.DOMResults.setAttribute("class","autocomplete");this.DOMResults.style.top=this.Input.offsetTop+this.Input.offsetHeight+"px";this.DOMResults.style.left=this.Input.offsetLeft+"px";this.DOMResults.style.width=this.Input.clientWidth+"px"},_Open:function(){var t=this;Array.prototype.forEach.call(this.DOMResults.getElementsByTagName("li"),function(e){if(e.getAttribute("class")!="locked"){e.onmousedown=function(){t._Select(e)}}})}},"#"+o);t.addEventListener("resize",function(){var e=new CustomEvent("position");a.dispatchEvent(e)})}a.addEventListener("focus",e,false);a.focus()}if(a!==null&&n.querySelector(".help")!=null&&i.search_on_category_select){n.querySelector(".help").className="invisible";i.on("#categories input","change",function(){var e,t=n.querySelectorAll('#categories input[type="checkbox"]');for(e=0;eExample usage of searxng.ImageLayout class. * searxng.image_thumbnail_layout = new searxng.ImageLayout( * '#urls', // container_selector * '#urls .result-images', // results_selector * 'img.image_thumbnail', // img_selector * 14, // verticalMargin * 6, // horizontalMargin * 200 // maxHeight * ); * searxng.image_thumbnail_layout.watch(); */ (function(s,c){function e(e,t,n,i,r,o){this.container_selector=e;this.results_selector=t;this.img_selector=n;this.verticalMargin=i;this.horizontalMargin=r;this.maxHeight=o;this.isAlignDone=true}e.prototype._getHeigth=function(e,t){var n,i;var r=0;for(n=0;n0&&i.naturalHeight>0){r+=i.naturalWidth/i.naturalHeight}else{r+=1}}return(t-e.length*this.verticalMargin)/r};e.prototype._setSize=function(e,t){var n,i,r;var o=e.length,a;for(n=0;n0&&i.naturalHeight>0){r=t*i.naturalWidth/i.naturalHeight}else{r=t}i.style.width=r+"px";i.style.height=t+"px";i.style.marginLeft=this.horizontalMargin+"px";i.style.marginTop=this.horizontalMargin+"px";i.style.marginRight=this.verticalMargin-7+"px";i.style.marginBottom=this.verticalMargin-7+"px";a=i.parentNode.parentNode;if(!a.classList.contains("js")){a.classList.add("js")}}};e.prototype._alignImgs=function(e){var t,n,i,r;var o=c.querySelector(this.container_selector);var a=window.getComputedStyle(o);var s=parseInt(a.getPropertyValue("padding-left"),10);var l=parseInt(a.getPropertyValue("padding-right"),10);var u=o.clientWidth-s-l;while(e.length>0){t=true;for(i=1;i<=e.length&&t;i++){n=e.slice(0,i);r=this._getHeigth(n,u);if(r0){this._alignImgs(o);o=[]}o.push(r.querySelector(this.img_selector));i=r}if(o.length>0){this._alignImgs(o)}};e.prototype.watch=function(){var e,t;var n=this;var i=c.querySelectorAll(this.results_selector);var r=i.length;function o(e){e.originalTarget.src=s.searxng.static_path+s.searxng.theme.img_load_error}function a(){if(n.isAlignDone){n.isAlignDone=false;setTimeout(function(){n.align();n.isAlignDone=true},100)}}s.addEventListener("pageshow",a);s.addEventListener("load",a);s.addEventListener("resize",a);for(e=0;e=e.From&&n.keyCode<=e.To){a=!e.Not}else{a=e.Not}}}};for(var r in s.prototype.getEventsByType(e,t)){var o=s.merge({Operator:l.AND},e.KeyboardMappings[r]),a=l.AND==o.Operator;o.Conditions.forEach(i);if(a===true){o.Callback.call(e,n)}}};s.prototype.makeRequest=function(e,t,n){var i=Object.getOwnPropertyNames(e.HttpHeaders),r=new XMLHttpRequest,o=e._HttpMethod(),a=e._Url(),s=e._Pre(),l=encodeURIComponent(e._QueryArg())+"="+encodeURIComponent(s);if(o.match(/^GET$/i)){if(a.indexOf("?")!==-1){a+="&"+l}else{a+="?"+l}}r.open(o,a,true);for(var u=i.length-1;u>=0;u--){r.setRequestHeader(i[u],e.HttpHeaders[i[u]])}r.onreadystatechange=function(){if(r.readyState==4&&r.status==200){e.$Cache[s]=r.response;t(r.response)}else if(r.status>=400){n()}};return r};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,n){var i=e._Cache(e._Pre());if(i===undefined){var r=s.prototype.makeRequest(e,t,n);s.prototype.ajax(e,r)}else{t(i)}};s.prototype.destroy=function(e){for(var t in e.$Listeners){e.Input.removeEventListener(t,e.$Listeners[t])}e.DOMResults.parentNode.removeChild(e.DOMResults)};s.merge=function(){var e={},t;for(var n=0;n"+e+""}},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:o.KEYDOWN},KeyUpAndDown_down:{Conditions:[{Is:38,Not:false},{Is:40,Not:false}],Callback:function(e){e.preventDefault()},Operator:l.OR,Event:o.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),o=r+(e.keyCode-39),a=this.DOMResults.getElementsByTagName("li").length;if(o<0){o=a-1}else if(o>=a){o=0}i.classList.remove("active");i.parentElement.children.item(o).classList.add("active")}else if(n&&e.keyCode==38){n.classList.add("active")}else if(t){t.classList.add("active")}},Operator:l.OR,Event:o.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")}s.prototype.cache(this,function(e){this._Render(this._Post(e));this._Open()}.bind(this),this._Error)}else{this._Close()}},Operator:l.AND,Event:o.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===void 0){e=false}if(e){this._Close()}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 t=this;Array.prototype.forEach.call(this.DOMResults.getElementsByTagName("li"),function(e){if(e.getAttribute("class")!="locked"){e.onclick=function(){t._Select(e)}}})},_Close:function(){this.DOMResults.setAttribute("class","autocomplete")},_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;r0){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