From d246679dbe5eccc5e7d5be50b8c78c76e1f0bebb Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Tue, 31 Aug 2021 15:33:38 +0200 Subject: [build] /static --- searx/static/themes/simple/js/searx.head.js | 1 + .../static/themes/simple/js/searx.head.min.js.map | 2 +- searx/static/themes/simple/js/searx.js | 103 +++++++++++---------- searx/static/themes/simple/js/searx.min.js | 2 +- searx/static/themes/simple/js/searx.min.js.map | 2 +- 5 files changed, 58 insertions(+), 52 deletions(-) (limited to 'searx/static/themes/simple') diff --git a/searx/static/themes/simple/js/searx.head.js b/searx/static/themes/simple/js/searx.head.js index be7560451..0a4fafbce 100644 --- a/searx/static/themes/simple/js/searx.head.js +++ b/searx/static/themes/simple/js/searx.head.js @@ -15,6 +15,7 @@ * (C) 2019 by Alexandre Flament * */ +/* global DocumentTouch:readonly */ (function(w, d) { 'use strict'; diff --git a/searx/static/themes/simple/js/searx.head.min.js.map b/searx/static/themes/simple/js/searx.head.min.js.map index 04525c616..69490193e 100644 --- a/searx/static/themes/simple/js/searx.head.min.js.map +++ b/searx/static/themes/simple/js/searx.head.min.js.map @@ -1 +1 @@ -{"version":3,"file":"searx.head.min.js","sources":["searx.head.js"],"names":["w","d","script","currentScript","scripts","getElementsByTagName","length","searx","touch","DocumentTouch","document","method","getAttribute","autocompleter","search_on_category_select","infinite_scroll","static_path","translations","JSON","parse","className","window"],"mappings":"CAiBA,SAAUA,EAAGC,gBAIT,IAAIC,EAASD,EAAEE,eAAkB,WAC7B,IAAIC,EAAUH,EAAEI,qBAAqB,UACrC,OAAOD,EAAQA,EAAQE,OAAS,GAFH,GAMjCN,EAAEO,MAAQ,CACNC,MAAS,iBAAkBR,GAAMA,EAAES,eAAiBC,oBAAoBD,eAAkB,MAC1FE,OAAQT,EAAOU,aAAa,eAC5BC,cAAeX,EAAOU,aAAa,wBAA0B,OAC7DE,0BAA2BZ,EAAOU,aAAa,oCAAsC,OACrFG,gBAAiBb,EAAOU,aAAa,0BAA4B,OACjEI,YAAad,EAAOU,aAAa,oBACjCK,aAAcC,KAAKC,MAAMjB,EAAOU,aAAa,uBAIjDX,EAAEI,qBAAqB,QAAQ,GAAGe,UAAapB,EAAEO,MAAW,MAAE,WAAW,MArB7E,CAsBGc,OAAQX"} \ No newline at end of file +{"version":3,"file":"searx.head.min.js","sources":["searx.head.js"],"names":["w","d","script","currentScript","scripts","getElementsByTagName","length","searx","touch","DocumentTouch","document","method","getAttribute","autocompleter","search_on_category_select","infinite_scroll","static_path","translations","JSON","parse","className","window"],"mappings":"CAkBA,SAAUA,EAAGC,gBAIT,IAAIC,EAASD,EAAEE,eAAkB,WAC7B,IAAIC,EAAUH,EAAEI,qBAAqB,UACrC,OAAOD,EAAQA,EAAQE,OAAS,GAFH,GAMjCN,EAAEO,MAAQ,CACNC,MAAS,iBAAkBR,GAAMA,EAAES,eAAiBC,oBAAoBD,eAAkB,MAC1FE,OAAQT,EAAOU,aAAa,eAC5BC,cAAeX,EAAOU,aAAa,wBAA0B,OAC7DE,0BAA2BZ,EAAOU,aAAa,oCAAsC,OACrFG,gBAAiBb,EAAOU,aAAa,0BAA4B,OACjEI,YAAad,EAAOU,aAAa,oBACjCK,aAAcC,KAAKC,MAAMjB,EAAOU,aAAa,uBAIjDX,EAAEI,qBAAqB,QAAQ,GAAGe,UAAapB,EAAEO,MAAW,MAAE,WAAW,MArB7E,CAsBGc,OAAQX"} \ No newline at end of file diff --git a/searx/static/themes/simple/js/searx.js b/searx/static/themes/simple/js/searx.js index 5ded864cb..5982a06cf 100644 --- a/searx/static/themes/simple/js/searx.js +++ b/searx/static/themes/simple/js/searx.js @@ -70,7 +70,7 @@ window.searx = (function(w, d) { } }; - searx.http = function(method, url, callback) { + searx.http = function(method, url) { var req = new XMLHttpRequest(), resolve = function() {}, reject = function() {}, @@ -148,21 +148,22 @@ window.searx = (function(w, d) { }; searx.insertBefore = function (newNode, referenceNode) { - element.parentNode.insertBefore(newNode, referenceNode); + referenceNode.parentNode.insertBefore(newNode, referenceNode); }; searx.insertAfter = function(newNode, referenceNode) { - referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); + referenceNode.parentNode.insertAfter(newNode, referenceNode.nextSibling); }; - searx.on('.close', 'click', function(e) { - var el = e.target || e.srcElement; + searx.on('.close', 'click', function() { this.parentNode.classList.add('invisible'); }); return searx; })(window, document); -;searx.ready(function() { +;/*global searx*/ + +searx.ready(function() { searx.on('.result', 'click', function() { highlightResult(this)(true); @@ -244,13 +245,13 @@ window.searx = (function(w, d) { }, 80: { key: 'p', - fun: pageButtonClick(0), + fun: GoToPreviousPage(), des: 'go to previous page', cat: 'Results' }, 78: { key: 'n', - fun: pageButtonClick(1), + fun: GoToNextPage(), des: 'go to next page', cat: 'Results' }, @@ -282,7 +283,7 @@ window.searx = (function(w, d) { searx.on(document, "keydown", function(e) { // check for modifiers so we don't break browser's hotkeys - if (vimKeys.hasOwnProperty(e.keyCode) && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { + if (Object.prototype.hasOwnProperty.call(vimKeys, e.keyCode) && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { var tagName = e.target.tagName.toLowerCase(); if (e.keyCode === 27) { if (tagName === 'input' || tagName === 'select' || tagName === 'textarea') { @@ -380,21 +381,23 @@ window.searx = (function(w, d) { } } - function pageButtonClick(num) { + function pageButtonClick(css_selector) { return function() { - var buttons = $('div#pagination button[type="submit"]'); - if (buttons.length !== 2) { - console.log('page navigation with this theme is not supported'); - return; - } - if (num >= 0 && num < buttons.length) { - buttons[num].click(); - } else { - console.log('pageButtonClick(): invalid argument'); + var button = document.querySelector(css_selector); + if (button) { + button.click(); } }; } + function GoToNextPage() { + return pageButtonClick('nav#pagination .next_page button[type="submit"]'); + } + + function GoToPreviousPage() { + return pageButtonClick('nav#pagination .previous_page button[type="submit"]'); + } + function scrollPageToSelected() { var sel = document.querySelector('.result[data-vim-selected]'); if (sel === null) { @@ -472,9 +475,9 @@ window.searx = (function(w, d) { return; } - var html = '×'; - html += '

How to navigate searx with Vim-like hotkeys

'; - html += ''; + var html = '×'; + html += '

How to navigate searx with Vim-like hotkeys

'; + html += '
'; for (var i = 0; i < sorted.length; i++) { var cat = categories[sorted[i]]; @@ -502,31 +505,31 @@ window.searx = (function(w, d) { } } - html += '
'; + html += ''; - divElement.innerHTML = html; - } + divElement.innerHTML = html; + } function toggleHelp() { - var helpPanel = document.querySelector('#vim-hotkeys-help'); - console.log(helpPanel); - if (helpPanel === undefined || helpPanel === null) { - // first call - helpPanel = document.createElement('div'); - helpPanel.id = 'vim-hotkeys-help'; - helpPanel.className='dialog-modal'; - helpPanel.style='width: 40%'; + var helpPanel = document.querySelector('#vim-hotkeys-help'); + console.log(helpPanel); + if (helpPanel === undefined || helpPanel === null) { + // first call + helpPanel = document.createElement('div'); + helpPanel.id = 'vim-hotkeys-help'; + helpPanel.className='dialog-modal'; + helpPanel.style='width: 40%'; + initHelpContent(helpPanel); initHelpContent(helpPanel); - var body = document.getElementsByTagName('body')[0]; - body.appendChild(helpPanel); - } else { - // togggle hidden - helpPanel.classList.toggle('invisible'); - return; - } - + initHelpContent(helpPanel); + var body = document.getElementsByTagName('body')[0]; + body.appendChild(helpPanel); + } else { + // togggle hidden + helpPanel.classList.toggle('invisible'); + return; + } } - }); ;/** * searx is free software: you can redistribute it and/or modify @@ -545,6 +548,7 @@ window.searx = (function(w, d) { * (C) 2014 by Thomas Pointhuber, * (C) 2017 by Alexandre Flament, */ +/* global L */ (function (w, d, searx) { 'use strict'; @@ -577,7 +581,7 @@ window.searx = (function(w, d) { var osmMapnikAttrib='Map data © OpenStreetMap contributors'; var osmMapnik = new L.TileLayer(osmMapnikUrl, {minZoom: 1, maxZoom: 19, attribution: osmMapnikAttrib}); var osmWikimediaUrl='https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png'; - var osmWikimediaAttrib = 'Wikimedia maps beta | Maps data © OpenStreetMap contributors'; + var osmWikimediaAttrib = 'Wikimedia maps | Maps data © OpenStreetMap contributors'; var osmWikimedia = new L.TileLayer(osmWikimediaUrl, {minZoom: 1, maxZoom: 19, attribution: osmWikimediaAttrib}); // init map view if(map_bounds) { @@ -599,8 +603,8 @@ window.searx = (function(w, d) { map.addLayer(osmMapnik); var baseLayers = { - "OSM Mapnik": osmMapnik/*, - "OSM Wikimedia": osmWikimedia*/ + "OSM Mapnik": osmMapnik, + "OSM Wikimedia": osmWikimedia, }; L.control.layers(baseLayers).addTo(map); @@ -640,7 +644,7 @@ window.searx = (function(w, d) { searx.image_thumbnail_layout = new searx.ImageLayout('#urls', '#urls .result-images', 'img.image_thumbnail', 10, 200); searx.image_thumbnail_layout.watch(); - searx.on('.btn-collapse', 'click', function(event) { + searx.on('.btn-collapse', 'click', function() { var btnLabelCollapsed = this.getAttribute('data-btn-text-collapsed'); var btnLabelNotCollapsed = this.getAttribute('data-btn-text-not-collapsed'); var target = this.getAttribute('data-target'); @@ -656,7 +660,7 @@ window.searx = (function(w, d) { targetElement.classList.toggle('invisible'); }); - searx.on('.media-loader', 'click', function(event) { + searx.on('.media-loader', 'click', function() { var target = this.getAttribute('data-target'); var iframe_load = d.querySelector(target + ' > iframe'); var srctest = iframe_load.getAttribute('src'); @@ -696,6 +700,7 @@ window.searx = (function(w, d) { * * (C) 2017 by Alexandre Flament, */ +/* global AutoComplete */ (function(w, d, searx) { 'use strict'; @@ -738,7 +743,7 @@ window.searx = (function(w, d) { searx.ready(function() { qinput = d.getElementById(qinput_id); - function placeCursorAtEndOnce(e) { + function placeCursorAtEndOnce() { if (firstFocus) { placeCursorAtEnd(qinput); firstFocus = false; @@ -780,7 +785,7 @@ window.searx = (function(w, d) { if (qinput !== null && searx.search_on_category_select) { d.querySelector('.help').className='invisible'; - searx.on('#categories input', 'change', function(e) { + searx.on('#categories input', 'change', function() { var i, categories = d.querySelectorAll('#categories input[type="checkbox"]'); for(i=0; io){break}}break;case"down":i=t.nextElementSibling;if(i===null){i=r[0]}break;case"up":i=t.previousElementSibling;if(i===null){i=r[r.length-1]}break;case"bottom":i=r[r.length-1];break;case"top":default:i=r[0]}}if(i){t.removeAttribute("data-vim-selected");i.setAttribute("data-vim-selected","true");var c=i.querySelector("h3 a")||i.querySelector("a");if(c!==null){c.focus()}if(!e){f()}}}}function e(){document.location.reload(true)}function t(){if(document.activeElement){document.activeElement.blur()}}function i(t){return function(){var e=$('div#pagination button[type="submit"]');if(e.length!==2){console.log("page navigation with this theme is not supported");return}if(t>=0&&ti-o){window.scroll(window.scrollX,i-o)}else{var a=t+n;if(a"}o+="";o+="

"+s[0].cat+"

";o+='
    ';for(var c in s){o+="
  • "+s[c].key+" "+s[c].des+"
  • "}o+="
";o+="";if(!u||l){o+=""}}o+="";e.innerHTML=o}function u(){var e=document.querySelector("#vim-hotkeys-help");console.log(e);if(e===undefined||e===null){e=document.createElement("div");e.id="vim-hotkeys-help";e.className="dialog-modal";e.style="width: 40%";l(e);var t=document.getElementsByTagName("body")[0];t.appendChild(e)}else{e.classList.toggle("invisible");return}}});(function(e,t,n){"use strict";n.ready(function(){n.on(".searx_init_map","click",function(e){this.classList.remove("searx_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 i=L.map(d);var r="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";var o='Map data © OpenStreetMap contributors';var a=new L.TileLayer(r,{minZoom:1,maxZoom:19,attribution:o});var s="https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png";var l='Wikimedia maps beta | Maps data © OpenStreetMap contributors';var u=new L.TileLayer(s,{minZoom:1,maxZoom:19,attribution:l});if(e){setTimeout(function(){i.fitBounds(e,{maxZoom:17})},0)}else if(f&&p){if(h){i.setView(new L.latLng(p,f),h)}else{i.setView(new L.latLng(p,f),8)}}i.addLayer(a);var c={"OSM Mapnik":a};L.control.layers(c).addTo(i);if(g){L.geoJson(g).addTo(i)}});e.preventDefault()})})})(window,document,window.searx);(function(e,a,t){"use strict";t.ready(function(){t.image_thumbnail_layout=new t.ImageLayout("#urls","#urls .result-images","img.image_thumbnail",10,200);t.image_thumbnail_layout.watch();t.on(".btn-collapse","click",function(e){var t=this.getAttribute("data-btn-text-collapsed");var n=this.getAttribute("data-btn-text-not-collapsed");var i=this.getAttribute("data-target");var r=a.querySelector(i);var o=this.innerHTML;if(this.classList.contains("collapsed")){o=o.replace(t,n)}else{o=o.replace(n,t)}this.innerHTML=o;this.classList.toggle("collapsed");r.classList.toggle("invisible")});t.on(".media-loader","click",function(e){var t=this.getAttribute("data-target");var n=a.querySelector(t+" > iframe");var i=n.getAttribute("src");if(i===null||i===undefined||i===false){n.setAttribute("src",n.getAttribute("data-src"))}});e.addEventListener("scroll",function(){var e=a.getElementById("backToTop"),t=document.documentElement.scrollTop||document.body.scrollTop;if(e!==null){if(t>=200){e.style.opacity=1}else{e.style.opacity=0}}})})})(window,document,window.searx);(function(t,i,n){"use strict";var r=true,o="q",a;function s(e){if(e.setSelectionRange){var t=e.value.length;e.setSelectionRange(t,t)}}function l(){if(a.value.length>0){var e=document.getElementById("search");setTimeout(e.submit.bind(e),0)}}function u(e){var t=document.getElementById("clear_search");var n=function(){if(e.value.length===0){t.classList.add("empty")}else{t.classList.remove("empty")}};n();t.addEventListener("click",function(){e.value="";e.focus();n()});e.addEventListener("keyup",n,false)}n.ready(function(){a=i.getElementById(o);function e(e){if(r){s(a);r=false}else{}}if(a!==null){u(a);if(n.autocompleter){n.autocomplete=AutoComplete.call(t,{Url:"./autocompleter",EmptyMessage:n.translations.no_item_found,HttpMethod:n.method,HttpHeaders:{"Content-type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},MinChars:4,Delay:300},"#"+o);t.addEventListener("resize",function(){var e=new CustomEvent("position");a.dispatchEvent(e)})}a.addEventListener("focus",e,false);a.focus()}if(a!==null&&n.search_on_category_select){i.querySelector(".help").className="invisible";n.on("#categories input","change",function(e){var t,n=i.querySelectorAll('#categories input[type="checkbox"]');for(t=0;to){break}}break;case"down":i=t.nextElementSibling;if(i===null){i=r[0]}break;case"up":i=t.previousElementSibling;if(i===null){i=r[r.length-1]}break;case"bottom":i=r[r.length-1];break;case"top":default:i=r[0]}}if(i){t.removeAttribute("data-vim-selected");i.setAttribute("data-vim-selected","true");var c=i.querySelector("h3 a")||i.querySelector("a");if(c!==null){c.focus()}if(!e){f()}}}}function e(){document.location.reload(true)}function t(){if(document.activeElement){document.activeElement.blur()}}function i(t){return function(){var e=document.querySelector(t);if(e){e.click()}}}function r(){return i('nav#pagination .next_page button[type="submit"]')}function o(){return i('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,i=e.offsetTop,r=i+e.clientHeight,o=120;if(e.previousElementSibling===null&&ri-o){window.scroll(window.scrollX,i-o)}else{var a=t+n;if(a"}o+="";o+="

"+s[0].cat+"

";o+='
    ';for(var c in s){o+="
  • "+s[c].key+" "+s[c].des+"
  • "}o+="
";o+="";if(!u||l){o+=""}}o+="";e.innerHTML=o}function p(){var e=document.querySelector("#vim-hotkeys-help");console.log(e);if(e===undefined||e===null){e=document.createElement("div");e.id="vim-hotkeys-help";e.className="dialog-modal";e.style="width: 40%";c(e);c(e);c(e);var t=document.getElementsByTagName("body")[0];t.appendChild(e)}else{e.classList.toggle("invisible");return}}});(function(e,t,n){"use strict";n.ready(function(){n.on(".searx_init_map","click",function(e){this.classList.remove("searx_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 i=L.map(d);var r="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";var o='Map data © OpenStreetMap contributors';var a=new L.TileLayer(r,{minZoom:1,maxZoom:19,attribution:o});var s="https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png";var l='Wikimedia maps | Maps data © OpenStreetMap contributors';var u=new L.TileLayer(s,{minZoom:1,maxZoom:19,attribution:l});if(e){setTimeout(function(){i.fitBounds(e,{maxZoom:17})},0)}else if(f&&p){if(h){i.setView(new L.latLng(p,f),h)}else{i.setView(new L.latLng(p,f),8)}}i.addLayer(a);var c={"OSM Mapnik":a,"OSM Wikimedia":u};L.control.layers(c).addTo(i);if(g){L.geoJson(g).addTo(i)}});e.preventDefault()})})})(window,document,window.searx);(function(e,o,t){"use strict";t.ready(function(){t.image_thumbnail_layout=new t.ImageLayout("#urls","#urls .result-images","img.image_thumbnail",10,200);t.image_thumbnail_layout.watch();t.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 i=o.querySelector(n);var r=this.innerHTML;if(this.classList.contains("collapsed")){r=r.replace(e,t)}else{r=r.replace(t,e)}this.innerHTML=r;this.classList.toggle("collapsed");i.classList.toggle("invisible")});t.on(".media-loader","click",function(){var e=this.getAttribute("data-target");var t=o.querySelector(e+" > iframe");var n=t.getAttribute("src");if(n===null||n===undefined||n===false){t.setAttribute("src",t.getAttribute("data-src"))}});e.addEventListener("scroll",function(){var e=o.getElementById("backToTop"),t=document.documentElement.scrollTop||document.body.scrollTop;if(e!==null){if(t>=200){e.style.opacity=1}else{e.style.opacity=0}}})})})(window,document,window.searx);(function(t,n,i){"use strict";var r=true,o="q",a;function s(e){if(e.setSelectionRange){var t=e.value.length;e.setSelectionRange(t,t)}}function l(){if(a.value.length>0){var e=document.getElementById("search");setTimeout(e.submit.bind(e),0)}}function u(e){var t=document.getElementById("clear_search");var n=function(){if(e.value.length===0){t.classList.add("empty")}else{t.classList.remove("empty")}};n();t.addEventListener("click",function(){e.value="";e.focus();n()});e.addEventListener("keyup",n,false)}i.ready(function(){a=n.getElementById(o);function e(){if(r){s(a);r=false}else{}}if(a!==null){u(a);if(i.autocompleter){i.autocomplete=AutoComplete.call(t,{Url:"./autocompleter",EmptyMessage:i.translations.no_item_found,HttpMethod:i.method,HttpHeaders:{"Content-type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},MinChars:4,Delay:300},"#"+o);t.addEventListener("resize",function(){var e=new CustomEvent("position");a.dispatchEvent(e)})}a.addEventListener("focus",e,false);a.focus()}if(a!==null&&i.search_on_category_select){n.querySelector(".help").className="invisible";i.on("#categories input","change",function(){var e,t=n.querySelectorAll('#categories input[type="checkbox"]');for(e=0;e