/** * @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,i){"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),r=-1;while(n[++r]&&n[r]!=t);return!!n[r]}})(Element.prototype)}function s(e,t,n){try{e.call(t,n)}catch(e){console.log(e)}}var a=window.searxng||{};a.on=function(r,e,o,t){t=t||false;if(typeof r!=="string"){r.addEventListener(e,o,t)}else{i.addEventListener(e,function(e){var t=e.target||e.srcElement,n=false;while(t&&t.matches&&t!==i&&!(n=t.matches(r)))t=t.parentElement;if(n)s(o,t,e)},t)}};a.ready=function(e){if(document.readyState!="loading"){e.call(t)}else{t.addEventListener("DOMContentLoaded",e.bind(t))}};a.http=function(r,o,i=null){return new Promise(function(e,t){try{var n=new XMLHttpRequest;n.open(r,o,true);n.timeout=2e4;n.onload=function(){if(n.status==200){e(n.response,n.responseType)}else{t(Error(n.statusText))}};n.onerror=function(){t(Error("Network Error"))};n.onabort=function(){t(Error("Transaction is aborted"))};n.ontimeout=function(){t(Error("Timeout"))};if(i){n.send(i)}else{n.send()}}catch(e){t(e)}})};a.loadStyle=function(e){var t=a.static_path+e,n="style_"+e.replace(".","_"),r=i.getElementById(n);if(r===null){r=i.createElement("link");r.setAttribute("id",n);r.setAttribute("rel","stylesheet");r.setAttribute("type","text/css");r.setAttribute("href",t);i.body.appendChild(r)}};a.loadScript=function(e,t){var n=a.static_path+e,r="script_"+e.replace(".","_"),o=i.getElementById(r);if(o===null){o=i.createElement("script");o.setAttribute("id",r);o.setAttribute("src",n);o.onload=t;o.onerror=function(){o.setAttribute("error","1")};i.body.appendChild(o)}else if(!o.hasAttribute("error")){try{t.apply(o,[])}catch(e){console.log(e)}}else{console.log("callback not executed : script '"+n+"' not loaded.")}};a.insertBefore=function(e,t){t.parentNode.insertBefore(e,t)};a.insertAfter=function(e,t){t.parentNode.insertAfter(e,t.nextSibling)};a.on(".close","click",function(){this.parentNode.classList.add("invisible")});function e(){for(var e of i.getElementsByTagName("body")[0].classList.values()){if(e.endsWith("_endpoint")){return e.split("_")[0]}}return""}a.endpoint=e();return a}(window,document);searxng.ready(function(){"use strict";searxng.infinite_scroll_supported="IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype;if(searxng.endpoint!=="results"){return}if(!searxng.infinite_scroll_supported){console.log("IntersectionObserver not supported");return}let i=document;var s=i.getElementById("results").classList.contains("only_template_images");function n(){var e=i.createElement("div");e.classList.add("loader");return e}function r(t,e){t.textContent="";e.forEach(e=>t.appendChild(e))}function o(o){var e=i.querySelector("#pagination form.next_page");if(!e){return}r(i.querySelector("#pagination"),[n()]);var t=new FormData(e);searxng.http("POST",i.querySelector("#search").getAttribute("action"),t).then(function(e){var t=(new DOMParser).parseFromString(e,"text/html");var n=t.querySelectorAll("#urls article");var r=t.querySelector("#pagination");i.querySelector("#pagination").remove();if(n.length>0&&!s){i.querySelector("#urls").appendChild(i.createElement("hr"))}n.forEach(e=>{i.querySelector("#urls").appendChild(e)});if(r){i.querySelector("#results").appendChild(r);o()}}).catch(function(e){console.log(e);var t=i.createElement("div");t.textContent=searxng.translations.error_loading_next_page;t.classList.add("dialog-error");t.setAttribute("role","alert");r(i.querySelector("#pagination"),[t])})}if(searxng.infinite_scroll&&searxng.infinite_scroll_supported){const a={rootMargin:"20rem"};const l="article.result:last-child";const u=new IntersectionObserver(e=>{const t=e[0];if(t.isIntersecting){u.unobserve(t.target);o(()=>u.observe(i.querySelector(l),a))}});u.observe(i.querySelector(l),a)}});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 r(e){return e&&e.classList.contains("result-images")}searxng.on(".result","mousedown",function(t){if(!e(t.target)){o(this)(true);let e=n(t.target);if(r(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){o(e)(true)}if(r(e)){searxng.selectImage(e)}}},true);var d={27:{key:"Escape",fun:i,des:"remove focus from the focused input",cat:"Control"},73:{key:"i",fun:p,des:"focus on the search input",cat:"Control"},66:{key:"b",fun:u(-window.innerHeight),des:"scroll one page up",cat:"Navigation"},70:{key:"f",fun:u(window.innerHeight),des:"scroll one page down",cat:"Navigation"},85:{key:"u",fun:u(-window.innerHeight/2),des:"scroll half a page up",cat:"Navigation"},68:{key:"d",fun:u(window.innerHeight/2),des:"scroll half a page down",cat:"Navigation"},71:{key:"g",fun:c(-document.body.scrollHeight,"top"),des:"scroll to the top of the page",cat:"Navigation"},86:{key:"v",fun:c(document.body.scrollHeight,"bottom"),des:"scroll to the bottom of the page",cat:"Navigation"},75:{key:"k",fun:o("up"),des:"select previous search result",cat:"Results"},74:{key:"j",fun:o("down"),des:"select next search result",cat:"Results"},80:{key:"p",fun:l(),des:"go to previous page",cat:"Results"},78:{key:"n",fun:a(),des:"go to next page",cat:"Results"},79:{key:"o",fun:h(false),des:"open search result",cat:"Results"},84:{key:"t",fun:h(true),des:"open the result in a new tab",cat:"Results"},82:{key:"r",fun:t,des:"reload page from the server",cat:"Control"},72:{key:"h",fun:g,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 o(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 r,o=document.querySelectorAll(".result");if(typeof n!=="string"){r=n}else{switch(n){case"visible":var i=document.documentElement.scrollTop||document.body.scrollTop;var s=i+document.documentElement.clientHeight;for(var a=0;ai){break}}break;case"down":r=t.nextElementSibling;if(r===null){r=o[0]}break;case"up":r=t.previousElementSibling;if(r===null){r=o[o.length-1]}break;case"bottom":r=o[o.length-1];break;case"top":default:r=o[0]}}if(r){t.removeAttribute("data-vim-selected");r.setAttribute("data-vim-selected","true");var c=r.querySelector("h3 a")||r.querySelector("a");if(c!==null){c.focus()}if(!e){f()}}}}function t(){document.location.reload(true)}function i(e){const t=e.target.tagName.toLowerCase();if(document.activeElement&&(t==="input"||t==="select"||t==="textarea")){document.activeElement.blur()}else{searxng.closeDetail()}}function s(t){return function(){var e=document.querySelector(t);if(e){e.click()}}}function a(){return s('nav#pagination .next_page button[type="submit"]')}function l(){return s('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,r=e.offsetTop,o=r+e.clientHeight,i=120;if(e.previousElementSibling===null&&or-i){window.scroll(window.scrollX,r-i)}else{var s=t+n;if(s a")}if(e!==null){var t=e.getAttribute("href");if(n){window.open(t)}else{window.location.href=t}}}}function m(e){var n={};for(var t in d){var r=d[t];n[r.cat]=n[r.cat]||[];n[r.cat].push(r)}var o=Object.keys(n).sort(function(e,t){return n[t].length-n[e].length});if(o.length===0){return}var i='×';i+="

How to navigate searx with Vim-like hotkeys

";i+="";for(var s=0;s"}i+="";if(!u||l){i+=""}}i+="
";i+="

"+a[0].cat+"

";i+='
    ';for(var c in a){i+="
  • "+a[c].key+" "+a[c].des+"
  • "}i+="
";i+="
";e.innerHTML=i}function g(){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";m(e);m(e);m(e);var t=document.getElementsByTagName("body")[0];t.appendChild(e)}else{e.classList.toggle("invisible");return}}searxng.scrollPageToSelected=f;searxng.selectNext=o("down");searxng.selectPrevious=o("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 m=JSON.parse(this.dataset.mapBoundingbox);var g=JSON.parse(this.dataset.mapGeojson);n.loadStyle("css/leaflet.css");n.loadScript("js/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 r=L.map(d);var o="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";var i='Map data © OpenStreetMap contributors';var s=new L.TileLayer(o,{minZoom:1,maxZoom:19,attribution:i});var a="https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png";var l='Wikimedia maps | Maps data © OpenStreetMap contributors';var u=new L.TileLayer(a,{minZoom:1,maxZoom:19,attribution:l});if(e){setTimeout(function(){r.fitBounds(e,{maxZoom:17})},0)}else if(f&&p){if(h){r.setView(new L.latLng(p,f),h)}else{r.setView(new L.latLng(p,f),8)}}r.addLayer(s);var c={"OSM Mapnik":s,"OSM Wikimedia":u};L.control.layers(c).addTo(r);if(g){L.geoJson(g).addTo(r)}});e.preventDefault()})})})(window,document,window.searxng);(function(e,i,s){"use strict";if(s.endpoint!=="preferences"){return}s.ready(function(){let o=null;function e(){if(o==null){s.http("GET","engine_descriptions.json").then(function(e){o=JSON.parse(e);for(const[t,n]of Object.entries(o)){let e=i.querySelectorAll('[data-engine-name="'+t+'"] .engine-description');for(const r of e){let e=" ("+s.translations["Source"]+": "+n[1]+")";r.innerHTML=n[0]+e}}})}}for(const t of i.querySelectorAll("[data-engine-name]")){s.on(t,"mouseenter",e)}})})(window,document,window.searxng);(function(e,a,l){"use strict";if(l.endpoint!=="results"){return}l.ready(function(){a.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 r=a.querySelector(n);var o=this.innerHTML;if(this.classList.contains("collapsed")){o=o.replace(e,t)}else{o=o.replace(t,e)}this.innerHTML=o;this.classList.toggle("collapsed");r.classList.toggle("invisible")});l.on(".media-loader","click",function(){var e=this.getAttribute("data-target");var t=a.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 r=e.querySelector(".detail");if(t){const o=t.getAttribute("data-src");if(o){const i=a.createElement("div");const s=new Image;i.classList.add("loader");r.appendChild(i);s.onload=e=>{t.src=o;i.remove()};s.onerror=e=>{i.remove()};s.src=o;t.src=n.src;t.removeAttribute("data-src")}}}a.getElementById("results").classList.add("image-detail-open");l.scrollPageToSelected()};l.closeDetail=function(e){a.getElementById("results").classList.remove("image-detail-open");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=a.getElementById("backToTop"),t=document.documentElement.scrollTop||document.body.scrollTop,n=a.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,r){"use strict";var o=true,i="q",s;function a(e){if(e.setSelectionRange){var t=e.value.length;e.setSelectionRange(t,t)}}function l(){if(s.value.length>0){var e=document.getElementById("search");setTimeout(e.submit.bind(e),0)}}function u(t){var e=document.getElementById("clear_search");var n=function(){if(t.value.length===0){e.classList.add("empty")}else{e.classList.remove("empty")}};n();e.addEventListener("click",function(e){t.value="";t.focus();n();e.preventDefault()});t.addEventListener("keyup",n,false)}r.ready(function(){s=n.getElementById(i);function e(){if(o){a(s);o=false}else{}}if(s!==null){u(s);if(r.autocompleter){r.autocomplete=AutoComplete.call(t,{Url:"./autocompleter",EmptyMessage:r.translations.no_item_found,HttpMethod:r.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)}}})}},"#"+i);t.addEventListener("resize",function(){var e=new CustomEvent("position");s.dispatchEvent(e)})}s.addEventListener("focus",e,false);s.focus()}if(s!==null&&n.querySelector(".help")!=null&&r.search_on_category_select){n.querySelector(".help").className="invisible";r.on("#categories input","change",function(){var e,t=n.querySelectorAll('#categories input[type="checkbox"]');for(e=0;e=e.From&&n.keyCode<=e.To){s=!e.Not}else{s=e.Not}}}};for(var o in a.prototype.getEventsByType(e,t)){var i=a.merge({Operator:l.AND},e.KeyboardMappings[o]),s=l.AND==i.Operator;i.Conditions.forEach(r);if(s===true){i.Callback.call(e,n)}}};a.prototype.makeRequest=function(e,t,n){var r=Object.getOwnPropertyNames(e.HttpHeaders),o=new XMLHttpRequest,i=e._HttpMethod(),s=e._Url(),a=e._Pre(),l=encodeURIComponent(e._QueryArg())+"="+encodeURIComponent(a);if(i.match(/^GET$/i)){if(s.indexOf("?")!==-1){s+="&"+l}else{s+="?"+l}}o.open(i,s,true);for(var u=r.length-1;u>=0;u--){o.setRequestHeader(r[u],e.HttpHeaders[r[u]])}o.onreadystatechange=function(){if(o.readyState==4&&o.status==200){e.$Cache[a]=o.response;t(o.response)}else if(o.status>=400){n()}};return o};a.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(a.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())}};a.prototype.cache=function(e,t,n){var r=e._Cache(e._Pre());if(r===undefined){var o=a.prototype.makeRequest(e,t,n);a.prototype.ajax(e,o)}else{t(r)}};a.prototype.destroy=function(e){for(var t in e.$Listeners){e.Input.removeEventListener(t,e.$Listeners[t])}e.DOMResults.parentNode.removeChild(e.DOMResults)};a.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:i.KEYDOWN},KeyUpAndDown_down:{Conditions:[{Is:38,Not:false},{Is:40,Not:false}],Callback:function(e){e.preventDefault()},Operator:l.OR,Event:i.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)"),r=this.DOMResults.querySelector("li.active");if(r){var o=Array.prototype.indexOf.call(r.parentNode.children,r),i=o+(e.keyCode-39),s=this.DOMResults.getElementsByTagName("li").length;if(i<0){i=s-1}else if(i>=s){i=0}r.classList.remove("active");r.parentElement.children.item(i).classList.add("active")}else if(n&&e.keyCode==38){n.classList.add("active")}else if(t){t.classList.add("active")}},Operator:l.OR,Event:i.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")}a.prototype.cache(this,function(e){this._Render(this._Post(e));this._Open()}.bind(this),this._Error)}else{this._Close()}},Operator:l.AND,Event:i.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"),r=this._Limit();if(r<0){e=e.reverse()}else if(r===0){r=e.length}for(var o=0;o0){this.DOMResults.innerHTML=e}else{var r=this._EmptyMessage();if(r!==""){n.innerHTML=r;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 r=0;r