2025-04-02 09:46:47 +00:00
|
|
|
*/window.searxng=function(h,d){h.Element&&function(r){r.matches=r.matches||r.matchesSelector||r.webkitMatchesSelector||r.msMatchesSelector||function(a){for(var l=this,n=(l.parentNode||l.document).querySelectorAll(a),e=-1;n[++e]&&n[e]!=l;);return!!n[e]}}(Element.prototype);function u(r,a,l){try{r.call(a,l)}catch(n){console.log(n)}}var p=window.searxng||{};p.on=function(r,a,l,n){n=n||!1,typeof r!="string"?r.addEventListener(a,l,n):d.addEventListener(a,function(e){for(var t=e.target||e.srcElement,o=!1;t&&t.matches&&t!==d&&!(o=t.matches(r));)t=t.parentElement;o&&u(l,t,e)},n)},p.ready=function(r){document.readyState!="loading"?r.call(h):h.addEventListener("DOMContentLoaded",r.bind(h))},p.http=function(r,a,l=null){return new Promise(function(n,e){try{var t=new XMLHttpRequest;t.open(r,a,!0),t.timeout=2e4,t.onload=function(){t.status==200?n(t.response,t.responseType):e(Error(t.statusText))},t.onerror=function(){e(Error("Network Error"))},t.onabort=function(){e(Error("Transaction is aborted"))},t.ontimeout=function(){e(Error("Timeout"))},l?t.send(l):t.send()}catch(o){e(o)}})},p.loadStyle=function(r){var a=p.settings.theme_static_path+"/"+r,l="style_"+r.replace(".","_"),n=d.getElementById(l);n===null&&(n=d.createElement("link"),n.setAttribute("id",l),n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),n.setAttribute("href",a),d.body.appendChild(n))},p.loadScript=function(r,a){var l=p.settings.theme_static_path+"/"+r,n="script_"+r.replace(".","_"),e=d.getElementById(n);if(e===null)e=d.createElement("script"),e.setAttribute("id",n),e.setAttribute("src",l),e.onload=a,e.onerror=function(){e.setAttribute("error","1")},d.body.appendChild(e);else if(e.hasAttribute("error"))console.log("callback not executed : script '"+l+"' not loaded.");else try{a.apply(e,[])}catch(t){console.log(t)}},p.insertBefore=function(r,a){a.parentNode.insertBefore(r,a)},p.insertAfter=function(r,a){a.parentNode.insertAfter(r,a.nextSibling)},p.on(".close","click",function(){this.parentNode.classList.add("invisible")});function m(){for(var r of d.getElementsByTagName("body")[0].classList.values())if(r.endsWith("_endpoint"))return r.split("_")[0];return""}return p.endpoint=m(),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 d=h.getElementById("results").classList.contains("only_template_images");function u(){var r=h.createElement("div");return r.classList.add("loader"),r}function p(r,a){r.textContent="",a.forEach(l=>r.appendChild(l))}function m(r){var a=h.querySelector("#pagination form.next_page");if(a){p(h.querySelector("#pagination"),[u()]);var l=new FormData(a);searxng.http("POST",h.querySelector("#search").getAttribute("action"),l).then(function(n){var e=new DOMParser().parseFromString(n,"text/html"),t=e.querySelectorAll("#urls article"),o=e.querySelector("#pagination");h.querySelector("#pagination").remove(),t.length>0&&!d&&h.querySelector("#urls").appendChild(h.createElement("hr")),t.forEach(c=>{h.querySelector("#urls").appendChild(c)}),o&&(h.querySelector("#results").appendChild(o),r())}).catch(function(n){console.log(n);var e=h.createElement("div");e.textContent=searxng.settings.translations.error_loading_next_page,e.classList.add("dialog-error"),e.setAttribute("role","alert"),p(h.querySelector("#pagination"),[e])})}}if(searxng.settings.infinite_scroll&&searxng.infinite_scroll_supported){const r={rootMargin:"20rem"},a="article.result:last-child",l=new IntersectionObserver(n=>{const e=n[0];e.isIntersecting&&(l.unobserve(e.target),m(()=>l.observe(h.querySelector(a),r)))});l.observe(h.querySelector(a),r)}});searxng.ready(function(){function h(i){for(;i!==void 0;){if(i.classList.contains("detail"))return!0;if(i.classList.contains("result"))return!1;i=i.parentNode}return!1}function d(i){for(;i!==void 0;){if(i.classList.contains(
|
|
|
|
*/(function(h,d){typeof h.CustomEvent!="function"&&(h.CustomEvent=function(s,g){g=g||{bubbles:!1,cancelable:!1,detail:void 0};var v=d.createEvent("CustomEvent");return v.initCustomEvent(s,g.bubbles,g.cancelable,g.detail),v},h.CustomEvent.prototype=h.Event.prototype),d.addEventListener("touchstart",t,!1),d.addEventListener("touchmove",o,!1),d.addEventListener("touchend",e,!1);var u=null,p=null,m=null,r=null,a=null,l=null,n=0;function e(s){if(l===s.target){var g=parseInt(c(l,"data-swipe-threshold","20"),10),v=c(l,"data-swipe-unit","px"),b=parseInt(c(l,"data-swipe-timeout","500"),10),k=Date.now()-a,_="",O=s.changedTouches||s.touches||[];if(v==="vh"&&(g=Math.round(g/100*d.documentElement.clientHeight)),v==="vw"&&(g=Math.round(g/100*d.documentElement.clientWidth)),Math.abs(m)>Math.abs(r)?Math.abs(m)>g&&k<b&&(m>0?_="swiped-left":_="swiped-right"):Math.abs(r)>g&&k<b&&(r>0?_="swiped-up":_="swiped-down"),_!==""){var i={dir:_.replace(/swiped-/,""),touchType:(O[0]||{}).touchType||"direct",fingers:n,xStart:parseInt(u,10),xEnd:parseInt((O[0]||{}).clientX||-1,10),yStart:parseInt(p,10),yEnd:parseInt((O[0]||{}).clientY||-1,10)};l.dispatchEvent(new CustomEvent("swiped",{bubbles:!0,cancelable:!0,detail:i})),l.dispatchEvent(new CustomEvent(_,{bubbles:!0,cancelable:!0,detail:i}))}u=null,p=null,a=null}}function t(s){s.target.getAttribute("data-swipe-ignore")!=="true"&&(l=s.target,a=Date.now(),u=s.touches[0].clientX,p=s.touches[0].clientY,m=0,r=0,n=s.touches.length)}function o(s){if(!(!u||!p)){var g=s.touches[0].clientX,v=s.touches[0].clientY;m=u-g,r=p-v}}function c(s,g,v){for(;s&&s!==d.documentElement;){var b=s.getAttribute(g);if(b)return b;s=s.parentNode}return v}})(window,document);(function(h,d,u){u.endpoint==="results"&&u.ready(function(){d.querySelectorAll("#urls img").forEach(l=>l.addEventListener("error",()=>{l.src=window.searxng.settings.theme_static_path+"/img/img_load_error.svg"},{once:!0})),d.querySelector("#search_url button#copy_url")&&(d.querySelector("#search_url button#copy_url").style.display="block"),u.on(".btn-collapse","click",function(){var l=this.getAttribute("data-btn-text-collapsed"),n=this.getAttribute("data-btn-text-not-collapsed"),e=this.getAttribute("data-target"),t=d.querySelector(e),o=this.innerHTML;this.classList.contains("collapsed")?o=o.replace(l,n):o=o.replace(n,l),this.innerHTML=o,this.classList.toggle("collapsed"),t.classList.toggle("invisible")}),u.on(".media-loader","click",function(){var l=this.getAttribute("data-target"),n=d.querySelector(l+" > iframe"),e=n.getAttribute("src");(e==null||e===!1)&&n.setAttribute("src",n.getAttribute("data-src"))}),u.on("#copy_url","click",function(){var l=this.parentElement.querySelector("pre");navigator.clipboard.writeText(l.innerText),this.innerText=this.dataset.copiedText});let p;const m=d.createElement("div");m.classList.add("loader");const r=new Image,a=(l,n)=>{p&&clearTimeout(p),p=setTimeout(()=>{r.src=l},1e3),r.onload=()=>{n(),m.remove()},r.onerror=()=>{m.remove()}};u.selectImage=l=>{if(d.getElementById("results").classList.add("image-detail-open"),window.location.hash="#image-viewer",u.scrollPageToSelected(),!l)return;const n=l.querySelector(".result-images-source img");if(!n)return;const e=n.getAttribute("data-src");if(!e)return;const t=l.querySelector(".image_thumbnail");n.src=t.src,l.querySelector(".detail").appendChild(m),a(e,()=>{n.src=e,n.removeAttribute("data-src")})},u.closeDetail=function(){d.getElementById("results").classList.remove("image-detail-open"),window.location.hash=="#image-viewer"&&window.history.back(),u.scrollPageToSelected()},u.on(".result-detail-close","click",l=>{l.preventDefault(),u.closeDetail()}),u.on(".result-detail-previous","click",l=>{l.preventDefault(),u.selectPrevious(!1)}),u.on(".result-detail-next","click",l=>{l.preventDefault(),u.selectNext(!1)}),window.addEventListener("hashchange",()=>{window.location.hash!="#image-viewer"&&u.closeDetail()}),d.querySelectorAll(".swipe-horizontal").forEach(l=>{l.addEventListener("swiped-left",function(){u.selectNext(!1)}),l.addEventListener("swiped-right",function(){u.selectPrevious(!1)})}
|