1234567891011121314 |
- /**
- * @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(h,s){h.Element&&function(o){o.matches=o.matches||o.matchesSelector||o.webkitMatchesSelector||o.msMatchesSelector||function(l){for(var n=this,r=(n.parentNode||n.document).querySelectorAll(l),t=-1;r[++t]&&r[t]!=n;);return!!r[t]}}(Element.prototype);function i(o,l,n){try{o.call(l,n)}catch(r){console.log(r)}}var p=window.searxng||{};p.on=function(o,l,n,r){r=r||!1,typeof o!="string"?o.addEventListener(l,n,r):s.addEventListener(l,function(t){for(var a=t.target||t.srcElement,f=!1;a&&a.matches&&a!==s&&!(f=a.matches(o));)a=a.parentElement;f&&i(n,a,t)},r)},p.ready=function(o){document.readyState!="loading"?o.call(h):h.addEventListener("DOMContentLoaded",o.bind(h))},p.http=function(o,l,n=null){return new Promise(function(r,t){try{var a=new XMLHttpRequest;a.open(o,l,!0),a.timeout=2e4,a.onload=function(){a.status==200?r(a.response,a.responseType):t(Error(a.statusText))},a.onerror=function(){t(Error("Network Error"))},a.onabort=function(){t(Error("Transaction is aborted"))},a.ontimeout=function(){t(Error("Timeout"))},n?a.send(n):a.send()}catch(f){t(f)}})},p.loadStyle=function(o){var l=p.settings.theme_static_path+"/"+o,n="style_"+o.replace(".","_"),r=s.getElementById(n);r===null&&(r=s.createElement("link"),r.setAttribute("id",n),r.setAttribute("rel","stylesheet"),r.setAttribute("type","text/css"),r.setAttribute("href",l),s.body.appendChild(r))},p.loadScript=function(o,l){var n=p.settings.theme_static_path+"/"+o,r="script_"+o.replace(".","_"),t=s.getElementById(r);if(t===null)t=s.createElement("script"),t.setAttribute("id",r),t.setAttribute("src",n),t.onload=l,t.onerror=function(){t.setAttribute("error","1")},s.body.appendChild(t);else if(t.hasAttribute("error"))console.log("callback not executed : script '"+n+"' not loaded.");else try{l.apply(t,[])}catch(a){console.log(a)}},p.insertBefore=function(o,l){l.parentNode.insertBefore(o,l)},p.insertAfter=function(o,l){l.parentNode.insertAfter(o,l.nextSibling)},p.on(".close","click",function(){this.parentNode.classList.add("invisible")});function g(){for(var o of s.getElementsByTagName("body")[0].classList.values())if(o.endsWith("_endpoint"))return o.split("_")[0];return""}return p.endpoint=g(),p}(window,document);searxng.ready(function(){if(searxng.infinite_scroll_supported="IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype,searxng.endpoint!=="results")return;if(!searxng.infinite_scroll_supported){console.log("IntersectionObserver not supported");return}let h=document;var s=h.getElementById("results").classList.contains("only_template_images");function i(){var o=h.createElement("div");return o.classList.add("loader"),o}function p(o,l){o.textContent="",l.forEach(n=>o.appendChild(n))}function g(o){var l=h.querySelector("#pagination form.next_page");if(l){p(h.querySelector("#pagination"),[i()]);var n=new FormData(l);searxng.http("POST",h.querySelector("#search").getAttribute("action"),n).then(function(r){var t=new DOMParser().parseFromString(r,"text/html"),a=t.querySelectorAll("#urls article"),f=t.querySelector("#pagination");h.querySelector("#pagination").remove(),a.length>0&&!s&&h.querySelector("#urls").appendChild(h.createElement("hr")),a.forEach(b=>{h.querySelector("#urls").appendChild(b)}),f&&(h.querySelector("#results").appendChild(f),o())}).catch(function(r){console.log(r);var t=h.createElement("div");t.textContent=searxng.settings.translations.error_loading_next_page,t.classList.add("dialog-error"),t.setAttribute("role","alert"),p(h.querySelector("#pagination"),[t])})}}if(searxng.settings.infinite_scroll&&searxng.infinite_scroll_supported){const o={rootMargin:"20rem"},l="article.result:last-child",n=new IntersectionObserver(r=>{const t=r[0];t.isIntersecting&&(n.unobserve(t.target),g(()=>n.observe(h.querySelector(l),o)))});n.observe(h.querySelector(l),o)}});searxng.ready(function(){function h(e){for(;e!==void 0;){if(e.classList.contains("detail"))return!0;if(e.classList.contains("result"))return!1;e=e.parentNode}return!1}function s(e){for(;e!==void 0;){if(e.classList.contains("result"))return e;e=e.parentNode}}function i(e){return e&&e.classList.contains("result-images")}searxng.on(".result","click",function(e){if(!h(e.target)){l(this)(!0,!0);let u=s(e.target);i(u)&&(e.preventDefault(),searxng.selectImage(u))}}),searxng.on(".result a","focus",function(e){if(!h(e.target)){let u=s(e.target);u&&u.getAttribute("data-vim-selected")===null&&l(u)(!0),i(u)&&searxng.selectImage(u)}},!0);var p={Escape:{key:"ESC",fun:r,des:"remove focus from the focused input",cat:"Control"},c:{key:"c",fun:A,des:"copy url of the selected result to the clipboard",cat:"Results"},h:{key:"h",fun:T,des:"toggle help window",cat:"Other"},i:{key:"i",fun:m,des:"focus on the search input",cat:"Control"},n:{key:"n",fun:a(),des:"go to next page",cat:"Results"},o:{key:"o",fun:y(!1),des:"open search result",cat:"Results"},p:{key:"p",fun:f(),des:"go to previous page",cat:"Results"},r:{key:"r",fun:n,des:"reload page from the server",cat:"Control"},t:{key:"t",fun:y(!0),des:"open the result in a new tab",cat:"Results"}},g={default:Object.assign({ArrowLeft:{key:"←",fun:l("up"),des:"select previous search result",cat:"Results"},ArrowRight:{key:"→",fun:l("down"),des:"select next search result",cat:"Results"}},p),vim:Object.assign({b:{key:"b",fun:c(-window.innerHeight),des:"scroll one page up",cat:"Navigation"},f:{key:"f",fun:c(window.innerHeight),des:"scroll one page down",cat:"Navigation"},u:{key:"u",fun:c(-window.innerHeight/2),des:"scroll half a page up",cat:"Navigation"},d:{key:"d",fun:c(window.innerHeight/2),des:"scroll half a page down",cat:"Navigation"},g:{key:"g",fun:d(-document.body.scrollHeight,"top"),des:"scroll to the top of the page",cat:"Navigation"},v:{key:"v",fun:d(document.body.scrollHeight,"bottom"),des:"scroll to the bottom of the page",cat:"Navigation"},k:{key:"k",fun:l("up"),des:"select previous search result",cat:"Results"},j:{key:"j",fun:l("down"),des:"select next search result",cat:"Results"},y:{key:"y",fun:A,des:"copy url of the selected result to the clipboard",cat:"Results"}},p)},o=g[searxng.settings.hotkeys]||g.default;searxng.on(document,"keydown",function(e){if(Object.prototype.hasOwnProperty.call(o,e.key)&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey){var u=e.target.tagName.toLowerCase();e.key==="Escape"?o[e.key].fun(e):(e.target===document.body||u==="a"||u==="button")&&(e.preventDefault(),o[e.key].fun())}});function l(e){return function(u,_){var E=document.querySelector(".result[data-vim-selected]"),k=e;if(E===null){if(E=document.querySelector(".result"),E===null)return;(e==="down"||e==="up")&&(k=E)}var v,w=document.querySelectorAll(".result");if(w=Array.from(w),typeof k!="string")v=k;else switch(k){case"visible":for(var q=document.documentElement.scrollTop||document.body.scrollTop,B=q+document.documentElement.clientHeight,x=0;x<w.length;x++){v=w[x];var I=v.offsetTop,M=I+v.clientHeight;if(M<=B&&I>q)break}break;case"down":v=w[w.indexOf(E)+1]||E;break;case"up":v=w[w.indexOf(E)-1]||E;break;case"bottom":v=w[w.length-1];break;case"top":default:v=w[0]}if(v){if(E.removeAttribute("data-vim-selected"),v.setAttribute("data-vim-selected","true"),!_){var C=v.querySelector("h3 a")||v.querySelector("a");C!==null&&C.focus()}u||b()}}}function n(){document.location.reload(!0)}function r(e){const u=e.target.tagName.toLowerCase();document.activeElement&&(u==="input"||u==="select"||u==="textarea")?document.activeElement.blur():searxng.closeDetail()}function t(e){return function(){var u=document.querySelector(e);u&&u.click()}}function a(){return t('nav#pagination .next_page button[type="submit"]')}function f(){return t('nav#pagination .previous_page button[type="submit"]')}function b(){var e=document.querySelector(".result[data-vim-selected]");if(e!==null){var u=document.documentElement.scrollTop||document.body.scrollTop,_=document.documentElement.clientHeight,E=e.offsetTop,k=E+e.clientHeight,v=120;if(e.previousElementSibling===null&&k<_){window.scroll(window.scrollX,0);return}if(u>E-v)window.scroll(window.scrollX,E-v);else{var w=u+_;w<k+v&&window.scroll(window.scrollX,k-_+v)}}}function c(e){return function(){window.scrollBy(0,e),l("visible")()}}function d(e,u){return function(){window.scrollTo(0,e),l(u)()}}function m(){window.scrollTo(0,0);var e=document.querySelector("#q");if(e.focus(),e.setSelectionRange){var u=e.value.length;e.setSelectionRange(u,u)}}function y(e){return function(){var u=document.querySelector(".result[data-vim-selected] h3 a");if(u===null&&(u=document.querySelector(".result[data-vim-selected] > a")),u!==null){var _=u.getAttribute("href");e?window.open(_):window.location.href=_}}}function S(e){var u={};for(var _ in o){var E=o[_];u[E.cat]=u[E.cat]||[],u[E.cat].push(E)}var k=Object.keys(u).sort(function(M,C){return u[C].length-u[M].length});if(k.length!==0){var v='<a href="#" class="close" aria-label="close" title="close">×</a>';v+="<h3>How to navigate SearXNG with hotkeys</h3>",v+="<table>";for(var w=0;w<k.length;w++){var q=u[k[w]],B=w===k.length-1,x=w%2===0;x&&(v+="<tr>"),v+="<td>",v+="<h4>"+q[0].cat+"</h4>",v+='<ul class="list-unstyled">';for(var I in q)v+="<li><kbd>"+q[I].key+"</kbd> "+q[I].des+"</li>";v+="</ul>",v+="</td>",(!x||B)&&(v+="</tr>")}v+="</table>",e.innerHTML=v}}function T(){var e=document.querySelector("#vim-hotkeys-help");if(e==null){e=document.createElement("div"),e.id="vim-hotkeys-help",e.className="dialog-modal",S(e);var u=document.getElementsByTagName("body")[0];u.appendChild(e)}else{e.classList.toggle("invisible");return}}function A(){var e=document.querySelector(".result[data-vim-selected] h3 a");if(e===null)return;const u=e.getAttribute("href");navigator.clipboard.writeText(u)}searxng.scrollPageToSelected=b,searxng.selectNext=l("down"),searxng.selectPrevious=l("up")});(function(h,s,i){i.ready(function(){i.on(".searxng_init_map","click",function(p){this.classList.remove("searxng_init_map");var g=this.dataset.leafletTarget,o=parseFloat(this.dataset.mapLon),l=parseFloat(this.dataset.mapLat),n=parseFloat(this.dataset.mapZoom),r=JSON.parse(this.dataset.mapBoundingbox),t=JSON.parse(this.dataset.mapGeojson);i.loadStyle("css/leaflet.css"),i.loadScript("js/leaflet.js",function(){var a=null;if(r){var f=L.latLng(r[0],r[2]),b=L.latLng(r[1],r[3]);a=L.latLngBounds(f,b)}var c=L.map(g),d="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",m='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors',y=new L.TileLayer(d,{minZoom:1,maxZoom:19,attribution:m}),S="https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png",T='Wikimedia maps | Maps data © <a href="https://openstreetmap.org">OpenStreetMap contributors</a>',A=new L.TileLayer(S,{minZoom:1,maxZoom:19,attribution:T});a?setTimeout(function(){c.fitBounds(a,{maxZoom:17})},0):o&&l&&(n?c.setView(new L.latLng(l,o),n):c.setView(new L.latLng(l,o),8)),c.addLayer(y);var e={"OSM Mapnik":y,"OSM Wikimedia":A};L.control.layers(e).addTo(c),t&&L.geoJson(t).addTo(c)}),p.preventDefault()})})})(window,document,window.searxng);(function(h,s,i){i.endpoint==="preferences"&&i.ready(function(){let p=null;function g(){p==null&&i.http("GET","engine_descriptions.json").then(function(a){p=JSON.parse(a);for(const[f,b]of Object.entries(p)){let c=s.querySelectorAll('[data-engine-name="'+f+'"] .engine-description');for(const d of c){let m=" (<i>"+i.settings.translations.Source+": "+b[1]+"</i>)";d.innerHTML=b[0]+m}}})}for(const a of s.querySelectorAll("[data-engine-name]"))i.on(a,"mouseenter",g);const o=s.querySelectorAll(".enable-all-engines"),l=s.querySelectorAll(".disable-all-engines"),n=s.querySelectorAll("tbody input[type=checkbox][class~=checkbox-onoff]"),r=a=>{for(const f of n)f.offsetParent!==null&&(f.checked=!a)};for(const a of o)i.on(a,"click",()=>r(!0));for(const a of l)i.on(a,"click",()=>r(!1));const t=s.querySelector("#copy-hash");i.on(t,"click",a=>{a.preventDefault(),navigator.clipboard.writeText(t.dataset.hash),t.innerText=t.dataset.copiedText})})})(window,document,window.searxng);/*!
- * swiped-events.js - v@version@
- * Pure JavaScript swipe events
- * https://github.com/john-doherty/swiped-events
- * @inspiration https://stackoverflow.com/questions/16348031/disable-scrolling-when-touch-moving-certain-element
- * @author John Doherty <www.johndoherty.info>
- * @license MIT
- */(function(h,s){typeof h.CustomEvent!="function"&&(h.CustomEvent=function(c,d){d=d||{bubbles:!1,cancelable:!1,detail:void 0};var m=s.createEvent("CustomEvent");return m.initCustomEvent(c,d.bubbles,d.cancelable,d.detail),m},h.CustomEvent.prototype=h.Event.prototype),s.addEventListener("touchstart",a,!1),s.addEventListener("touchmove",f,!1),s.addEventListener("touchend",t,!1);var i=null,p=null,g=null,o=null,l=null,n=null,r=0;function t(c){if(n===c.target){var d=parseInt(b(n,"data-swipe-threshold","20"),10),m=b(n,"data-swipe-unit","px"),y=parseInt(b(n,"data-swipe-timeout","500"),10),S=Date.now()-l,T="",A=c.changedTouches||c.touches||[];if(m==="vh"&&(d=Math.round(d/100*s.documentElement.clientHeight)),m==="vw"&&(d=Math.round(d/100*s.documentElement.clientWidth)),Math.abs(g)>Math.abs(o)?Math.abs(g)>d&&S<y&&(g>0?T="swiped-left":T="swiped-right"):Math.abs(o)>d&&S<y&&(o>0?T="swiped-up":T="swiped-down"),T!==""){var e={dir:T.replace(/swiped-/,""),touchType:(A[0]||{}).touchType||"direct",fingers:r,xStart:parseInt(i,10),xEnd:parseInt((A[0]||{}).clientX||-1,10),yStart:parseInt(p,10),yEnd:parseInt((A[0]||{}).clientY||-1,10)};n.dispatchEvent(new CustomEvent("swiped",{bubbles:!0,cancelable:!0,detail:e})),n.dispatchEvent(new CustomEvent(T,{bubbles:!0,cancelable:!0,detail:e}))}i=null,p=null,l=null}}function a(c){c.target.getAttribute("data-swipe-ignore")!=="true"&&(n=c.target,l=Date.now(),i=c.touches[0].clientX,p=c.touches[0].clientY,g=0,o=0,r=c.touches.length)}function f(c){if(!(!i||!p)){var d=c.touches[0].clientX,m=c.touches[0].clientY;g=i-d,o=p-m}}function b(c,d,m){for(;c&&c!==s.documentElement;){var y=c.getAttribute(d);if(y)return y;c=c.parentNode}return m}})(window,document);(function(h,s,i){i.endpoint==="results"&&i.ready(function(){s.querySelectorAll("#urls img").forEach(n=>n.addEventListener("error",()=>{n.src=window.searxng.settings.theme_static_path+"/img/img_load_error.svg"},{once:!0})),s.querySelector("#search_url button#copy_url")&&(s.querySelector("#search_url button#copy_url").style.display="block"),i.on(".btn-collapse","click",function(){var n=this.getAttribute("data-btn-text-collapsed"),r=this.getAttribute("data-btn-text-not-collapsed"),t=this.getAttribute("data-target"),a=s.querySelector(t),f=this.innerHTML;this.classList.contains("collapsed")?f=f.replace(n,r):f=f.replace(r,n),this.innerHTML=f,this.classList.toggle("collapsed"),a.classList.toggle("invisible")}),i.on(".media-loader","click",function(){var n=this.getAttribute("data-target"),r=s.querySelector(n+" > iframe"),t=r.getAttribute("src");(t==null||t===!1)&&r.setAttribute("src",r.getAttribute("data-src"))}),i.on("#copy_url","click",function(){var n=this.parentElement.querySelector("pre");navigator.clipboard.writeText(n.innerText),this.innerText=this.dataset.copiedText});let p;const g=s.createElement("div");g.classList.add("loader");const o=new Image,l=(n,r)=>{p&&clearTimeout(p),p=setTimeout(()=>{o.src=n},1e3),o.onload=()=>{r(),g.remove()},o.onerror=()=>{g.remove()}};i.selectImage=n=>{if(s.getElementById("results").classList.add("image-detail-open"),window.location.hash="#image-viewer",i.scrollPageToSelected(),!n)return;const r=n.querySelector(".result-images-source img");if(!r)return;const t=r.getAttribute("data-src");if(!t)return;const a=n.querySelector(".image_thumbnail");r.src=a.src,n.querySelector(".detail").appendChild(g),l(t,()=>{r.src=t,r.removeAttribute("data-src")})},i.closeDetail=function(){s.getElementById("results").classList.remove("image-detail-open"),window.location.hash=="#image-viewer"&&window.history.back(),i.scrollPageToSelected()},i.on(".result-detail-close","click",n=>{n.preventDefault(),i.closeDetail()}),i.on(".result-detail-previous","click",n=>{n.preventDefault(),i.selectPrevious(!1)}),i.on(".result-detail-next","click",n=>{n.preventDefault(),i.selectNext(!1)}),window.addEventListener("hashchange",()=>{window.location.hash!="#image-viewer"&&i.closeDetail()}),s.querySelectorAll(".swipe-horizontal").forEach(n=>{n.addEventListener("swiped-left",function(){i.selectNext(!1)}),n.addEventListener("swiped-right",function(){i.selectPrevious(!1)})}),h.addEventListener("scroll",function(){var n=s.getElementById("backToTop"),r=document.documentElement.scrollTop||document.body.scrollTop,t=s.getElementById("results");n!==null&&(r>=100?t.classList.add("scrolling"):t.classList.remove("scrolling"))},!0)})})(window,document,window.searxng);(function(h,s,i){var p="q",g;const o=window.matchMedia("only screen and (max-width: 50em)").matches;function l(){if(g.value.length>0){var t=document.getElementById("search");setTimeout(t.submit.bind(t),0)}}function n(t){var a=document.getElementById("clear_search"),f=function(){t.value.length===0?a.classList.add("empty"):a.classList.remove("empty")};f(),a.addEventListener("click",function(b){t.value="",t.focus(),f(),b.preventDefault()}),t.addEventListener("input",f,!1)}const r=async t=>{let a;if(i.settings.method==="GET"){const f=new URLSearchParams;f.append("q",t),a=fetch("./autocompleter?"+f.toString())}else{const f=new FormData;f.append("q",t),a=fetch("./autocompleter",{method:"POST",body:f})}a.then(async function(f){const b=await f.json();if(!b)return;const c=s.querySelector(".autocomplete"),d=s.querySelector(".autocomplete ul");if(c.classList.add("open"),d.innerHTML="",!b[1]||b[1].length==0){const m=document.createElement("li");m.classList.add("no-item-found"),m.innerHTML=i.settings.translations.no_item_found,d.appendChild(m);return}for(let m of b[1]){const y=document.createElement("li");y.innerText=m,i.on(y,"mousedown",()=>{g.value=m,s.querySelector("#search").submit(),c.classList.remove("open")}),d.appendChild(y)}})};i.ready(function(){o||document.getElementById("q").focus(),g=s.getElementById(p);const t=s.querySelector(".autocomplete"),a=s.querySelector(".autocomplete ul");g!==null&&(n(g),i.settings.autocomplete&&(i.on(g,"input",()=>{const c=g.value;c.length<i.settings.autocomplete_min||setTimeout(()=>{c==g.value&&r(c)},300)}),i.on(g,"keyup",c=>{let d=-1;const m=a.children;for(let S=0;S<m.length;S++)if(m[S].classList.contains("active")){d=S;break}let y=-1;if(c.key==="ArrowUp"?(d>=0&&m[d].classList.remove("active"),y=(d-1+m.length)%m.length):c.key==="ArrowDown"?(d>=0&&m[d].classList.remove("active"),y=(d+1)%m.length):(c.key==="Tab"||c.key==="Enter")&&t.classList.remove("open"),y!=-1){const S=m[y];S.classList.add("active"),S.classList.contains("no-item-found")||(g.value=S.innerText)}}))),g!==null&&i.settings.search_on_category_select&&s.querySelector(".search_filters")!=null&&(i.on(s.getElementById("safesearch"),"change",l),i.on(s.getElementById("time_range"),"change",l),i.on(s.getElementById("language"),"change",l));const f=s.querySelectorAll("button.category_button");for(let c of f)i.on(c,"click",d=>{if(d.shiftKey){d.preventDefault(),c.classList.toggle("selected");return}const m=s.querySelectorAll("button.category_button.selected");for(let y of m)y.classList.remove("selected");c.classList.add("selected")});const b=s.querySelector("#search");b!=null&&i.on(b,"submit",c=>{c.preventDefault();const d=s.querySelector("#selected-categories");if(d){let m=[];for(let y of f)y.classList.contains("selected")&&m.push(y.name.replace("category_",""));d.value=m.join(",")}b.submit()})})})(window,document,window.searxng);
- //# sourceMappingURL=searxng.min.js.map
|