2025-07-03 17:05:55 +02:00
|
|
|
*/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.
|
2025-07-03 17:05:55 +02:00
|
|
|
*/(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.addEventLi
|