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