summaryrefslogtreecommitdiff
path: root/searx/static/themes/simple/js
diff options
context:
space:
mode:
Diffstat (limited to 'searx/static/themes/simple/js')
-rw-r--r--searx/static/themes/simple/js/searx.head.js40
-rw-r--r--searx/static/themes/simple/js/searx.head.min.js4
-rw-r--r--searx/static/themes/simple/js/searx.head.min.js.map1
-rw-r--r--searx/static/themes/simple/js/searx.js1573
-rw-r--r--searx/static/themes/simple/js/searx.min.js25
-rw-r--r--searx/static/themes/simple/js/searx.min.js.map1
-rw-r--r--searx/static/themes/simple/js/searx_head/00_init.js40
-rw-r--r--searx/static/themes/simple/js/searx_src/00_searx_toolkit.js164
-rw-r--r--searx/static/themes/simple/js/searx_src/autocomplete.js536
-rw-r--r--searx/static/themes/simple/js/searx_src/searx_imageresult.js151
-rw-r--r--searx/static/themes/simple/js/searx_src/searx_keyboard.js366
-rw-r--r--searx/static/themes/simple/js/searx_src/searx_mapresult.js176
-rw-r--r--searx/static/themes/simple/js/searx_src/searx_results.js63
-rw-r--r--searx/static/themes/simple/js/searx_src/searx_search.js117
14 files changed, 3257 insertions, 0 deletions
diff --git a/searx/static/themes/simple/js/searx.head.js b/searx/static/themes/simple/js/searx.head.js
new file mode 100644
index 000000000..3ac61c8ae
--- /dev/null
+++ b/searx/static/themes/simple/js/searx.head.js
@@ -0,0 +1,40 @@
+/**
+* searx is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2019 by Alexandre Flament
+*
+*/
+(function(w, d) {
+ 'use strict';
+
+ // add data- properties
+ var script = d.currentScript || (function() {
+ var scripts = d.getElementsByTagName('script');
+ return scripts[scripts.length - 1];
+ })();
+
+ // try to detect touch screen
+ w.searx = {
+ touch: (("ontouchstart" in w) || w.DocumentTouch && document instanceof DocumentTouch) || false,
+ method: script.getAttribute('data-method'),
+ autocompleter: script.getAttribute('data-autocompleter') === 'true',
+ search_on_category_select: script.getAttribute('data-search-on-category-select') === 'true',
+ infinite_scroll: script.getAttribute('data-infinite-scroll') === 'true',
+ static_path: script.getAttribute('data-static-path'),
+ no_item_found: script.getAttribute('data-no-item-found')
+ }
+
+ // update the css
+ d.getElementsByTagName("html")[0].className = (w.searx.touch)?"js touch":"js";
+})(window, document); \ No newline at end of file
diff --git a/searx/static/themes/simple/js/searx.head.min.js b/searx/static/themes/simple/js/searx.head.min.js
new file mode 100644
index 000000000..00c711c79
--- /dev/null
+++ b/searx/static/themes/simple/js/searx.head.min.js
@@ -0,0 +1,4 @@
+/*! simple/searx.min.js | 06-08-2019 | https://github.com/asciimoo/searx */
+
+(function(t,e){"use strict";var a=e.currentScript||function(){var t=e.getElementsByTagName("script");return t[t.length-1]}();t.searx={touch:"ontouchstart"in t||t.DocumentTouch&&document instanceof DocumentTouch||false,method:a.getAttribute("data-method"),autocompleter:a.getAttribute("data-autocompleter")==="true",search_on_category_select:a.getAttribute("data-search-on-category-select")==="true",infinite_scroll:a.getAttribute("data-infinite-scroll")==="true",static_path:a.getAttribute("data-static-path"),no_item_found:a.getAttribute("data-no-item-found")};e.getElementsByTagName("html")[0].className=t.searx.touch?"js touch":"js"})(window,document);
+//# sourceMappingURL=searx.head.min.js.map \ No newline at end of file
diff --git a/searx/static/themes/simple/js/searx.head.min.js.map b/searx/static/themes/simple/js/searx.head.min.js.map
new file mode 100644
index 000000000..d19ad5a44
--- /dev/null
+++ b/searx/static/themes/simple/js/searx.head.min.js.map
@@ -0,0 +1 @@
+{"version":3,"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","no_item_found","className","window"],"mappings":";;CAiBA,SAAUA,EAAGC,GACT,aAGA,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,cAAef,EAAOU,aAAa,uBAIvCX,EAAEI,qBAAqB,QAAQ,GAAGa,UAAalB,EAAEO,MAAW,MAAE,WAAW,MArB7E,CAsBGY,OAAQT","file":"searx.head.min.js"} \ No newline at end of file
diff --git a/searx/static/themes/simple/js/searx.js b/searx/static/themes/simple/js/searx.js
new file mode 100644
index 000000000..e191f2487
--- /dev/null
+++ b/searx/static/themes/simple/js/searx.js
@@ -0,0 +1,1573 @@
+/**
+* searx is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2017 by Alexandre Flament, <alex@al-f.net>
+*
+*/
+window.searx = (function(w, d) {
+
+ 'use strict';
+
+ // not invented here tookit with bugs fixed elsewhere
+ // purposes : be just good enough and as small as possible
+
+ // from https://plainjs.com/javascript/events/live-binding-event-handlers-14/
+ if (w.Element) {
+ (function(ElementPrototype) {
+ ElementPrototype.matches = ElementPrototype.matches ||
+ ElementPrototype.matchesSelector ||
+ ElementPrototype.webkitMatchesSelector ||
+ ElementPrototype.msMatchesSelector ||
+ function(selector) {
+ var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;
+ while (nodes[++i] && nodes[i] != node);
+ return !!nodes[i];
+ };
+ })(Element.prototype);
+ }
+
+ function callbackSafe(callback, el, e) {
+ try {
+ callback.call(el, e);
+ } catch (exception) {
+ console.log(exception);
+ }
+ }
+
+ var searx = window.searx || {};
+
+ searx.on = function(obj, eventType, callback, useCapture) {
+ useCapture = useCapture || false;
+ if (typeof obj !== 'string') {
+ // obj HTMLElement, HTMLDocument
+ obj.addEventListener(eventType, callback, useCapture);
+ } else {
+ // obj is a selector
+ d.addEventListener(eventType, function(e) {
+ var el = e.target || e.srcElement, found = false;
+ while (el && el.matches && el !== d && !(found = el.matches(obj))) el = el.parentElement;
+ if (found) callbackSafe(callback, el, e);
+ }, useCapture);
+ }
+ };
+
+ searx.ready = function(callback) {
+ if (document.readyState != 'loading') {
+ callback.call(w);
+ } else {
+ w.addEventListener('DOMContentLoaded', callback.bind(w));
+ }
+ };
+
+ searx.http = function(method, url, callback) {
+ var req = new XMLHttpRequest(),
+ resolve = function() {},
+ reject = function() {},
+ promise = {
+ then: function(callback) { resolve = callback; return promise; },
+ catch: function(callback) { reject = callback; return promise; }
+ };
+
+ try {
+ req.open(method, url, true);
+
+ // On load
+ req.onload = function() {
+ if (req.status == 200) {
+ resolve(req.response, req.responseType);
+ } else {
+ reject(Error(req.statusText));
+ }
+ };
+
+ // Handle network errors
+ req.onerror = function() {
+ reject(Error("Network Error"));
+ };
+
+ req.onabort = function() {
+ reject(Error("Transaction is aborted"));
+ };
+
+ // Make the request
+ req.send();
+ } catch (ex) {
+ reject(ex);
+ }
+
+ return promise;
+ };
+
+ searx.loadStyle = function(src) {
+ var path = searx.static_path + src,
+ id = "style_" + src.replace('.', '_'),
+ s = d.getElementById(id);
+ if (s === null) {
+ s = d.createElement('link');
+ s.setAttribute('id', id);
+ s.setAttribute('rel', 'stylesheet');
+ s.setAttribute('type', 'text/css');
+ s.setAttribute('href', path);
+ d.body.appendChild(s);
+ }
+ };
+
+ searx.loadScript = function(src, callback) {
+ var path = searx.static_path + src,
+ id = "script_" + src.replace('.', '_'),
+ s = d.getElementById(id);
+ if (s === null) {
+ s = d.createElement('script');
+ s.setAttribute('id', id);
+ s.setAttribute('src', path);
+ s.onload = callback;
+ s.onerror = function() {
+ s.setAttribute('error', '1');
+ };
+ d.body.appendChild(s);
+ } else if (!s.hasAttribute('error')) {
+ try {
+ callback.apply(s, []);
+ } catch (exception) {
+ console.log(exception);
+ }
+ } else {
+ console.log("callback not executed : script '" + path + "' not loaded.");
+ }
+ };
+
+ searx.insertBefore = function (newNode, referenceNode) {
+ element.parentNode.insertBefore(newNode, referenceNode);
+ };
+
+ searx.insertAfter = function(newNode, referenceNode) {
+ referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
+ };
+
+ searx.on('.close', 'click', function(e) {
+ var el = e.target || e.srcElement;
+ this.parentNode.classList.add('invisible');
+ });
+
+ return searx;
+})(window, document);
+;(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AutoComplete = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+/*
+ * @license MIT
+ *
+ * Autocomplete.js v2.6.3
+ * Developed by Baptiste Donaux
+ * http://autocomplete-js.com
+ *
+ * (c) 2017, Baptiste Donaux
+ */
+"use strict";
+var ConditionOperator;
+(function (ConditionOperator) {
+ ConditionOperator[ConditionOperator["AND"] = 0] = "AND";
+ ConditionOperator[ConditionOperator["OR"] = 1] = "OR";
+})(ConditionOperator || (ConditionOperator = {}));
+var EventType;
+(function (EventType) {
+ EventType[EventType["KEYDOWN"] = 0] = "KEYDOWN";
+ EventType[EventType["KEYUP"] = 1] = "KEYUP";
+})(EventType || (EventType = {}));
+/**
+ * Core
+ *
+ * @class
+ * @author Baptiste Donaux <baptiste.donaux@gmail.com> @baptistedonaux
+ */
+var AutoComplete = (function () {
+ // Constructor
+ function AutoComplete(params, selector) {
+ if (params === void 0) { params = {}; }
+ if (selector === void 0) { selector = "[data-autocomplete]"; }
+ if (Array.isArray(selector)) {
+ selector.forEach(function (s) {
+ new AutoComplete(params, s);
+ });
+ }
+ else if (typeof selector == "string") {
+ var elements = document.querySelectorAll(selector);
+ Array.prototype.forEach.call(elements, function (input) {
+ new AutoComplete(params, input);
+ });
+ }
+ else {
+ var specificParams = AutoComplete.merge(AutoComplete.defaults, params, {
+ DOMResults: document.createElement("div")
+ });
+ AutoComplete.prototype.create(specificParams, selector);
+ return specificParams;
+ }
+ }
+ AutoComplete.prototype.create = function (params, element) {
+ params.Input = element;
+ if (params.Input.nodeName.match(/^INPUT$/i) && (params.Input.hasAttribute("type") === false || params.Input.getAttribute("type").match(/^TEXT|SEARCH$/i))) {
+ params.Input.setAttribute("autocomplete", "off");
+ params._Position(params);
+ params.Input.parentNode.appendChild(params.DOMResults);
+ params.$Listeners = {
+ blur: params._Blur.bind(params),
+ destroy: AutoComplete.prototype.destroy.bind(null, params),
+ focus: params._Focus.bind(params),
+ keyup: AutoComplete.prototype.event.bind(null, params, EventType.KEYUP),
+ keydown: AutoComplete.prototype.event.bind(null, params, EventType.KEYDOWN),
+ position: params._Position.bind(params)
+ };
+ for (var event in params.$Listeners) {
+ params.Input.addEventListener(event, params.$Listeners[event]);
+ }
+ }
+ };
+ AutoComplete.prototype.getEventsByType = function (params, type) {
+ var mappings = {};
+ for (var key in params.KeyboardMappings) {
+ var event = EventType.KEYUP;
+ if (params.KeyboardMappings[key].Event !== undefined) {
+ event = params.KeyboardMappings[key].Event;
+ }
+ if (event == type) {
+ mappings[key] = params.KeyboardMappings[key];
+ }
+ }
+ return mappings;
+ };
+ AutoComplete.prototype.event = function (params, type, event) {
+ var eventIdentifier = function (condition) {
+ if ((match === true && mapping.Operator == ConditionOperator.AND) || (match === false && mapping.Operator == ConditionOperator.OR)) {
+ condition = AutoComplete.merge({
+ Not: false
+ }, condition);
+ if (condition.hasOwnProperty("Is")) {
+ if (condition.Is == event.keyCode) {
+ match = !condition.Not;
+ }
+ else {
+ match = condition.Not;
+ }
+ }
+ else if (condition.hasOwnProperty("From") && condition.hasOwnProperty("To")) {
+ if (event.keyCode >= condition.From && event.keyCode <= condition.To) {
+ match = !condition.Not;
+ }
+ else {
+ match = condition.Not;
+ }
+ }
+ }
+ };
+ for (var name in AutoComplete.prototype.getEventsByType(params, type)) {
+ var mapping = AutoComplete.merge({
+ Operator: ConditionOperator.AND
+ }, params.KeyboardMappings[name]), match = ConditionOperator.AND == mapping.Operator;
+ mapping.Conditions.forEach(eventIdentifier);
+ if (match === true) {
+ mapping.Callback.call(params, event);
+ }
+ }
+ };
+ AutoComplete.prototype.makeRequest = function (params, callback) {
+ var propertyHttpHeaders = Object.getOwnPropertyNames(params.HttpHeaders), request = new XMLHttpRequest(), method = params._HttpMethod(), url = params._Url(), queryParams = params._Pre(), queryParamsStringify = encodeURIComponent(params._QueryArg()) + "=" + encodeURIComponent(queryParams);
+ if (method.match(/^GET$/i)) {
+ if (url.indexOf("?") !== -1) {
+ url += "&" + queryParamsStringify;
+ }
+ else {
+ url += "?" + queryParamsStringify;
+ }
+ }
+ request.open(method, url, true);
+ for (var i = propertyHttpHeaders.length - 1; i >= 0; i--) {
+ request.setRequestHeader(propertyHttpHeaders[i], params.HttpHeaders[propertyHttpHeaders[i]]);
+ }
+ request.onreadystatechange = function () {
+ if (request.readyState == 4 && request.status == 200) {
+ params.$Cache[queryParams] = request.response;
+ callback(request.response);
+ }
+ };
+ return request;
+ };
+ AutoComplete.prototype.ajax = function (params, request, timeout) {
+ if (timeout === void 0) { timeout = true; }
+ if (params.$AjaxTimer) {
+ window.clearTimeout(params.$AjaxTimer);
+ }
+ if (timeout === true) {
+ params.$AjaxTimer = window.setTimeout(AutoComplete.prototype.ajax.bind(null, params, request, false), params.Delay);
+ }
+ else {
+ if (params.Request) {
+ params.Request.abort();
+ }
+ params.Request = request;
+ params.Request.send(params._QueryArg() + "=" + params._Pre());
+ }
+ };
+ AutoComplete.prototype.cache = function (params, callback) {
+ var response = params._Cache(params._Pre());
+ if (response === undefined) {
+ var request = AutoComplete.prototype.makeRequest(params, callback);
+ AutoComplete.prototype.ajax(params, request);
+ }
+ else {
+ callback(response);
+ }
+ };
+ AutoComplete.prototype.destroy = function (params) {
+ for (var event in params.$Listeners) {
+ params.Input.removeEventListener(event, params.$Listeners[event]);
+ }
+ params.DOMResults.parentNode.removeChild(params.DOMResults);
+ };
+ return AutoComplete;
+}());
+AutoComplete.merge = function () {
+ var merge = {}, tmp;
+ for (var i = 0; i < arguments.length; i++) {
+ for (tmp in arguments[i]) {
+ merge[tmp] = arguments[i][tmp];
+ }
+ }
+ return merge;
+};
+AutoComplete.defaults = {
+ Delay: 150,
+ EmptyMessage: "No result here",
+ Highlight: {
+ getRegex: function (value) {
+ return new RegExp(value, "ig");
+ },
+ transform: function (value) {
+ return "<strong>" + value + "</strong>";
+ }
+ },
+ HttpHeaders: {
+ "Content-type": "application/x-www-form-urlencoded"
+ },
+ Limit: 0,
+ MinChars: 0,
+ HttpMethod: "GET",
+ QueryArg: "q",
+ Url: null,
+ KeyboardMappings: {
+ "Enter": {
+ Conditions: [{
+ Is: 13,
+ Not: false
+ }],
+ Callback: function (event) {
+ if (this.DOMResults.getAttribute("class").indexOf("open") != -1) {
+ var liActive = this.DOMResults.querySelector("li.active");
+ if (liActive !== null) {
+ event.preventDefault();
+ this._Select(liActive);
+ this.DOMResults.setAttribute("class", "autocomplete");
+ }
+ }
+ },
+ Operator: ConditionOperator.AND,
+ Event: EventType.KEYDOWN
+ },
+ "KeyUpAndDown_down": {
+ Conditions: [{
+ Is: 38,
+ Not: false
+ },
+ {
+ Is: 40,
+ Not: false
+ }],
+ Callback: function (event) {
+ event.preventDefault();
+ },
+ Operator: ConditionOperator.OR,
+ Event: EventType.KEYDOWN
+ },
+ "KeyUpAndDown_up": {
+ Conditions: [{
+ Is: 38,
+ Not: false
+ },
+ {
+ Is: 40,
+ Not: false
+ }],
+ Callback: function (event) {
+ event.preventDefault();
+ var first = this.DOMResults.querySelector("li:first-child:not(.locked)"), last = this.DOMResults.querySelector("li:last-child:not(.locked)"), active = this.DOMResults.querySelector("li.active");
+ if (active) {
+ var currentIndex = Array.prototype.indexOf.call(active.parentNode.children, active), position = currentIndex + (event.keyCode - 39), lisCount = this.DOMResults.getElementsByTagName("li").length;
+ if (position < 0) {
+ position = lisCount - 1;
+ }
+ else if (position >= lisCount) {
+ position = 0;
+ }
+ active.classList.remove("active");
+ active.parentElement.children.item(position).classList.add("active");
+ }
+ else if (last && event.keyCode == 38) {
+ last.classList.add("active");
+ }
+ else if (first) {
+ first.classList.add("active");
+ }
+ },
+ Operator: ConditionOperator.OR,
+ Event: EventType.KEYUP
+ },
+ "AlphaNum": {
+ Conditions: [{
+ Is: 13,
+ Not: true
+ }, {
+ From: 35,
+ To: 40,
+ Not: true
+ }],
+ Callback: function () {
+ var oldValue = this.Input.getAttribute("data-autocomplete-old-value"), currentValue = this._Pre();
+ if (currentValue !== "" && currentValue.length >= this._MinChars()) {
+ if (!oldValue || currentValue != oldValue) {
+ this.DOMResults.setAttribute("class", "autocomplete open");
+ }
+ AutoComplete.prototype.cache(this, function (response) {
+ this._Render(this._Post(response));
+ this._Open();
+ }.bind(this));
+ }
+ },
+ Operator: ConditionOperator.AND,
+ Event: EventType.KEYUP
+ }
+ },
+ DOMResults: null,
+ Request: null,
+ Input: null,
+ /**
+ * Return the message when no result returns
+ */
+ _EmptyMessage: function () {
+ var emptyMessage = "";
+ if (this.Input.hasAttribute("data-autocomplete-empty-message")) {
+ emptyMessage = this.Input.getAttribute("data-autocomplete-empty-message");
+ }
+ else if (this.EmptyMessage !== false) {
+ emptyMessage = this.EmptyMessage;
+ }
+ else {
+ emptyMessage = "";
+ }
+ return emptyMessage;
+ },
+ /**
+ * Returns the maximum number of results
+ */
+ _Limit: function () {
+ var limit = this.Input.getAttribute("data-autocomplete-limit");
+ if (isNaN(limit) || limit === null) {
+ return this.Limit;
+ }
+ return parseInt(limit, 10);
+ },
+ /**
+ * Returns the minimum number of characters entered before firing ajax
+ */
+ _MinChars: function () {
+ var minchars = this.Input.getAttribute("data-autocomplete-minchars");
+ if (isNaN(minchars) || minchars === null) {
+ return this.MinChars;
+ }
+ return parseInt(minchars, 10);
+ },
+ /**
+ * Apply transformation on labels response
+ */
+ _Highlight: function (label) {
+ return label.replace(this.Highlight.getRegex(this._Pre()), this.Highlight.transform);
+ },
+ /**
+ * Returns the HHTP method to use
+ */
+ _HttpMethod: function () {
+ if (this.Input.hasAttribute("data-autocomplete-method")) {
+ return this.Input.getAttribute("data-autocomplete-method");
+ }
+ return this.HttpMethod;
+ },
+ /**
+ * Returns the query param to use
+ */
+ _QueryArg: function () {
+ if (this.Input.hasAttribute("data-autocomplete-param-name")) {
+ return this.Input.getAttribute("data-autocomplete-param-name");
+ }
+ return this.QueryArg;
+ },
+ /**
+ * Returns the URL to use for AJAX request
+ */
+ _Url: function () {
+ if (this.Input.hasAttribute("data-autocomplete")) {
+ return this.Input.getAttribute("data-autocomplete");
+ }
+ return this.Url;
+ },
+ /**
+ * Manage the close
+ */
+ _Blur: function (now) {
+ if (now === true) {
+ this.DOMResults.setAttribute("class", "autocomplete");
+ this.Input.setAttribute("data-autocomplete-old-value", this.Input.value);
+ }
+ else {
+ var params = this;
+ setTimeout(function () {
+ params._Blur(true);
+ }, 150);
+ }
+ },
+ /**
+ * Manage the cache
+ */
+ _Cache: function (value) {
+ return this.$Cache[value];
+ },
+ /**
+ * Manage the open
+ */
+ _Focus: function () {
+ var oldValue = this.Input.getAttribute("data-autocomplete-old-value");
+ if ((!oldValue || this.Input.value != oldValue) && this._MinChars() <= this.Input.value.length) {
+ this.DOMResults.setAttribute("class", "autocomplete open");
+ }
+ },
+ /**
+ * Bind all results item if one result is opened
+ */
+ _Open: function () {
+ var params = this;
+ Array.prototype.forEach.call(this.DOMResults.getElementsByTagName("li"), function (li) {
+ if (li.getAttribute("class") != "locked") {
+ li.onclick = function (event) {
+ params._Select(li);
+ };
+ li.onmouseenter = function () {
+ var active = params.DOMResults.querySelector("li.active");
+ if (active !== li) {
+ if (active !== null) {
+ active.classList.remove("active");
+ }
+ li.classList.add("active");
+ }
+ };
+ }
+ });
+ },
+ /**
+ * Position the results HTML element
+ */
+ _Position: function () {
+ this.DOMResults.setAttribute("class", "autocomplete");
+ this.DOMResults.setAttribute("style", "top:" + (this.Input.offsetTop + this.Input.offsetHeight) + "px;left:" + this.Input.offsetLeft + "px;width:" + this.Input.clientWidth + "px;");
+ },
+ /**
+ * Execute the render of results DOM element
+ */
+ _Render: function (response) {
+ var ul;
+ if (typeof response == "string") {
+ ul = this._RenderRaw(response);
+ }
+ else {
+ ul = this._RenderResponseItems(response);
+ }
+ if (this.DOMResults.hasChildNodes()) {
+ this.DOMResults.removeChild(this.DOMResults.childNodes[0]);
+ }
+ this.DOMResults.appendChild(ul);
+ },
+ /**
+ * ResponseItems[] rendering
+ */
+ _RenderResponseItems: function (response) {
+ var ul = document.createElement("ul"), li = document.createElement("li"), limit = this._Limit();
+ // Order
+ if (limit < 0) {
+ response = response.reverse();
+ }
+ else if (limit === 0) {
+ limit = response.length;
+ }
+ for (var item = 0; item < Math.min(Math.abs(limit), response.length); item++) {
+ li.innerHTML = response[item].Label;
+ li.setAttribute("data-autocomplete-value", response[item].Value);
+ ul.appendChild(li);
+ li = document.createElement("li");
+ }
+ return ul;
+ },
+ /**
+ * string response rendering (RAW HTML)
+ */
+ _RenderRaw: function (response) {
+ var ul = document.createElement("ul"), li = document.createElement("li");
+ if (response.length > 0) {
+ this.DOMResults.innerHTML = response;
+ }
+ else {
+ var emptyMessage = this._EmptyMessage();
+ if (emptyMessage !== "") {
+ li.innerHTML = emptyMessage;
+ li.setAttribute("class", "locked");
+ ul.appendChild(li);
+ }
+ }
+ return ul;
+ },
+ /**
+ * Deal with request response
+ */
+ _Post: function (response) {
+ try {
+ var returnResponse = [];
+ //JSON return
+ var json = JSON.parse(response);
+ if (Object.keys(json).length === 0) {
+ return "";
+ }
+ if (Array.isArray(json)) {
+ for (var i = 0; i < Object.keys(json).length; i++) {
+ returnResponse[returnResponse.length] = { "Value": json[i], "Label": this._Highlight(json[i]) };
+ }
+ }
+ else {
+ for (var value in json) {
+ returnResponse.push({
+ "Value": value,
+ "Label": this._Highlight(json[value])
+ });
+ }
+ }
+ return returnResponse;
+ }
+ catch (event) {
+ //HTML return
+ return response;
+ }
+ },
+ /**
+ * Return the autocomplete value to send (before request)
+ */
+ _Pre: function () {
+ return this.Input.value;
+ },
+ /**
+ * Choice one result item
+ */
+ _Select: function (item) {
+ console.log('test test test');
+ if (item.hasAttribute("data-autocomplete-value")) {
+ this.Input.value = item.getAttribute("data-autocomplete-value");
+ }
+ else {
+ this.Input.value = item.innerHTML;
+ }
+ this.Input.setAttribute("data-autocomplete-old-value", this.Input.value);
+ },
+ $AjaxTimer: null,
+ $Cache: {},
+ $Listeners: {}
+};
+module.exports = AutoComplete;
+
+},{}]},{},[1])(1)
+});
+;/**
+*
+* Google Image Layout v0.0.1
+* Description, by Anh Trinh.
+* Heavily modified for searx
+* http://trinhtrunganh.com
+*
+* @license Free to use under the MIT License.
+*
+*/
+(function(w, d) {
+ 'use strict';
+
+ function ImageLayout(container_selector, results_selector, img_selector, maxHeight) {
+ this.container_selector = container_selector;
+ this.results_selector = results_selector;
+ this.img_selector = img_selector;
+ this.margin = 10;
+ this.maxHeight = maxHeight;
+ this._alignAllDone = true;
+ }
+
+ /**
+ * Get the height that make all images fit the container
+ *
+ * width = w1 + w2 + w3 + ... = r1*h + r2*h + r3*h + ...
+ *
+ * @param {[type]} images the images to be calculated
+ * @param {[type]} width the container witdth
+ * @param {[type]} margin the margin between each image
+ *
+ * @return {[type]} the height
+ */
+ ImageLayout.prototype._getHeigth = function(images, width) {
+ var r = 0,
+ img;
+
+ width -= images.length * this.margin;
+ for (var i = 0; i < images.length; i++) {
+ img = images[i];
+ if ((img.naturalWidth > 0) && (img.naturalHeight > 0)) {
+ r += img.naturalWidth / img.naturalHeight;
+ } else {
+ // assume that not loaded images are square
+ r += 1;
+ }
+ }
+
+ return width / r; //have to round down because Firefox will automatically roundup value with number of decimals > 3
+ };
+
+ ImageLayout.prototype._setSize = function(images, height) {
+ var img, imgWidth, imagesLength = images.length;
+ for (var i = 0; i < imagesLength; i++) {
+ img = images[i];
+ if ((img.naturalWidth > 0) && (img.naturalHeight > 0)) {
+ imgWidth = height * img.naturalWidth / img.naturalHeight;
+ } else {
+ // not loaded image : make it square as _getHeigth said it
+ imgWidth = height;
+ }
+ img.style.width = imgWidth + 'px';
+ img.style.height = height + 'px';
+ img.style.marginLeft = '3px';
+ img.style.marginTop = '3px';
+ img.style.marginRight = this.margin - 7 + 'px'; // -4 is the negative margin of the inline element
+ img.style.marginBottom = this.margin - 7 + 'px';
+ }
+ };
+
+ ImageLayout.prototype._alignImgs = function(imgGroup) {
+ var slice, h,
+ containerWidth = d.querySelector(this.container_selector).clientWidth;
+
+ w: while (imgGroup.length > 0) {
+ for (var i = 1; i <= imgGroup.length; i++) {
+ slice = imgGroup.slice(0, i);
+ h = this._getHeigth(slice, containerWidth);
+ if (h < this.maxHeight) {
+ this._setSize(slice, h);
+ imgGroup = imgGroup.slice(i);
+ continue w;
+ }
+ }
+ this._setSize(slice, Math.min(this.maxHeight, h));
+ break;
+ }
+ };
+
+ ImageLayout.prototype.align = function(results_selector) {
+ var results_selectorNode = d.querySelectorAll(this.results_selector),
+ results_length = results_selectorNode.length,
+ previous = null,
+ current = null,
+ imgGroup = [];
+ for (var i = 0; i < results_length; i++) {
+ current = results_selectorNode[i];
+ if (current.previousElementSibling !== previous && imgGroup.length > 0) {
+ // the current image is not conected to previous one
+ // so the current image is the start of a new group of images.
+ // so call _alignImgs to align the current group
+ this._alignImgs(imgGroup);
+ // and start a new empty group of images
+ imgGroup = [];
+ }
+ // add the current image to the group (only the img tag)
+ imgGroup.push(current.querySelector(this.img_selector));
+ // update the previous variable
+ previous = current;
+ }
+ // align the remaining images
+ if (imgGroup.length > 0) {
+ this._alignImgs(imgGroup);
+ }
+ };
+
+ ImageLayout.prototype.watch = function() {
+ var i, img, imgGroup, imgNodeLength,
+ obj = this,
+ results_nodes = d.querySelectorAll(this.results_selector),
+ results_length = results_nodes.length;
+
+ function align(e) {
+ obj.align();
+ }
+
+ function throttleAlign(e) {
+ if (obj._alignAllDone) {
+ obj._alignAllDone = false;
+ setTimeout(function() {
+ obj.align();
+ obj._alignAllDone = true;
+ }, 100);
+ }
+ }
+
+ w.addEventListener('resize', throttleAlign);
+ w.addEventListener('pageshow', align);
+
+ for (i = 0; i < results_length; i++) {
+ img = results_nodes[i].querySelector(this.img_selector);
+ if (typeof img !== 'undefined') {
+ img.addEventListener('load', throttleAlign);
+ img.addEventListener('error', throttleAlign);
+ }
+ }
+ };
+
+ w.searx.ImageLayout = ImageLayout;
+
+})(window, document);
+;searx.ready(function() {
+
+ searx.on('.result', 'click', function() {
+ highlightResult(this)(true);
+ });
+
+ searx.on('.result a', 'focus', function(e) {
+ var el = e.target;
+ while (el !== undefined) {
+ if (el.classList.contains('result')) {
+ if (el.getAttribute("data-vim-selected") === null) {
+ highlightResult(el)(true);
+ }
+ break;
+ }
+ el = el.parentNode;
+ }
+ }, true);
+
+ var vimKeys = {
+ 27: {
+ key: 'Escape',
+ fun: removeFocus,
+ des: 'remove focus from the focused input',
+ cat: 'Control'
+ },
+ 73: {
+ key: 'i',
+ fun: searchInputFocus,
+ des: 'focus on the search input',
+ cat: 'Control'
+ },
+ 66: {
+ key: 'b',
+ fun: scrollPage(-window.innerHeight),
+ des: 'scroll one page up',
+ cat: 'Navigation'
+ },
+ 70: {
+ key: 'f',
+ fun: scrollPage(window.innerHeight),
+ des: 'scroll one page down',
+ cat: 'Navigation'
+ },
+ 85: {
+ key: 'u',
+ fun: scrollPage(-window.innerHeight / 2),
+ des: 'scroll half a page up',
+ cat: 'Navigation'
+ },
+ 68: {
+ key: 'd',
+ fun: scrollPage(window.innerHeight / 2),
+ des: 'scroll half a page down',
+ cat: 'Navigation'
+ },
+ 71: {
+ key: 'g',
+ fun: scrollPageTo(-document.body.scrollHeight, 'top'),
+ des: 'scroll to the top of the page',
+ cat: 'Navigation'
+ },
+ 86: {
+ key: 'v',
+ fun: scrollPageTo(document.body.scrollHeight, 'bottom'),
+ des: 'scroll to the bottom of the page',
+ cat: 'Navigation'
+ },
+ 75: {
+ key: 'k',
+ fun: highlightResult('up'),
+ des: 'select previous search result',
+ cat: 'Results'
+ },
+ 74: {
+ key: 'j',
+ fun: highlightResult('down'),
+ des: 'select next search result',
+ cat: 'Results'
+ },
+ 80: {
+ key: 'p',
+ fun: pageButtonClick(0),
+ des: 'go to previous page',
+ cat: 'Results'
+ },
+ 78: {
+ key: 'n',
+ fun: pageButtonClick(1),
+ des: 'go to next page',
+ cat: 'Results'
+ },
+ 79: {
+ key: 'o',
+ fun: openResult(false),
+ des: 'open search result',
+ cat: 'Results'
+ },
+ 84: {
+ key: 't',
+ fun: openResult(true),
+ des: 'open the result in a new tab',
+ cat: 'Results'
+ },
+ 82: {
+ key: 'r',
+ fun: reloadPage,
+ des: 'reload page from the server',
+ cat: 'Control'
+ },
+ 72: {
+ key: 'h',
+ fun: toggleHelp,
+ des: 'toggle help window',
+ cat: 'Other'
+ }
+ };
+
+ 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) {
+ var tagName = e.target.tagName.toLowerCase();
+ if (e.keyCode === 27) {
+ if (tagName === 'input' || tagName === 'select' || tagName === 'textarea') {
+ vimKeys[e.keyCode].fun();
+ }
+ } else {
+ if (e.target === document.body || tagName === 'a' || tagName === 'button') {
+ e.preventDefault();
+ vimKeys[e.keyCode].fun();
+ }
+ }
+ }
+ });
+
+ function highlightResult(which) {
+ return function(noScroll) {
+ var current = document.querySelector('.result[data-vim-selected]'),
+ effectiveWhich = which;
+ if (current === null) {
+ // no selection : choose the first one
+ current = document.querySelector('.result');
+ if (current === null) {
+ // no first one : there are no results
+ return;
+ }
+ // replace up/down actions by selecting first one
+ if (which === "down" || which === "up") {
+ effectiveWhich = current;
+ }
+ }
+
+ var next, results = document.querySelectorAll('.result');
+
+ if (typeof effectiveWhich !== 'string') {
+ next = effectiveWhich;
+ } else {
+ switch (effectiveWhich) {
+ case 'visible':
+ var top = document.documentElement.scrollTop || document.body.scrollTop;
+ var bot = top + document.documentElement.clientHeight;
+
+ for (var i = 0; i < results.length; i++) {
+ next = results[i];
+ var etop = next.offsetTop;
+ var ebot = etop + next.clientHeight;
+
+ if ((ebot <= bot) && (etop > top)) {
+ break;
+ }
+ }
+ break;
+ case 'down':
+ next = current.nextElementSibling;
+ if (next === null) {
+ next = results[0];
+ }
+ break;
+ case 'up':
+ next = current.previousElementSibling;
+ if (next === null) {
+ next = results[results.length - 1];
+ }
+ break;
+ case 'bottom':
+ next = results[results.length - 1];
+ break;
+ case 'top':
+ /* falls through */
+ default:
+ next = results[0];
+ }
+ }
+
+ if (next) {
+ current.removeAttribute('data-vim-selected');
+ next.setAttribute('data-vim-selected', 'true');
+ var link = next.querySelector('h3 a') || next.querySelector('a');
+ if (link !== null) {
+ link.focus();
+ }
+ if (!noScroll) {
+ scrollPageToSelected();
+ }
+ }
+ };
+ }
+
+ function reloadPage() {
+ document.location.reload(true);
+ }
+
+ function removeFocus() {
+ if (document.activeElement) {
+ document.activeElement.blur();
+ }
+ }
+
+ function pageButtonClick(num) {
+ 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');
+ }
+ };
+ }
+
+ function scrollPageToSelected() {
+ var sel = document.querySelector('.result[data-vim-selected]');
+ if (sel === null) {
+ return;
+ }
+ var wtop = document.documentElement.scrollTop || document.body.scrollTop,
+ wheight = document.documentElement.clientHeight,
+ etop = sel.offsetTop,
+ ebot = etop + sel.clientHeight,
+ offset = 120;
+ // first element ?
+ if ((sel.previousElementSibling === null) && (ebot < wheight)) {
+ // set to the top of page if the first element
+ // is fully included in the viewport
+ window.scroll(window.scrollX, 0);
+ return;
+ }
+ if (wtop > (etop - offset)) {
+ window.scroll(window.scrollX, etop - offset);
+ } else {
+ var wbot = wtop + wheight;
+ if (wbot < (ebot + offset)) {
+ window.scroll(window.scrollX, ebot - wheight + offset);
+ }
+ }
+ }
+
+ function scrollPage(amount) {
+ return function() {
+ window.scrollBy(0, amount);
+ highlightResult('visible')();
+ };
+ }
+
+ function scrollPageTo(position, nav) {
+ return function() {
+ window.scrollTo(0, position);
+ highlightResult(nav)();
+ };
+ }
+
+ function searchInputFocus() {
+ window.scrollTo(0, 0);
+ document.querySelector('#q').focus();
+ }
+
+ function openResult(newTab) {
+ return function() {
+ var link = document.querySelector('.result[data-vim-selected] h3 a');
+ if (link !== null) {
+ var url = link.getAttribute('href');
+ if (newTab) {
+ window.open(url);
+ } else {
+ window.location.href = url;
+ }
+ }
+ };
+ }
+
+ function initHelpContent(divElement) {
+ var categories = {};
+
+ for (var k in vimKeys) {
+ var key = vimKeys[k];
+ categories[key.cat] = categories[key.cat] || [];
+ categories[key.cat].push(key);
+ }
+
+ var sorted = Object.keys(categories).sort(function(a, b) {
+ return categories[b].length - categories[a].length;
+ });
+
+ if (sorted.length === 0) {
+ return;
+ }
+
+ var html = '<a href="#" class="close" aria-label="close" title="close">×</a>';
+ html += '<h3>How to navigate searx with Vim-like hotkeys</h3>';
+ html += '<table>';
+
+ for (var i = 0; i < sorted.length; i++) {
+ var cat = categories[sorted[i]];
+
+ var lastCategory = i === (sorted.length - 1);
+ var first = i % 2 === 0;
+
+ if (first) {
+ html += '<tr>';
+ }
+ html += '<td>';
+
+ html += '<h4>' + cat[0].cat + '</h4>';
+ html += '<ul class="list-unstyled">';
+
+ for (var cj in cat) {
+ html += '<li><kbd>' + cat[cj].key + '</kbd> ' + cat[cj].des + '</li>';
+ }
+
+ html += '</ul>';
+ html += '</td>'; // col-sm-*
+
+ if (!first || lastCategory) {
+ html += '</tr>'; // row
+ }
+ }
+
+ html += '</table>';
+
+ 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%';
+ 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
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2014 by Thomas Pointhuber, <thomas.pointhuber@gmx.at>
+* (C) 2017 by Alexandre Flament, <alex@al-f.net>
+*/
+(function (w, d, searx) {
+ 'use strict';
+
+ searx.ready(function () {
+ searx.on('.searx_overpass_request', 'click', function(event) {
+ // no more request
+ this.classList.remove("searx_overpass_request");
+
+ //
+ var overpass_url = "https://overpass-api.de/api/interpreter?data=";
+ var query_start = overpass_url + "[out:json][timeout:25];(";
+ var query_end = ");out meta;";
+
+ var osm_id = this.dataset.osmId;
+ var osm_type = this.dataset.osmType;
+ var result_table = d.querySelector("#" + this.dataset.resultTable);
+ var result_table_loadicon = d.querySelector("#" + this.dataset.resultTableLoadicon);
+
+ // tags which can be ignored
+ var osm_ignore_tags = [ "addr:city", "addr:country", "addr:housenumber", "addr:postcode", "addr:street" ];
+
+ if(osm_id && osm_type && result_table) {
+ var query = null;
+ switch(osm_type) {
+ case 'node':
+ query = query_start + "node(" + osm_id + ");" + query_end;
+ break;
+ case 'way':
+ query = query_start + "way(" + osm_id + ");" + query_end;
+ break;
+ case 'relation':
+ query = query_start + "relation(" + osm_id + ");" + query_end;
+ break;
+ default:
+ break;
+ }
+ if(query) {
+ // console.log(query);
+ searx.http( 'GET', query ).then(function(html, contentType) {
+ html = JSON.parse(html);
+ if(html && html.elements && html.elements[0]) {
+ var element = html.elements[0];
+ var newHtml = "";
+ for (var row in element.tags) {
+ if(element.tags.name === null || osm_ignore_tags.indexOf(row) == -1) {
+ newHtml += "<tr><td>" + row + "</td><td>";
+ switch(row) {
+ case "phone":
+ case "fax":
+ newHtml += "<a href=\"tel:" + element.tags[row].replace(/ /g,'') + "\">" + element.tags[row] + "</a>";
+ break;
+ case "email":
+ newHtml += "<a href=\"mailto:" + element.tags[row] + "\">" + element.tags[row] + "</a>";
+ break;
+ case "website":
+ case "url":
+ newHtml += "<a href=\"" + element.tags[row] + "\">" + element.tags[row] + "</a>";
+ break;
+ case "wikidata":
+ newHtml += "<a href=\"https://www.wikidata.org/wiki/" + element.tags[row] + "\">" + element.tags[row] + "</a>";
+ break;
+ case "wikipedia":
+ if(element.tags[row].indexOf(":") != -1) {
+ newHtml += "<a href=\"https://" + element.tags[row].substring(0,element.tags[row].indexOf(":")) + ".wikipedia.org/wiki/" + element.tags[row].substring(element.tags[row].indexOf(":")+1) + "\">" + element.tags[row] + "</a>";
+ break;
+ }
+ /* jshint ignore:start */
+ default:
+ /* jshint ignore:end */
+ newHtml += element.tags[row];
+ break;
+ }
+ newHtml += "</td></tr>";
+ }
+ }
+ result_table_loadicon.parentNode.removeChild(result_table_loadicon);
+ result_table.classList.remove('invisible');
+ result_table.querySelector("tbody").innerHTML = newHtml;
+ }
+ })
+ .catch(function() {
+ result_table_loadicon.classList.remove('invisible');
+ result_table_loadicon.innerHTML = "could not load data!";
+ });
+ }
+ }
+
+ // this event occour only once per element
+ event.preventDefault();
+ });
+
+ searx.on('.searx_init_map', 'click', function(event) {
+ // no more request
+ this.classList.remove("searx_init_map");
+
+ //
+ var leaflet_target = this.dataset.leafletTarget;
+ var map_lon = parseFloat(this.dataset.mapLon);
+ var map_lat = parseFloat(this.dataset.mapLat);
+ var map_zoom = parseFloat(this.dataset.mapZoom);
+ var map_boundingbox = JSON.parse(this.dataset.mapBoundingbox);
+ var map_geojson = JSON.parse(this.dataset.mapGeojson);
+
+ searx.loadStyle('leaflet/leaflet.css');
+ searx.loadScript('leaflet/leaflet.js', function() {
+ var map_bounds = null;
+ if(map_boundingbox) {
+ var southWest = L.latLng(map_boundingbox[0], map_boundingbox[2]);
+ var northEast = L.latLng(map_boundingbox[1], map_boundingbox[3]);
+ map_bounds = L.latLngBounds(southWest, northEast);
+ }
+
+ // init map
+ var map = L.map(leaflet_target);
+ // create the tile layer with correct attribution
+ var osmMapnikUrl='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
+ var osmMapnikAttrib='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> 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 © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';
+ var osmWikimedia = new L.TileLayer(osmWikimediaUrl, {minZoom: 1, maxZoom: 19, attribution: osmWikimediaAttrib});
+ // init map view
+ if(map_bounds) {
+ // TODO hack: https://github.com/Leaflet/Leaflet/issues/2021
+ // Still useful ?
+ setTimeout(function () {
+ map.fitBounds(map_bounds, {
+ maxZoom:17
+ });
+ }, 0);
+ } else if (map_lon && map_lat) {
+ if(map_zoom) {
+ map.setView(new L.latLng(map_lat, map_lon),map_zoom);
+ } else {
+ map.setView(new L.latLng(map_lat, map_lon),8);
+ }
+ }
+
+ map.addLayer(osmMapnik);
+
+ var baseLayers = {
+ "OSM Mapnik": osmMapnik/*,
+ "OSM Wikimedia": osmWikimedia*/
+ };
+
+ L.control.layers(baseLayers).addTo(map);
+
+ if(map_geojson) {
+ L.geoJson(map_geojson).addTo(map);
+ } /*else if(map_bounds) {
+ L.rectangle(map_bounds, {color: "#ff7800", weight: 3, fill:false}).addTo(map);
+ }*/
+ });
+
+ // this event occour only once per element
+ event.preventDefault();
+ });
+ });
+})(window, document, window.searx);
+;/**
+* searx is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2017 by Alexandre Flament, <alex@al-f.net>
+*/
+(function(w, d, searx) {
+ 'use strict';
+
+ searx.ready(function() {
+ searx.image_thumbnail_layout = new searx.ImageLayout('#urls', '#urls .result-images', 'img.image_thumbnail', 200);
+ searx.image_thumbnail_layout.watch();
+
+ searx.on('.btn-collapse', 'click', function(event) {
+ var btnLabelCollapsed = this.getAttribute('data-btn-text-collapsed');
+ var btnLabelNotCollapsed = this.getAttribute('data-btn-text-not-collapsed');
+ var target = this.getAttribute('data-target');
+ var targetElement = d.querySelector(target);
+ var html = this.innerHTML;
+ if (this.classList.contains('collapsed')) {
+ html = html.replace(btnLabelCollapsed, btnLabelNotCollapsed);
+ } else {
+ html = html.replace(btnLabelNotCollapsed, btnLabelCollapsed);
+ }
+ this.innerHTML = html;
+ this.classList.toggle('collapsed');
+ targetElement.classList.toggle('invisible');
+ });
+
+ searx.on('.media-loader', 'click', function(event) {
+ var target = this.getAttribute('data-target');
+ var iframe_load = d.querySelector(target + ' > iframe');
+ var srctest = iframe_load.getAttribute('src');
+ if (srctest === null || srctest === undefined || srctest === false) {
+ iframe_load.setAttribute('src', iframe_load.getAttribute('data-src'));
+ }
+ });
+
+ w.addEventListener('scroll', function() {
+ var e = d.getElementById('backToTop'),
+ scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
+ if (e !== null) {
+ if (scrollTop >= 200) {
+ e.style.opacity = 1;
+ } else {
+ e.style.opacity = 0;
+ }
+ }
+ });
+
+ });
+
+})(window, document, window.searx);
+;/**
+* searx is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2017 by Alexandre Flament, <alex@al-f.net>
+*/
+(function(w, d, searx) {
+ 'use strict';
+
+ var firstFocus = true, qinput_id = "q", qinput;
+
+ function placeCursorAtEnd(element) {
+ if (element.setSelectionRange) {
+ var len = element.value.length;
+ element.setSelectionRange(len, len);
+ }
+ }
+
+ function submitIfQuery() {
+ if (qinput.value.length > 0) {
+ var search = document.getElementById('search');
+ setTimeout(search.submit.bind(search), 0);
+ }
+ }
+
+ function createClearButton(qinput) {
+ var cs = document.getElementById('clear_search');
+ var updateClearButton = function() {
+ if (qinput.value.length === 0) {
+ cs.classList.add("empty");
+ } else {
+ cs.classList.remove("empty");
+ }
+ };
+
+ // update status, event listener
+ updateClearButton();
+ cs.addEventListener('click', function() {
+ qinput.value='';
+ qinput.focus();
+ updateClearButton();
+ });
+ qinput.addEventListener('keyup', updateClearButton, false);
+ }
+
+ searx.ready(function() {
+ qinput = d.getElementById(qinput_id);
+
+ function placeCursorAtEndOnce(e) {
+ if (firstFocus) {
+ placeCursorAtEnd(qinput);
+ firstFocus = false;
+ } else {
+ // e.preventDefault();
+ }
+ }
+
+ if (qinput !== null) {
+ // clear button
+ createClearButton(qinput);
+
+ // autocompleter
+ if (searx.autocompleter) {
+ searx.autocomplete = AutoComplete.call(w, {
+ Url: "./autocompleter",
+ EmptyMessage: searx.no_item_found,
+ HttpMethod: searx.method,
+ MinChars: 4,
+ Delay: 300,
+ }, "#" + qinput_id);
+
+ // hack, see : https://github.com/autocompletejs/autocomplete.js/issues/37
+ w.addEventListener('resize', function() {
+ var event = new CustomEvent("position");
+ qinput.dispatchEvent(event);
+ });
+ }
+
+ qinput.addEventListener('focus', placeCursorAtEndOnce, false);
+ qinput.focus();
+ }
+
+ // vanilla js version of search_on_category_select.js
+ if (qinput !== null && searx.search_on_category_select) {
+ d.querySelector('.help').className='invisible';
+
+ searx.on('#categories input', 'change', function(e) {
+ var i, categories = d.querySelectorAll('#categories input[type="checkbox"]');
+ for(i=0; i<categories.length; i++) {
+ if (categories[i] !== this && categories[i].checked) {
+ categories[i].click();
+ }
+ }
+ if (! this.checked) {
+ this.click();
+ }
+ submitIfQuery();
+ return false;
+ });
+
+ searx.on(d.getElementById('time_range'), 'change', submitIfQuery);
+ searx.on(d.getElementById('language'), 'change', submitIfQuery);
+ }
+
+ });
+
+})(window, document, window.searx);
diff --git a/searx/static/themes/simple/js/searx.min.js b/searx/static/themes/simple/js/searx.min.js
new file mode 100644
index 000000000..42e8a845c
--- /dev/null
+++ b/searx/static/themes/simple/js/searx.min.js
@@ -0,0 +1,25 @@
+/*! simple/searx.min.js | 06-08-2019 | https://github.com/asciimoo/searx */
+
+window.searx=function(t,a){"use strict";if(t.Element){(function(e){e.matches=e.matches||e.matchesSelector||e.webkitMatchesSelector||e.msMatchesSelector||function(e){var t=this,n=(t.parentNode||t.document).querySelectorAll(e),i=-1;while(n[++i]&&n[i]!=t);return!!n[i]}})(Element.prototype)}function o(e,t,n){try{e.call(t,n)}catch(e){console.log(e)}}var s=window.searx||{};s.on=function(i,e,r,t){t=t||false;if(typeof i!=="string"){i.addEventListener(e,r,t)}else{a.addEventListener(e,function(e){var t=e.target||e.srcElement,n=false;while(t&&t.matches&&t!==a&&!(n=t.matches(i)))t=t.parentElement;if(n)o(r,t,e)},t)}};s.ready=function(e){if(document.readyState!="loading"){e.call(t)}else{t.addEventListener("DOMContentLoaded",e.bind(t))}};s.http=function(e,t,n){var i=new XMLHttpRequest,r=function(){},a=function(){},o={then:function(e){r=e;return o},catch:function(e){a=e;return o}};try{i.open(e,t,true);i.onload=function(){if(i.status==200){r(i.response,i.responseType)}else{a(Error(i.statusText))}};i.onerror=function(){a(Error("Network Error"))};i.onabort=function(){a(Error("Transaction is aborted"))};i.send()}catch(e){a(e)}return o};s.loadStyle=function(e){var t=s.static_path+e,n="style_"+e.replace(".","_"),i=a.getElementById(n);if(i===null){i=a.createElement("link");i.setAttribute("id",n);i.setAttribute("rel","stylesheet");i.setAttribute("type","text/css");i.setAttribute("href",t);a.body.appendChild(i)}};s.loadScript=function(e,t){var n=s.static_path+e,i="script_"+e.replace(".","_"),r=a.getElementById(i);if(r===null){r=a.createElement("script");r.setAttribute("id",i);r.setAttribute("src",n);r.onload=t;r.onerror=function(){r.setAttribute("error","1")};a.body.appendChild(r)}else if(!r.hasAttribute("error")){try{t.apply(r,[])}catch(e){console.log(e)}}else{console.log("callback not executed : script '"+n+"' not loaded.")}};s.insertBefore=function(e,t){element.parentNode.insertBefore(e,t)};s.insertAfter=function(e,t){t.parentNode.insertBefore(e,t.nextSibling)};s.on(".close","click",function(e){var t=e.target||e.srcElement;this.parentNode.classList.add("invisible")});return s}(window,document);(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.AutoComplete=e()}})(function(){var e,t,n;return function a(o,s,l){function u(n,e){if(!s[n]){if(!o[n]){var t=typeof require=="function"&&require;if(!e&&t)return t(n,!0);if(c)return c(n,!0);var i=new Error("Cannot find module '"+n+"'");throw i.code="MODULE_NOT_FOUND",i}var r=s[n]={exports:{}};o[n][0].call(r.exports,function(e){var t=o[n][1][e];return u(t?t:e)},r,r.exports,a,o,s,l)}return s[n].exports}var c=typeof require=="function"&&require;for(var e=0;e<l.length;e++)u(l[e]);return u}({1:[function(e,t,n){
+/*
+ * @license MIT
+ *
+ * Autocomplete.js v2.6.3
+ * Developed by Baptiste Donaux
+ * http://autocomplete-js.com
+ *
+ * (c) 2017, Baptiste Donaux
+ */
+"use strict";var l;(function(e){e[e["AND"]=0]="AND";e[e["OR"]=1]="OR"})(l||(l={}));var a;(function(e){e[e["KEYDOWN"]=0]="KEYDOWN";e[e["KEYUP"]=1]="KEYUP"})(a||(a={}));var i=function(){function s(t,e){if(t===void 0){t={}}if(e===void 0){e="[data-autocomplete]"}if(Array.isArray(e)){e.forEach(function(e){new s(t,e)})}else if(typeof e=="string"){var n=document.querySelectorAll(e);Array.prototype.forEach.call(n,function(e){new s(t,e)})}else{var i=s.merge(s.defaults,t,{DOMResults:document.createElement("div")});s.prototype.create(i,e);return i}}s.prototype.create=function(e,t){e.Input=t;if(e.Input.nodeName.match(/^INPUT$/i)&&(e.Input.hasAttribute("type")===false||e.Input.getAttribute("type").match(/^TEXT|SEARCH$/i))){e.Input.setAttribute("autocomplete","off");e._Position(e);e.Input.parentNode.appendChild(e.DOMResults);e.$Listeners={blur:e._Blur.bind(e),destroy:s.prototype.destroy.bind(null,e),focus:e._Focus.bind(e),keyup:s.prototype.event.bind(null,e,a.KEYUP),keydown:s.prototype.event.bind(null,e,a.KEYDOWN),position:e._Position.bind(e)};for(var n in e.$Listeners){e.Input.addEventListener(n,e.$Listeners[n])}}};s.prototype.getEventsByType=function(e,t){var n={};for(var i in e.KeyboardMappings){var r=a.KEYUP;if(e.KeyboardMappings[i].Event!==undefined){r=e.KeyboardMappings[i].Event}if(r==t){n[i]=e.KeyboardMappings[i]}}return n};s.prototype.event=function(e,t,n){var i=function(e){if(o===true&&a.Operator==l.AND||o===false&&a.Operator==l.OR){e=s.merge({Not:false},e);if(e.hasOwnProperty("Is")){if(e.Is==n.keyCode){o=!e.Not}else{o=e.Not}}else if(e.hasOwnProperty("From")&&e.hasOwnProperty("To")){if(n.keyCode>=e.From&&n.keyCode<=e.To){o=!e.Not}else{o=e.Not}}}};for(var r in s.prototype.getEventsByType(e,t)){var a=s.merge({Operator:l.AND},e.KeyboardMappings[r]),o=l.AND==a.Operator;a.Conditions.forEach(i);if(o===true){a.Callback.call(e,n)}}};s.prototype.makeRequest=function(e,t){var n=Object.getOwnPropertyNames(e.HttpHeaders),i=new XMLHttpRequest,r=e._HttpMethod(),a=e._Url(),o=e._Pre(),s=encodeURIComponent(e._QueryArg())+"="+encodeURIComponent(o);if(r.match(/^GET$/i)){if(a.indexOf("?")!==-1){a+="&"+s}else{a+="?"+s}}i.open(r,a,true);for(var l=n.length-1;l>=0;l--){i.setRequestHeader(n[l],e.HttpHeaders[n[l]])}i.onreadystatechange=function(){if(i.readyState==4&&i.status==200){e.$Cache[o]=i.response;t(i.response)}};return i};s.prototype.ajax=function(e,t,n){if(n===void 0){n=true}if(e.$AjaxTimer){window.clearTimeout(e.$AjaxTimer)}if(n===true){e.$AjaxTimer=window.setTimeout(s.prototype.ajax.bind(null,e,t,false),e.Delay)}else{if(e.Request){e.Request.abort()}e.Request=t;e.Request.send(e._QueryArg()+"="+e._Pre())}};s.prototype.cache=function(e,t){var n=e._Cache(e._Pre());if(n===undefined){var i=s.prototype.makeRequest(e,t);s.prototype.ajax(e,i)}else{t(n)}};s.prototype.destroy=function(e){for(var t in e.$Listeners){e.Input.removeEventListener(t,e.$Listeners[t])}e.DOMResults.parentNode.removeChild(e.DOMResults)};return s}();i.merge=function(){var e={},t;for(var n=0;n<arguments.length;n++){for(t in arguments[n]){e[t]=arguments[n][t]}}return e};i.defaults={Delay:150,EmptyMessage:"No result here",Highlight:{getRegex:function(e){return new RegExp(e,"ig")},transform:function(e){return"<strong>"+e+"</strong>"}},HttpHeaders:{"Content-type":"application/x-www-form-urlencoded"},Limit:0,MinChars:0,HttpMethod:"GET",QueryArg:"q",Url:null,KeyboardMappings:{Enter:{Conditions:[{Is:13,Not:false}],Callback:function(e){if(this.DOMResults.getAttribute("class").indexOf("open")!=-1){var t=this.DOMResults.querySelector("li.active");if(t!==null){e.preventDefault();this._Select(t);this.DOMResults.setAttribute("class","autocomplete")}}},Operator:l.AND,Event:a.KEYDOWN},KeyUpAndDown_down:{Conditions:[{Is:38,Not:false},{Is:40,Not:false}],Callback:function(e){e.preventDefault()},Operator:l.OR,Event:a.KEYDOWN},KeyUpAndDown_up:{Conditions:[{Is:38,Not:false},{Is:40,Not:false}],Callback:function(e){e.preventDefault();var t=this.DOMResults.querySelector("li:first-child:not(.locked)"),n=this.DOMResults.querySelector("li:last-child:not(.locked)"),i=this.DOMResults.querySelector("li.active");if(i){var r=Array.prototype.indexOf.call(i.parentNode.children,i),a=r+(e.keyCode-39),o=this.DOMResults.getElementsByTagName("li").length;if(a<0){a=o-1}else if(a>=o){a=0}i.classList.remove("active");i.parentElement.children.item(a).classList.add("active")}else if(n&&e.keyCode==38){n.classList.add("active")}else if(t){t.classList.add("active")}},Operator:l.OR,Event:a.KEYUP},AlphaNum:{Conditions:[{Is:13,Not:true},{From:35,To:40,Not:true}],Callback:function(){var e=this.Input.getAttribute("data-autocomplete-old-value"),t=this._Pre();if(t!==""&&t.length>=this._MinChars()){if(!e||t!=e){this.DOMResults.setAttribute("class","autocomplete open")}i.prototype.cache(this,function(e){this._Render(this._Post(e));this._Open()}.bind(this))}},Operator:l.AND,Event:a.KEYUP}},DOMResults:null,Request:null,Input:null,_EmptyMessage:function(){var e="";if(this.Input.hasAttribute("data-autocomplete-empty-message")){e=this.Input.getAttribute("data-autocomplete-empty-message")}else if(this.EmptyMessage!==false){e=this.EmptyMessage}else{e=""}return e},_Limit:function(){var e=this.Input.getAttribute("data-autocomplete-limit");if(isNaN(e)||e===null){return this.Limit}return parseInt(e,10)},_MinChars:function(){var e=this.Input.getAttribute("data-autocomplete-minchars");if(isNaN(e)||e===null){return this.MinChars}return parseInt(e,10)},_Highlight:function(e){return e.replace(this.Highlight.getRegex(this._Pre()),this.Highlight.transform)},_HttpMethod:function(){if(this.Input.hasAttribute("data-autocomplete-method")){return this.Input.getAttribute("data-autocomplete-method")}return this.HttpMethod},_QueryArg:function(){if(this.Input.hasAttribute("data-autocomplete-param-name")){return this.Input.getAttribute("data-autocomplete-param-name")}return this.QueryArg},_Url:function(){if(this.Input.hasAttribute("data-autocomplete")){return this.Input.getAttribute("data-autocomplete")}return this.Url},_Blur:function(e){if(e===true){this.DOMResults.setAttribute("class","autocomplete");this.Input.setAttribute("data-autocomplete-old-value",this.Input.value)}else{var t=this;setTimeout(function(){t._Blur(true)},150)}},_Cache:function(e){return this.$Cache[e]},_Focus:function(){var e=this.Input.getAttribute("data-autocomplete-old-value");if((!e||this.Input.value!=e)&&this._MinChars()<=this.Input.value.length){this.DOMResults.setAttribute("class","autocomplete open")}},_Open:function(){var n=this;Array.prototype.forEach.call(this.DOMResults.getElementsByTagName("li"),function(t){if(t.getAttribute("class")!="locked"){t.onclick=function(e){n._Select(t)};t.onmouseenter=function(){var e=n.DOMResults.querySelector("li.active");if(e!==t){if(e!==null){e.classList.remove("active")}t.classList.add("active")}}}})},_Position:function(){this.DOMResults.setAttribute("class","autocomplete");this.DOMResults.setAttribute("style","top:"+(this.Input.offsetTop+this.Input.offsetHeight)+"px;left:"+this.Input.offsetLeft+"px;width:"+this.Input.clientWidth+"px;")},_Render:function(e){var t;if(typeof e=="string"){t=this._RenderRaw(e)}else{t=this._RenderResponseItems(e)}if(this.DOMResults.hasChildNodes()){this.DOMResults.removeChild(this.DOMResults.childNodes[0])}this.DOMResults.appendChild(t)},_RenderResponseItems:function(e){var t=document.createElement("ul"),n=document.createElement("li"),i=this._Limit();if(i<0){e=e.reverse()}else if(i===0){i=e.length}for(var r=0;r<Math.min(Math.abs(i),e.length);r++){n.innerHTML=e[r].Label;n.setAttribute("data-autocomplete-value",e[r].Value);t.appendChild(n);n=document.createElement("li")}return t},_RenderRaw:function(e){var t=document.createElement("ul"),n=document.createElement("li");if(e.length>0){this.DOMResults.innerHTML=e}else{var i=this._EmptyMessage();if(i!==""){n.innerHTML=i;n.setAttribute("class","locked");t.appendChild(n)}}return t},_Post:function(t){try{var e=[];var n=JSON.parse(t);if(Object.keys(n).length===0){return""}if(Array.isArray(n)){for(var i=0;i<Object.keys(n).length;i++){e[e.length]={Value:n[i],Label:this._Highlight(n[i])}}}else{for(var r in n){e.push({Value:r,Label:this._Highlight(n[r])})}}return e}catch(e){return t}},_Pre:function(){return this.Input.value},_Select:function(e){console.log("test test test");if(e.hasAttribute("data-autocomplete-value")){this.Input.value=e.getAttribute("data-autocomplete-value")}else{this.Input.value=e.innerHTML}this.Input.setAttribute("data-autocomplete-old-value",this.Input.value)},$AjaxTimer:null,$Cache:{},$Listeners:{}};t.exports=i},{}]},{},[1])(1)});
+/**
+*
+* Google Image Layout v0.0.1
+* Description, by Anh Trinh.
+* Heavily modified for searx
+* http://trinhtrunganh.com
+*
+* @license Free to use under the MIT License.
+*
+*/
+(function(u,c){"use strict";function e(e,t,n,i){this.container_selector=e;this.results_selector=t;this.img_selector=n;this.margin=10;this.maxHeight=i;this._alignAllDone=true}e.prototype._getHeigth=function(e,t){var n=0,i;t-=e.length*this.margin;for(var r=0;r<e.length;r++){i=e[r];if(i.naturalWidth>0&&i.naturalHeight>0){n+=i.naturalWidth/i.naturalHeight}else{n+=1}}return t/n};e.prototype._setSize=function(e,t){var n,i,r=e.length;for(var a=0;a<r;a++){n=e[a];if(n.naturalWidth>0&&n.naturalHeight>0){i=t*n.naturalWidth/n.naturalHeight}else{i=t}n.style.width=i+"px";n.style.height=t+"px";n.style.marginLeft="3px";n.style.marginTop="3px";n.style.marginRight=this.margin-7+"px";n.style.marginBottom=this.margin-7+"px"}};e.prototype._alignImgs=function(e){var t,n,i=c.querySelector(this.container_selector).clientWidth;e:while(e.length>0){for(var r=1;r<=e.length;r++){t=e.slice(0,r);n=this._getHeigth(t,i);if(n<this.maxHeight){this._setSize(t,n);e=e.slice(r);continue e}}this._setSize(t,Math.min(this.maxHeight,n));break}};e.prototype.align=function(e){var t=c.querySelectorAll(this.results_selector),n=t.length,i=null,r=null,a=[];for(var o=0;o<n;o++){r=t[o];if(r.previousElementSibling!==i&&a.length>0){this._alignImgs(a);a=[]}a.push(r.querySelector(this.img_selector));i=r}if(a.length>0){this._alignImgs(a)}};e.prototype.watch=function(){var e,t,n,i,r=this,a=c.querySelectorAll(this.results_selector),o=a.length;function s(e){r.align()}function l(e){if(r._alignAllDone){r._alignAllDone=false;setTimeout(function(){r.align();r._alignAllDone=true},100)}}u.addEventListener("resize",l);u.addEventListener("pageshow",s);for(e=0;e<o;e++){t=a[e].querySelector(this.img_selector);if(typeof t!=="undefined"){t.addEventListener("load",l);t.addEventListener("error",l)}}};u.searx.ImageLayout=e})(window,document);searx.ready(function(){searx.on(".result","click",function(){n(this)(true)});searx.on(".result a","focus",function(e){var t=e.target;while(t!==undefined){if(t.classList.contains("result")){if(t.getAttribute("data-vim-selected")===null){n(t)(true)}break}t=t.parentNode}},true);var d={27:{key:"Escape",fun:t,des:"remove focus from the focused input",cat:"Control"},73:{key:"i",fun:o,des:"focus on the search input",cat:"Control"},66:{key:"b",fun:r(-window.innerHeight),des:"scroll one page up",cat:"Navigation"},70:{key:"f",fun:r(window.innerHeight),des:"scroll one page down",cat:"Navigation"},85:{key:"u",fun:r(-window.innerHeight/2),des:"scroll half a page up",cat:"Navigation"},68:{key:"d",fun:r(window.innerHeight/2),des:"scroll half a page down",cat:"Navigation"},71:{key:"g",fun:a(-document.body.scrollHeight,"top"),des:"scroll to the top of the page",cat:"Navigation"},86:{key:"v",fun:a(document.body.scrollHeight,"bottom"),des:"scroll to the bottom of the page",cat:"Navigation"},75:{key:"k",fun:n("up"),des:"select previous search result",cat:"Results"},74:{key:"j",fun:n("down"),des:"select next search result",cat:"Results"},80:{key:"p",fun:i(0),des:"go to previous page",cat:"Results"},78:{key:"n",fun:i(1),des:"go to next page",cat:"Results"},79:{key:"o",fun:s(false),des:"open search result",cat:"Results"},84:{key:"t",fun:s(true),des:"open the result in a new tab",cat:"Results"},82:{key:"r",fun:e,des:"reload page from the server",cat:"Control"},72:{key:"h",fun:u,des:"toggle help window",cat:"Other"}};searx.on(document,"keydown",function(e){if(d.hasOwnProperty(e.keyCode)&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey){var t=e.target.tagName.toLowerCase();if(e.keyCode===27){if(t==="input"||t==="select"||t==="textarea"){d[e.keyCode].fun()}}else{if(e.target===document.body||t==="a"||t==="button"){e.preventDefault();d[e.keyCode].fun()}}}});function n(d){return function(e){var t=document.querySelector(".result[data-vim-selected]"),n=d;if(t===null){t=document.querySelector(".result");if(t===null){return}if(d==="down"||d==="up"){n=t}}var i,r=document.querySelectorAll(".result");if(typeof n!=="string"){i=n}else{switch(n){case"visible":var a=document.documentElement.scrollTop||document.body.scrollTop;var o=a+document.documentElement.clientHeight;for(var s=0;s<r.length;s++){i=r[s];var l=i.offsetTop;var u=l+i.clientHeight;if(u<=o&&l>a){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&&t<e.length){e[t].click()}else{console.log("pageButtonClick(): invalid argument")}}}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,a=120;if(e.previousElementSibling===null&&r<n){window.scroll(window.scrollX,0);return}if(t>i-a){window.scroll(window.scrollX,i-a)}else{var o=t+n;if(o<r+a){window.scroll(window.scrollX,r-n+a)}}}function r(e){return function(){window.scrollBy(0,e);n("visible")()}}function a(e,t){return function(){window.scrollTo(0,e);n(t)()}}function o(){window.scrollTo(0,0);document.querySelector("#q").focus()}function s(n){return function(){var e=document.querySelector(".result[data-vim-selected] h3 a");if(e!==null){var t=e.getAttribute("href");if(n){window.open(t)}else{window.location.href=t}}}}function l(e){var n={};for(var t in d){var i=d[t];n[i.cat]=n[i.cat]||[];n[i.cat].push(i)}var r=Object.keys(n).sort(function(e,t){return n[t].length-n[e].length});if(r.length===0){return}var a='<a href="#" class="close" aria-label="close" title="close">×</a>';a+="<h3>How to navigate searx with Vim-like hotkeys</h3>";a+="<table>";for(var o=0;o<r.length;o++){var s=n[r[o]];var l=o===r.length-1;var u=o%2===0;if(u){a+="<tr>"}a+="<td>";a+="<h4>"+s[0].cat+"</h4>";a+='<ul class="list-unstyled">';for(var c in s){a+="<li><kbd>"+s[c].key+"</kbd> "+s[c].des+"</li>"}a+="</ul>";a+="</td>";if(!u||l){a+="</tr>"}}a+="</table>";e.innerHTML=a}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,c,v){"use strict";v.ready(function(){v.on(".searx_overpass_request","click",function(e){this.classList.remove("searx_overpass_request");var t="https://overpass-api.de/api/interpreter?data=";var n=t+"[out:json][timeout:25];(";var i=");out meta;";var r=this.dataset.osmId;var a=this.dataset.osmType;var o=c.querySelector("#"+this.dataset.resultTable);var s=c.querySelector("#"+this.dataset.resultTableLoadicon);var l=["addr:city","addr:country","addr:housenumber","addr:postcode","addr:street"];if(r&&a&&o){var u=null;switch(a){case"node":u=n+"node("+r+");"+i;break;case"way":u=n+"way("+r+");"+i;break;case"relation":u=n+"relation("+r+");"+i;break;default:break}if(u){v.http("GET",u).then(function(e,t){e=JSON.parse(e);if(e&&e.elements&&e.elements[0]){var n=e.elements[0];var i="";for(var r in n.tags){if(n.tags.name===null||l.indexOf(r)==-1){i+="<tr><td>"+r+"</td><td>";switch(r){case"phone":case"fax":i+='<a href="tel:'+n.tags[r].replace(/ /g,"")+'">'+n.tags[r]+"</a>";break;case"email":i+='<a href="mailto:'+n.tags[r]+'">'+n.tags[r]+"</a>";break;case"website":case"url":i+='<a href="'+n.tags[r]+'">'+n.tags[r]+"</a>";break;case"wikidata":i+='<a href="https://www.wikidata.org/wiki/'+n.tags[r]+'">'+n.tags[r]+"</a>";break;case"wikipedia":if(n.tags[r].indexOf(":")!=-1){i+='<a href="https://'+n.tags[r].substring(0,n.tags[r].indexOf(":"))+".wikipedia.org/wiki/"+n.tags[r].substring(n.tags[r].indexOf(":")+1)+'">'+n.tags[r]+"</a>";break}default:i+=n.tags[r];break}i+="</td></tr>"}}s.parentNode.removeChild(s);o.classList.remove("invisible");o.querySelector("tbody").innerHTML=i}}).catch(function(){s.classList.remove("invisible");s.innerHTML="could not load data!"})}}e.preventDefault()});v.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);v.loadStyle("leaflet/leaflet.css");v.loadScript("leaflet/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 a='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';var o=new L.TileLayer(r,{minZoom:1,maxZoom:19,attribution:a});var s="https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png";var l='Wikimedia maps beta | Maps data © <a href="https://openstreetmap.org">OpenStreetMap</a> 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(o);var c={"OSM Mapnik":o};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",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=o.querySelector(i);var a=this.innerHTML;if(this.classList.contains("collapsed")){a=a.replace(t,n)}else{a=a.replace(n,t)}this.innerHTML=a;this.classList.toggle("collapsed");r.classList.toggle("invisible")});t.on(".media-loader","click",function(e){var t=this.getAttribute("data-target");var n=o.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=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,i,n){"use strict";var r=true,a="q",o;function s(e){if(e.setSelectionRange){var t=e.value.length;e.setSelectionRange(t,t)}}function l(){if(o.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(){o=i.getElementById(a);function e(e){if(r){s(o);r=false}else{}}if(o!==null){u(o);if(n.autocompleter){n.autocomplete=AutoComplete.call(t,{Url:"./autocompleter",EmptyMessage:n.no_item_found,HttpMethod:n.method,MinChars:4,Delay:300},"#"+a);t.addEventListener("resize",function(){var e=new CustomEvent("position");o.dispatchEvent(e)})}o.addEventListener("focus",e,false);o.focus()}if(o!==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;t<n.length;t++){if(n[t]!==this&&n[t].checked){n[t].click()}}if(!this.checked){this.click()}l();return false});n.on(i.getElementById("time_range"),"change",l);n.on(i.getElementById("language"),"change",l)}})})(window,document,window.searx);
+//# sourceMappingURL=searx.min.js.map \ No newline at end of file
diff --git a/searx/static/themes/simple/js/searx.min.js.map b/searx/static/themes/simple/js/searx.min.js.map
new file mode 100644
index 000000000..d7a1eeac8
--- /dev/null
+++ b/searx/static/themes/simple/js/searx.min.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["searx.js"],"names":["window","searx","w","d","Element","ElementPrototype","matches","matchesSelector","webkitMatchesSelector","msMatchesSelector","selector","node","this","nodes","parentNode","document","querySelectorAll","i","prototype","callbackSafe","callback","el","e","call","exception","console","log","on","obj","eventType","useCapture","addEventListener","target","srcElement","found","parentElement","ready","readyState","bind","http","method","url","req","XMLHttpRequest","resolve","reject","promise","then","catch","open","onload","status","response","responseType","Error","statusText","onerror","onabort","send","ex","loadStyle","src","path","static_path","id","replace","s","getElementById","createElement","setAttribute","body","appendChild","loadScript","hasAttribute","apply","insertBefore","newNode","referenceNode","element","insertAfter","nextSibling","classList","add","f","exports","module","define","amd","g","global","self","AutoComplete","t","n","r","o","u","a","require","code","l","length","1","ConditionOperator","EventType","params","Array","isArray","forEach","elements","input","specificParams","merge","defaults","DOMResults","create","Input","nodeName","match","getAttribute","_Position","$Listeners","blur","_Blur","destroy","focus","_Focus","keyup","event","KEYUP","keydown","KEYDOWN","position","getEventsByType","type","mappings","key","KeyboardMappings","Event","undefined","eventIdentifier","condition","mapping","Operator","AND","OR","Not","hasOwnProperty","Is","keyCode","From","To","name","Conditions","Callback","makeRequest","propertyHttpHeaders","Object","getOwnPropertyNames","HttpHeaders","request","_HttpMethod","_Url","queryParams","_Pre","queryParamsStringify","encodeURIComponent","_QueryArg","indexOf","setRequestHeader","onreadystatechange","$Cache","ajax","timeout","$AjaxTimer","clearTimeout","setTimeout","Delay","Request","abort","cache","_Cache","removeEventListener","removeChild","tmp","arguments","EmptyMessage","Highlight","getRegex","value","RegExp","transform","Content-type","Limit","MinChars","HttpMethod","QueryArg","Url","Enter","liActive","querySelector","preventDefault","_Select","KeyUpAndDown_down","KeyUpAndDown_up","first","last","active","currentIndex","children","lisCount","getElementsByTagName","remove","item","AlphaNum","oldValue","currentValue","_MinChars","_Render","_Post","_Open","_EmptyMessage","emptyMessage","_Limit","limit","isNaN","parseInt","minchars","_Highlight","label","now","li","onclick","onmouseenter","offsetTop","offsetHeight","offsetLeft","clientWidth","ul","_RenderRaw","_RenderResponseItems","hasChildNodes","childNodes","reverse","Math","min","abs","innerHTML","Label","Value","returnResponse","json","JSON","parse","keys","push","ImageLayout","container_selector","results_selector","img_selector","maxHeight","margin","_alignAllDone","_getHeigth","images","width","img","naturalWidth","naturalHeight","_setSize","height","imgWidth","imagesLength","style","marginLeft","marginTop","marginRight","marginBottom","_alignImgs","imgGroup","slice","h","containerWidth","align","results_selectorNode","results_length","previous","current","previousElementSibling","watch","imgNodeLength","results_nodes","throttleAlign","highlightResult","contains","vimKeys","27","fun","removeFocus","des","cat","73","searchInputFocus","66","scrollPage","innerHeight","70","85","68","71","scrollPageTo","scrollHeight","86","75","74","80","pageButtonClick","78","79","openResult","84","82","reloadPage","72","toggleHelp","ctrlKey","altKey","shiftKey","metaKey","tagName","toLowerCase","which","noScroll","effectiveWhich","next","results","top","documentElement","scrollTop","bot","clientHeight","etop","ebot","nextElementSibling","removeAttribute","link","scrollPageToSelected","location","reload","activeElement","num","buttons","$","click","sel","wtop","wheight","offset","scroll","scrollX","wbot","amount","scrollBy","nav","scrollTo","newTab","href","initHelpContent","divElement","categories","k","sorted","sort","b","html","lastCategory","cj","helpPanel","className","toggle","overpass_url","query_start","query_end","osm_id","dataset","osmId","osm_type","osmType","result_table","resultTable","result_table_loadicon","resultTableLoadicon","osm_ignore_tags","query","contentType","newHtml","row","tags","substring","leaflet_target","leafletTarget","map_lon","parseFloat","mapLon","map_lat","mapLat","map_zoom","mapZoom","map_boundingbox","mapBoundingbox","map_geojson","mapGeojson","map_bounds","southWest","L","latLng","northEast","latLngBounds","map","osmMapnikUrl","osmMapnikAttrib","osmMapnik","TileLayer","minZoom","maxZoom","attribution","osmWikimediaUrl","osmWikimediaAttrib","osmWikimedia","fitBounds","setView","addLayer","baseLayers","OSM Mapnik","control","layers","addTo","geoJson","image_thumbnail_layout","btnLabelCollapsed","btnLabelNotCollapsed","targetElement","iframe_load","srctest","opacity","firstFocus","qinput_id","qinput","placeCursorAtEnd","setSelectionRange","len","submitIfQuery","search","submit","createClearButton","cs","updateClearButton","placeCursorAtEndOnce","autocompleter","autocomplete","no_item_found","CustomEvent","dispatchEvent","search_on_category_select","checked"],"mappings":";;AAiBAA,OAAOC,MAAQ,SAAUC,EAAGC,GAE1B,aAMA,GAAID,EAAEE,QAAS,EACb,SAAUC,GACRA,EAAiBC,QAAUD,EAAiBC,SAC5CD,EAAiBE,iBACjBF,EAAiBG,uBACjBH,EAAiBI,mBACjB,SAASC,GACP,IAAIC,EAAOC,KAAMC,GAASF,EAAKG,YAAcH,EAAKI,UAAUC,iBAAiBN,GAAWO,GAAK,EAC7F,MAAOJ,IAAQI,IAAMJ,EAAMI,IAAMN,GACjC,QAASE,EAAMI,KARnB,CAUGb,QAAQc,WAGb,SAASC,EAAaC,EAAUC,EAAIC,GAClC,IACEF,EAASG,KAAKF,EAAIC,GAClB,MAAOE,GACPC,QAAQC,IAAIF,IAIhB,IAAIvB,EAAQD,OAAOC,OAAS,GAE5BA,EAAM0B,GAAK,SAASC,EAAKC,EAAWT,EAAUU,GAC5CA,EAAaA,GAAc,MAC3B,UAAWF,IAAQ,SAAU,CAE3BA,EAAIG,iBAAiBF,EAAWT,EAAUU,OACrC,CAEL3B,EAAE4B,iBAAiBF,EAAW,SAASP,GACrC,IAAID,EAAKC,EAAEU,QAAUV,EAAEW,WAAYC,EAAQ,MAC3C,MAAOb,GAAMA,EAAGf,SAAWe,IAAOlB,KAAO+B,EAAQb,EAAGf,QAAQsB,IAAOP,EAAKA,EAAGc,cAC3E,GAAID,EAAOf,EAAaC,EAAUC,EAAIC,IACrCQ,KAIP7B,EAAMmC,MAAQ,SAAShB,GACrB,GAAIL,SAASsB,YAAc,UAAW,CACpCjB,EAASG,KAAKrB,OACT,CACLA,EAAE6B,iBAAiB,mBAAoBX,EAASkB,KAAKpC,MAIzDD,EAAMsC,KAAO,SAASC,EAAQC,EAAKrB,GACjC,IAAIsB,EAAM,IAAIC,eACdC,EAAU,aACVC,EAAS,aACTC,EAAU,CACRC,KAAM,SAAS3B,GAAYwB,EAAUxB,EAAU,OAAO0B,GACtD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OAAOC","file":"searx.min.js"} \ No newline at end of file
diff --git a/searx/static/themes/simple/js/searx_head/00_init.js b/searx/static/themes/simple/js/searx_head/00_init.js
new file mode 100644
index 000000000..3ac61c8ae
--- /dev/null
+++ b/searx/static/themes/simple/js/searx_head/00_init.js
@@ -0,0 +1,40 @@
+/**
+* searx is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2019 by Alexandre Flament
+*
+*/
+(function(w, d) {
+ 'use strict';
+
+ // add data- properties
+ var script = d.currentScript || (function() {
+ var scripts = d.getElementsByTagName('script');
+ return scripts[scripts.length - 1];
+ })();
+
+ // try to detect touch screen
+ w.searx = {
+ touch: (("ontouchstart" in w) || w.DocumentTouch && document instanceof DocumentTouch) || false,
+ method: script.getAttribute('data-method'),
+ autocompleter: script.getAttribute('data-autocompleter') === 'true',
+ search_on_category_select: script.getAttribute('data-search-on-category-select') === 'true',
+ infinite_scroll: script.getAttribute('data-infinite-scroll') === 'true',
+ static_path: script.getAttribute('data-static-path'),
+ no_item_found: script.getAttribute('data-no-item-found')
+ }
+
+ // update the css
+ d.getElementsByTagName("html")[0].className = (w.searx.touch)?"js touch":"js";
+})(window, document); \ No newline at end of file
diff --git a/searx/static/themes/simple/js/searx_src/00_searx_toolkit.js b/searx/static/themes/simple/js/searx_src/00_searx_toolkit.js
new file mode 100644
index 000000000..dbef4be73
--- /dev/null
+++ b/searx/static/themes/simple/js/searx_src/00_searx_toolkit.js
@@ -0,0 +1,164 @@
+/**
+* searx is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2017 by Alexandre Flament, <alex@al-f.net>
+*
+*/
+window.searx = (function(w, d) {
+
+ 'use strict';
+
+ // not invented here tookit with bugs fixed elsewhere
+ // purposes : be just good enough and as small as possible
+
+ // from https://plainjs.com/javascript/events/live-binding-event-handlers-14/
+ if (w.Element) {
+ (function(ElementPrototype) {
+ ElementPrototype.matches = ElementPrototype.matches ||
+ ElementPrototype.matchesSelector ||
+ ElementPrototype.webkitMatchesSelector ||
+ ElementPrototype.msMatchesSelector ||
+ function(selector) {
+ var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;
+ while (nodes[++i] && nodes[i] != node);
+ return !!nodes[i];
+ };
+ })(Element.prototype);
+ }
+
+ function callbackSafe(callback, el, e) {
+ try {
+ callback.call(el, e);
+ } catch (exception) {
+ console.log(exception);
+ }
+ }
+
+ var searx = window.searx || {};
+
+ searx.on = function(obj, eventType, callback, useCapture) {
+ useCapture = useCapture || false;
+ if (typeof obj !== 'string') {
+ // obj HTMLElement, HTMLDocument
+ obj.addEventListener(eventType, callback, useCapture);
+ } else {
+ // obj is a selector
+ d.addEventListener(eventType, function(e) {
+ var el = e.target || e.srcElement, found = false;
+ while (el && el.matches && el !== d && !(found = el.matches(obj))) el = el.parentElement;
+ if (found) callbackSafe(callback, el, e);
+ }, useCapture);
+ }
+ };
+
+ searx.ready = function(callback) {
+ if (document.readyState != 'loading') {
+ callback.call(w);
+ } else {
+ w.addEventListener('DOMContentLoaded', callback.bind(w));
+ }
+ };
+
+ searx.http = function(method, url, callback) {
+ var req = new XMLHttpRequest(),
+ resolve = function() {},
+ reject = function() {},
+ promise = {
+ then: function(callback) { resolve = callback; return promise; },
+ catch: function(callback) { reject = callback; return promise; }
+ };
+
+ try {
+ req.open(method, url, true);
+
+ // On load
+ req.onload = function() {
+ if (req.status == 200) {
+ resolve(req.response, req.responseType);
+ } else {
+ reject(Error(req.statusText));
+ }
+ };
+
+ // Handle network errors
+ req.onerror = function() {
+ reject(Error("Network Error"));
+ };
+
+ req.onabort = function() {
+ reject(Error("Transaction is aborted"));
+ };
+
+ // Make the request
+ req.send();
+ } catch (ex) {
+ reject(ex);
+ }
+
+ return promise;
+ };
+
+ searx.loadStyle = function(src) {
+ var path = searx.static_path + src,
+ id = "style_" + src.replace('.', '_'),
+ s = d.getElementById(id);
+ if (s === null) {
+ s = d.createElement('link');
+ s.setAttribute('id', id);
+ s.setAttribute('rel', 'stylesheet');
+ s.setAttribute('type', 'text/css');
+ s.setAttribute('href', path);
+ d.body.appendChild(s);
+ }
+ };
+
+ searx.loadScript = function(src, callback) {
+ var path = searx.static_path + src,
+ id = "script_" + src.replace('.', '_'),
+ s = d.getElementById(id);
+ if (s === null) {
+ s = d.createElement('script');
+ s.setAttribute('id', id);
+ s.setAttribute('src', path);
+ s.onload = callback;
+ s.onerror = function() {
+ s.setAttribute('error', '1');
+ };
+ d.body.appendChild(s);
+ } else if (!s.hasAttribute('error')) {
+ try {
+ callback.apply(s, []);
+ } catch (exception) {
+ console.log(exception);
+ }
+ } else {
+ console.log("callback not executed : script '" + path + "' not loaded.");
+ }
+ };
+
+ searx.insertBefore = function (newNode, referenceNode) {
+ element.parentNode.insertBefore(newNode, referenceNode);
+ };
+
+ searx.insertAfter = function(newNode, referenceNode) {
+ referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
+ };
+
+ searx.on('.close', 'click', function(e) {
+ var el = e.target || e.srcElement;
+ this.parentNode.classList.add('invisible');
+ });
+
+ return searx;
+})(window, document);
diff --git a/searx/static/themes/simple/js/searx_src/autocomplete.js b/searx/static/themes/simple/js/searx_src/autocomplete.js
new file mode 100644
index 000000000..b95fbcfb2
--- /dev/null
+++ b/searx/static/themes/simple/js/searx_src/autocomplete.js
@@ -0,0 +1,536 @@
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AutoComplete = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+/*
+ * @license MIT
+ *
+ * Autocomplete.js v2.6.3
+ * Developed by Baptiste Donaux
+ * http://autocomplete-js.com
+ *
+ * (c) 2017, Baptiste Donaux
+ */
+"use strict";
+var ConditionOperator;
+(function (ConditionOperator) {
+ ConditionOperator[ConditionOperator["AND"] = 0] = "AND";
+ ConditionOperator[ConditionOperator["OR"] = 1] = "OR";
+})(ConditionOperator || (ConditionOperator = {}));
+var EventType;
+(function (EventType) {
+ EventType[EventType["KEYDOWN"] = 0] = "KEYDOWN";
+ EventType[EventType["KEYUP"] = 1] = "KEYUP";
+})(EventType || (EventType = {}));
+/**
+ * Core
+ *
+ * @class
+ * @author Baptiste Donaux <baptiste.donaux@gmail.com> @baptistedonaux
+ */
+var AutoComplete = (function () {
+ // Constructor
+ function AutoComplete(params, selector) {
+ if (params === void 0) { params = {}; }
+ if (selector === void 0) { selector = "[data-autocomplete]"; }
+ if (Array.isArray(selector)) {
+ selector.forEach(function (s) {
+ new AutoComplete(params, s);
+ });
+ }
+ else if (typeof selector == "string") {
+ var elements = document.querySelectorAll(selector);
+ Array.prototype.forEach.call(elements, function (input) {
+ new AutoComplete(params, input);
+ });
+ }
+ else {
+ var specificParams = AutoComplete.merge(AutoComplete.defaults, params, {
+ DOMResults: document.createElement("div")
+ });
+ AutoComplete.prototype.create(specificParams, selector);
+ return specificParams;
+ }
+ }
+ AutoComplete.prototype.create = function (params, element) {
+ params.Input = element;
+ if (params.Input.nodeName.match(/^INPUT$/i) && (params.Input.hasAttribute("type") === false || params.Input.getAttribute("type").match(/^TEXT|SEARCH$/i))) {
+ params.Input.setAttribute("autocomplete", "off");
+ params._Position(params);
+ params.Input.parentNode.appendChild(params.DOMResults);
+ params.$Listeners = {
+ blur: params._Blur.bind(params),
+ destroy: AutoComplete.prototype.destroy.bind(null, params),
+ focus: params._Focus.bind(params),
+ keyup: AutoComplete.prototype.event.bind(null, params, EventType.KEYUP),
+ keydown: AutoComplete.prototype.event.bind(null, params, EventType.KEYDOWN),
+ position: params._Position.bind(params)
+ };
+ for (var event in params.$Listeners) {
+ params.Input.addEventListener(event, params.$Listeners[event]);
+ }
+ }
+ };
+ AutoComplete.prototype.getEventsByType = function (params, type) {
+ var mappings = {};
+ for (var key in params.KeyboardMappings) {
+ var event = EventType.KEYUP;
+ if (params.KeyboardMappings[key].Event !== undefined) {
+ event = params.KeyboardMappings[key].Event;
+ }
+ if (event == type) {
+ mappings[key] = params.KeyboardMappings[key];
+ }
+ }
+ return mappings;
+ };
+ AutoComplete.prototype.event = function (params, type, event) {
+ var eventIdentifier = function (condition) {
+ if ((match === true && mapping.Operator == ConditionOperator.AND) || (match === false && mapping.Operator == ConditionOperator.OR)) {
+ condition = AutoComplete.merge({
+ Not: false
+ }, condition);
+ if (condition.hasOwnProperty("Is")) {
+ if (condition.Is == event.keyCode) {
+ match = !condition.Not;
+ }
+ else {
+ match = condition.Not;
+ }
+ }
+ else if (condition.hasOwnProperty("From") && condition.hasOwnProperty("To")) {
+ if (event.keyCode >= condition.From && event.keyCode <= condition.To) {
+ match = !condition.Not;
+ }
+ else {
+ match = condition.Not;
+ }
+ }
+ }
+ };
+ for (var name in AutoComplete.prototype.getEventsByType(params, type)) {
+ var mapping = AutoComplete.merge({
+ Operator: ConditionOperator.AND
+ }, params.KeyboardMappings[name]), match = ConditionOperator.AND == mapping.Operator;
+ mapping.Conditions.forEach(eventIdentifier);
+ if (match === true) {
+ mapping.Callback.call(params, event);
+ }
+ }
+ };
+ AutoComplete.prototype.makeRequest = function (params, callback) {
+ var propertyHttpHeaders = Object.getOwnPropertyNames(params.HttpHeaders), request = new XMLHttpRequest(), method = params._HttpMethod(), url = params._Url(), queryParams = params._Pre(), queryParamsStringify = encodeURIComponent(params._QueryArg()) + "=" + encodeURIComponent(queryParams);
+ if (method.match(/^GET$/i)) {
+ if (url.indexOf("?") !== -1) {
+ url += "&" + queryParamsStringify;
+ }
+ else {
+ url += "?" + queryParamsStringify;
+ }
+ }
+ request.open(method, url, true);
+ for (var i = propertyHttpHeaders.length - 1; i >= 0; i--) {
+ request.setRequestHeader(propertyHttpHeaders[i], params.HttpHeaders[propertyHttpHeaders[i]]);
+ }
+ request.onreadystatechange = function () {
+ if (request.readyState == 4 && request.status == 200) {
+ params.$Cache[queryParams] = request.response;
+ callback(request.response);
+ }
+ };
+ return request;
+ };
+ AutoComplete.prototype.ajax = function (params, request, timeout) {
+ if (timeout === void 0) { timeout = true; }
+ if (params.$AjaxTimer) {
+ window.clearTimeout(params.$AjaxTimer);
+ }
+ if (timeout === true) {
+ params.$AjaxTimer = window.setTimeout(AutoComplete.prototype.ajax.bind(null, params, request, false), params.Delay);
+ }
+ else {
+ if (params.Request) {
+ params.Request.abort();
+ }
+ params.Request = request;
+ params.Request.send(params._QueryArg() + "=" + params._Pre());
+ }
+ };
+ AutoComplete.prototype.cache = function (params, callback) {
+ var response = params._Cache(params._Pre());
+ if (response === undefined) {
+ var request = AutoComplete.prototype.makeRequest(params, callback);
+ AutoComplete.prototype.ajax(params, request);
+ }
+ else {
+ callback(response);
+ }
+ };
+ AutoComplete.prototype.destroy = function (params) {
+ for (var event in params.$Listeners) {
+ params.Input.removeEventListener(event, params.$Listeners[event]);
+ }
+ params.DOMResults.parentNode.removeChild(params.DOMResults);
+ };
+ return AutoComplete;
+}());
+AutoComplete.merge = function () {
+ var merge = {}, tmp;
+ for (var i = 0; i < arguments.length; i++) {
+ for (tmp in arguments[i]) {
+ merge[tmp] = arguments[i][tmp];
+ }
+ }
+ return merge;
+};
+AutoComplete.defaults = {
+ Delay: 150,
+ EmptyMessage: "No result here",
+ Highlight: {
+ getRegex: function (value) {
+ return new RegExp(value, "ig");
+ },
+ transform: function (value) {
+ return "<strong>" + value + "</strong>";
+ }
+ },
+ HttpHeaders: {
+ "Content-type": "application/x-www-form-urlencoded"
+ },
+ Limit: 0,
+ MinChars: 0,
+ HttpMethod: "GET",
+ QueryArg: "q",
+ Url: null,
+ KeyboardMappings: {
+ "Enter": {
+ Conditions: [{
+ Is: 13,
+ Not: false
+ }],
+ Callback: function (event) {
+ if (this.DOMResults.getAttribute("class").indexOf("open") != -1) {
+ var liActive = this.DOMResults.querySelector("li.active");
+ if (liActive !== null) {
+ event.preventDefault();
+ this._Select(liActive);
+ this.DOMResults.setAttribute("class", "autocomplete");
+ }
+ }
+ },
+ Operator: ConditionOperator.AND,
+ Event: EventType.KEYDOWN
+ },
+ "KeyUpAndDown_down": {
+ Conditions: [{
+ Is: 38,
+ Not: false
+ },
+ {
+ Is: 40,
+ Not: false
+ }],
+ Callback: function (event) {
+ event.preventDefault();
+ },
+ Operator: ConditionOperator.OR,
+ Event: EventType.KEYDOWN
+ },
+ "KeyUpAndDown_up": {
+ Conditions: [{
+ Is: 38,
+ Not: false
+ },
+ {
+ Is: 40,
+ Not: false
+ }],
+ Callback: function (event) {
+ event.preventDefault();
+ var first = this.DOMResults.querySelector("li:first-child:not(.locked)"), last = this.DOMResults.querySelector("li:last-child:not(.locked)"), active = this.DOMResults.querySelector("li.active");
+ if (active) {
+ var currentIndex = Array.prototype.indexOf.call(active.parentNode.children, active), position = currentIndex + (event.keyCode - 39), lisCount = this.DOMResults.getElementsByTagName("li").length;
+ if (position < 0) {
+ position = lisCount - 1;
+ }
+ else if (position >= lisCount) {
+ position = 0;
+ }
+ active.classList.remove("active");
+ active.parentElement.children.item(position).classList.add("active");
+ }
+ else if (last && event.keyCode == 38) {
+ last.classList.add("active");
+ }
+ else if (first) {
+ first.classList.add("active");
+ }
+ },
+ Operator: ConditionOperator.OR,
+ Event: EventType.KEYUP
+ },
+ "AlphaNum": {
+ Conditions: [{
+ Is: 13,
+ Not: true
+ }, {
+ From: 35,
+ To: 40,
+ Not: true
+ }],
+ Callback: function () {
+ var oldValue = this.Input.getAttribute("data-autocomplete-old-value"), currentValue = this._Pre();
+ if (currentValue !== "" && currentValue.length >= this._MinChars()) {
+ if (!oldValue || currentValue != oldValue) {
+ this.DOMResults.setAttribute("class", "autocomplete open");
+ }
+ AutoComplete.prototype.cache(this, function (response) {
+ this._Render(this._Post(response));
+ this._Open();
+ }.bind(this));
+ }
+ },
+ Operator: ConditionOperator.AND,
+ Event: EventType.KEYUP
+ }
+ },
+ DOMResults: null,
+ Request: null,
+ Input: null,
+ /**
+ * Return the message when no result returns
+ */
+ _EmptyMessage: function () {
+ var emptyMessage = "";
+ if (this.Input.hasAttribute("data-autocomplete-empty-message")) {
+ emptyMessage = this.Input.getAttribute("data-autocomplete-empty-message");
+ }
+ else if (this.EmptyMessage !== false) {
+ emptyMessage = this.EmptyMessage;
+ }
+ else {
+ emptyMessage = "";
+ }
+ return emptyMessage;
+ },
+ /**
+ * Returns the maximum number of results
+ */
+ _Limit: function () {
+ var limit = this.Input.getAttribute("data-autocomplete-limit");
+ if (isNaN(limit) || limit === null) {
+ return this.Limit;
+ }
+ return parseInt(limit, 10);
+ },
+ /**
+ * Returns the minimum number of characters entered before firing ajax
+ */
+ _MinChars: function () {
+ var minchars = this.Input.getAttribute("data-autocomplete-minchars");
+ if (isNaN(minchars) || minchars === null) {
+ return this.MinChars;
+ }
+ return parseInt(minchars, 10);
+ },
+ /**
+ * Apply transformation on labels response
+ */
+ _Highlight: function (label) {
+ return label.replace(this.Highlight.getRegex(this._Pre()), this.Highlight.transform);
+ },
+ /**
+ * Returns the HHTP method to use
+ */
+ _HttpMethod: function () {
+ if (this.Input.hasAttribute("data-autocomplete-method")) {
+ return this.Input.getAttribute("data-autocomplete-method");
+ }
+ return this.HttpMethod;
+ },
+ /**
+ * Returns the query param to use
+ */
+ _QueryArg: function () {
+ if (this.Input.hasAttribute("data-autocomplete-param-name")) {
+ return this.Input.getAttribute("data-autocomplete-param-name");
+ }
+ return this.QueryArg;
+ },
+ /**
+ * Returns the URL to use for AJAX request
+ */
+ _Url: function () {
+ if (this.Input.hasAttribute("data-autocomplete")) {
+ return this.Input.getAttribute("data-autocomplete");
+ }
+ return this.Url;
+ },
+ /**
+ * Manage the close
+ */
+ _Blur: function (now) {
+ if (now === true) {
+ this.DOMResults.setAttribute("class", "autocomplete");
+ this.Input.setAttribute("data-autocomplete-old-value", this.Input.value);
+ }
+ else {
+ var params = this;
+ setTimeout(function () {
+ params._Blur(true);
+ }, 150);
+ }
+ },
+ /**
+ * Manage the cache
+ */
+ _Cache: function (value) {
+ return this.$Cache[value];
+ },
+ /**
+ * Manage the open
+ */
+ _Focus: function () {
+ var oldValue = this.Input.getAttribute("data-autocomplete-old-value");
+ if ((!oldValue || this.Input.value != oldValue) && this._MinChars() <= this.Input.value.length) {
+ this.DOMResults.setAttribute("class", "autocomplete open");
+ }
+ },
+ /**
+ * Bind all results item if one result is opened
+ */
+ _Open: function () {
+ var params = this;
+ Array.prototype.forEach.call(this.DOMResults.getElementsByTagName("li"), function (li) {
+ if (li.getAttribute("class") != "locked") {
+ li.onclick = function (event) {
+ params._Select(li);
+ };
+ li.onmouseenter = function () {
+ var active = params.DOMResults.querySelector("li.active");
+ if (active !== li) {
+ if (active !== null) {
+ active.classList.remove("active");
+ }
+ li.classList.add("active");
+ }
+ };
+ }
+ });
+ },
+ /**
+ * Position the results HTML element
+ */
+ _Position: function () {
+ this.DOMResults.setAttribute("class", "autocomplete");
+ this.DOMResults.setAttribute("style", "top:" + (this.Input.offsetTop + this.Input.offsetHeight) + "px;left:" + this.Input.offsetLeft + "px;width:" + this.Input.clientWidth + "px;");
+ },
+ /**
+ * Execute the render of results DOM element
+ */
+ _Render: function (response) {
+ var ul;
+ if (typeof response == "string") {
+ ul = this._RenderRaw(response);
+ }
+ else {
+ ul = this._RenderResponseItems(response);
+ }
+ if (this.DOMResults.hasChildNodes()) {
+ this.DOMResults.removeChild(this.DOMResults.childNodes[0]);
+ }
+ this.DOMResults.appendChild(ul);
+ },
+ /**
+ * ResponseItems[] rendering
+ */
+ _RenderResponseItems: function (response) {
+ var ul = document.createElement("ul"), li = document.createElement("li"), limit = this._Limit();
+ // Order
+ if (limit < 0) {
+ response = response.reverse();
+ }
+ else if (limit === 0) {
+ limit = response.length;
+ }
+ for (var item = 0; item < Math.min(Math.abs(limit), response.length); item++) {
+ li.innerHTML = response[item].Label;
+ li.setAttribute("data-autocomplete-value", response[item].Value);
+ ul.appendChild(li);
+ li = document.createElement("li");
+ }
+ return ul;
+ },
+ /**
+ * string response rendering (RAW HTML)
+ */
+ _RenderRaw: function (response) {
+ var ul = document.createElement("ul"), li = document.createElement("li");
+ if (response.length > 0) {
+ this.DOMResults.innerHTML = response;
+ }
+ else {
+ var emptyMessage = this._EmptyMessage();
+ if (emptyMessage !== "") {
+ li.innerHTML = emptyMessage;
+ li.setAttribute("class", "locked");
+ ul.appendChild(li);
+ }
+ }
+ return ul;
+ },
+ /**
+ * Deal with request response
+ */
+ _Post: function (response) {
+ try {
+ var returnResponse = [];
+ //JSON return
+ var json = JSON.parse(response);
+ if (Object.keys(json).length === 0) {
+ return "";
+ }
+ if (Array.isArray(json)) {
+ for (var i = 0; i < Object.keys(json).length; i++) {
+ returnResponse[returnResponse.length] = { "Value": json[i], "Label": this._Highlight(json[i]) };
+ }
+ }
+ else {
+ for (var value in json) {
+ returnResponse.push({
+ "Value": value,
+ "Label": this._Highlight(json[value])
+ });
+ }
+ }
+ return returnResponse;
+ }
+ catch (event) {
+ //HTML return
+ return response;
+ }
+ },
+ /**
+ * Return the autocomplete value to send (before request)
+ */
+ _Pre: function () {
+ return this.Input.value;
+ },
+ /**
+ * Choice one result item
+ */
+ _Select: function (item) {
+ console.log('test test test');
+ if (item.hasAttribute("data-autocomplete-value")) {
+ this.Input.value = item.getAttribute("data-autocomplete-value");
+ }
+ else {
+ this.Input.value = item.innerHTML;
+ }
+ this.Input.setAttribute("data-autocomplete-old-value", this.Input.value);
+ },
+ $AjaxTimer: null,
+ $Cache: {},
+ $Listeners: {}
+};
+module.exports = AutoComplete;
+
+},{}]},{},[1])(1)
+});
diff --git a/searx/static/themes/simple/js/searx_src/searx_imageresult.js b/searx/static/themes/simple/js/searx_src/searx_imageresult.js
new file mode 100644
index 000000000..7bbfc1454
--- /dev/null
+++ b/searx/static/themes/simple/js/searx_src/searx_imageresult.js
@@ -0,0 +1,151 @@
+/**
+*
+* Google Image Layout v0.0.1
+* Description, by Anh Trinh.
+* Heavily modified for searx
+* http://trinhtrunganh.com
+*
+* @license Free to use under the MIT License.
+*
+*/
+(function(w, d) {
+ 'use strict';
+
+ function ImageLayout(container_selector, results_selector, img_selector, maxHeight) {
+ this.container_selector = container_selector;
+ this.results_selector = results_selector;
+ this.img_selector = img_selector;
+ this.margin = 10;
+ this.maxHeight = maxHeight;
+ this._alignAllDone = true;
+ }
+
+ /**
+ * Get the height that make all images fit the container
+ *
+ * width = w1 + w2 + w3 + ... = r1*h + r2*h + r3*h + ...
+ *
+ * @param {[type]} images the images to be calculated
+ * @param {[type]} width the container witdth
+ * @param {[type]} margin the margin between each image
+ *
+ * @return {[type]} the height
+ */
+ ImageLayout.prototype._getHeigth = function(images, width) {
+ var r = 0,
+ img;
+
+ width -= images.length * this.margin;
+ for (var i = 0; i < images.length; i++) {
+ img = images[i];
+ if ((img.naturalWidth > 0) && (img.naturalHeight > 0)) {
+ r += img.naturalWidth / img.naturalHeight;
+ } else {
+ // assume that not loaded images are square
+ r += 1;
+ }
+ }
+
+ return width / r; //have to round down because Firefox will automatically roundup value with number of decimals > 3
+ };
+
+ ImageLayout.prototype._setSize = function(images, height) {
+ var img, imgWidth, imagesLength = images.length;
+ for (var i = 0; i < imagesLength; i++) {
+ img = images[i];
+ if ((img.naturalWidth > 0) && (img.naturalHeight > 0)) {
+ imgWidth = height * img.naturalWidth / img.naturalHeight;
+ } else {
+ // not loaded image : make it square as _getHeigth said it
+ imgWidth = height;
+ }
+ img.style.width = imgWidth + 'px';
+ img.style.height = height + 'px';
+ img.style.marginLeft = '3px';
+ img.style.marginTop = '3px';
+ img.style.marginRight = this.margin - 7 + 'px'; // -4 is the negative margin of the inline element
+ img.style.marginBottom = this.margin - 7 + 'px';
+ }
+ };
+
+ ImageLayout.prototype._alignImgs = function(imgGroup) {
+ var slice, h,
+ containerWidth = d.querySelector(this.container_selector).clientWidth;
+
+ w: while (imgGroup.length > 0) {
+ for (var i = 1; i <= imgGroup.length; i++) {
+ slice = imgGroup.slice(0, i);
+ h = this._getHeigth(slice, containerWidth);
+ if (h < this.maxHeight) {
+ this._setSize(slice, h);
+ imgGroup = imgGroup.slice(i);
+ continue w;
+ }
+ }
+ this._setSize(slice, Math.min(this.maxHeight, h));
+ break;
+ }
+ };
+
+ ImageLayout.prototype.align = function(results_selector) {
+ var results_selectorNode = d.querySelectorAll(this.results_selector),
+ results_length = results_selectorNode.length,
+ previous = null,
+ current = null,
+ imgGroup = [];
+ for (var i = 0; i < results_length; i++) {
+ current = results_selectorNode[i];
+ if (current.previousElementSibling !== previous && imgGroup.length > 0) {
+ // the current image is not conected to previous one
+ // so the current image is the start of a new group of images.
+ // so call _alignImgs to align the current group
+ this._alignImgs(imgGroup);
+ // and start a new empty group of images
+ imgGroup = [];
+ }
+ // add the current image to the group (only the img tag)
+ imgGroup.push(current.querySelector(this.img_selector));
+ // update the previous variable
+ previous = current;
+ }
+ // align the remaining images
+ if (imgGroup.length > 0) {
+ this._alignImgs(imgGroup);
+ }
+ };
+
+ ImageLayout.prototype.watch = function() {
+ var i, img, imgGroup, imgNodeLength,
+ obj = this,
+ results_nodes = d.querySelectorAll(this.results_selector),
+ results_length = results_nodes.length;
+
+ function align(e) {
+ obj.align();
+ }
+
+ function throttleAlign(e) {
+ if (obj._alignAllDone) {
+ obj._alignAllDone = false;
+ setTimeout(function() {
+ obj.align();
+ obj._alignAllDone = true;
+ }, 100);
+ }
+ }
+
+ w.addEventListener('resize', throttleAlign);
+ w.addEventListener('pageshow', align);
+
+ for (i = 0; i < results_length; i++) {
+ img = results_nodes[i].querySelector(this.img_selector);
+ if (typeof img !== 'undefined') {
+ img.addEventListener('load', throttleAlign);
+ img.addEventListener('error', throttleAlign);
+ }
+ }
+ };
+
+ w.searx.ImageLayout = ImageLayout;
+
+})(window, document);
diff --git a/searx/static/themes/simple/js/searx_src/searx_keyboard.js b/searx/static/themes/simple/js/searx_src/searx_keyboard.js
new file mode 100644
index 000000000..657d9ec93
--- /dev/null
+++ b/searx/static/themes/simple/js/searx_src/searx_keyboard.js
@@ -0,0 +1,366 @@
+searx.ready(function() {
+
+ searx.on('.result', 'click', function() {
+ highlightResult(this)(true);
+ });
+
+ searx.on('.result a', 'focus', function(e) {
+ var el = e.target;
+ while (el !== undefined) {
+ if (el.classList.contains('result')) {
+ if (el.getAttribute("data-vim-selected") === null) {
+ highlightResult(el)(true);
+ }
+ break;
+ }
+ el = el.parentNode;
+ }
+ }, true);
+
+ var vimKeys = {
+ 27: {
+ key: 'Escape',
+ fun: removeFocus,
+ des: 'remove focus from the focused input',
+ cat: 'Control'
+ },
+ 73: {
+ key: 'i',
+ fun: searchInputFocus,
+ des: 'focus on the search input',
+ cat: 'Control'
+ },
+ 66: {
+ key: 'b',
+ fun: scrollPage(-window.innerHeight),
+ des: 'scroll one page up',
+ cat: 'Navigation'
+ },
+ 70: {
+ key: 'f',
+ fun: scrollPage(window.innerHeight),
+ des: 'scroll one page down',
+ cat: 'Navigation'
+ },
+ 85: {
+ key: 'u',
+ fun: scrollPage(-window.innerHeight / 2),
+ des: 'scroll half a page up',
+ cat: 'Navigation'
+ },
+ 68: {
+ key: 'd',
+ fun: scrollPage(window.innerHeight / 2),
+ des: 'scroll half a page down',
+ cat: 'Navigation'
+ },
+ 71: {
+ key: 'g',
+ fun: scrollPageTo(-document.body.scrollHeight, 'top'),
+ des: 'scroll to the top of the page',
+ cat: 'Navigation'
+ },
+ 86: {
+ key: 'v',
+ fun: scrollPageTo(document.body.scrollHeight, 'bottom'),
+ des: 'scroll to the bottom of the page',
+ cat: 'Navigation'
+ },
+ 75: {
+ key: 'k',
+ fun: highlightResult('up'),
+ des: 'select previous search result',
+ cat: 'Results'
+ },
+ 74: {
+ key: 'j',
+ fun: highlightResult('down'),
+ des: 'select next search result',
+ cat: 'Results'
+ },
+ 80: {
+ key: 'p',
+ fun: pageButtonClick(0),
+ des: 'go to previous page',
+ cat: 'Results'
+ },
+ 78: {
+ key: 'n',
+ fun: pageButtonClick(1),
+ des: 'go to next page',
+ cat: 'Results'
+ },
+ 79: {
+ key: 'o',
+ fun: openResult(false),
+ des: 'open search result',
+ cat: 'Results'
+ },
+ 84: {
+ key: 't',
+ fun: openResult(true),
+ des: 'open the result in a new tab',
+ cat: 'Results'
+ },
+ 82: {
+ key: 'r',
+ fun: reloadPage,
+ des: 'reload page from the server',
+ cat: 'Control'
+ },
+ 72: {
+ key: 'h',
+ fun: toggleHelp,
+ des: 'toggle help window',
+ cat: 'Other'
+ }
+ };
+
+ 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) {
+ var tagName = e.target.tagName.toLowerCase();
+ if (e.keyCode === 27) {
+ if (tagName === 'input' || tagName === 'select' || tagName === 'textarea') {
+ vimKeys[e.keyCode].fun();
+ }
+ } else {
+ if (e.target === document.body || tagName === 'a' || tagName === 'button') {
+ e.preventDefault();
+ vimKeys[e.keyCode].fun();
+ }
+ }
+ }
+ });
+
+ function highlightResult(which) {
+ return function(noScroll) {
+ var current = document.querySelector('.result[data-vim-selected]'),
+ effectiveWhich = which;
+ if (current === null) {
+ // no selection : choose the first one
+ current = document.querySelector('.result');
+ if (current === null) {
+ // no first one : there are no results
+ return;
+ }
+ // replace up/down actions by selecting first one
+ if (which === "down" || which === "up") {
+ effectiveWhich = current;
+ }
+ }
+
+ var next, results = document.querySelectorAll('.result');
+
+ if (typeof effectiveWhich !== 'string') {
+ next = effectiveWhich;
+ } else {
+ switch (effectiveWhich) {
+ case 'visible':
+ var top = document.documentElement.scrollTop || document.body.scrollTop;
+ var bot = top + document.documentElement.clientHeight;
+
+ for (var i = 0; i < results.length; i++) {
+ next = results[i];
+ var etop = next.offsetTop;
+ var ebot = etop + next.clientHeight;
+
+ if ((ebot <= bot) && (etop > top)) {
+ break;
+ }
+ }
+ break;
+ case 'down':
+ next = current.nextElementSibling;
+ if (next === null) {
+ next = results[0];
+ }
+ break;
+ case 'up':
+ next = current.previousElementSibling;
+ if (next === null) {
+ next = results[results.length - 1];
+ }
+ break;
+ case 'bottom':
+ next = results[results.length - 1];
+ break;
+ case 'top':
+ /* falls through */
+ default:
+ next = results[0];
+ }
+ }
+
+ if (next) {
+ current.removeAttribute('data-vim-selected');
+ next.setAttribute('data-vim-selected', 'true');
+ var link = next.querySelector('h3 a') || next.querySelector('a');
+ if (link !== null) {
+ link.focus();
+ }
+ if (!noScroll) {
+ scrollPageToSelected();
+ }
+ }
+ };
+ }
+
+ function reloadPage() {
+ document.location.reload(true);
+ }
+
+ function removeFocus() {
+ if (document.activeElement) {
+ document.activeElement.blur();
+ }
+ }
+
+ function pageButtonClick(num) {
+ 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');
+ }
+ };
+ }
+
+ function scrollPageToSelected() {
+ var sel = document.querySelector('.result[data-vim-selected]');
+ if (sel === null) {
+ return;
+ }
+ var wtop = document.documentElement.scrollTop || document.body.scrollTop,
+ wheight = document.documentElement.clientHeight,
+ etop = sel.offsetTop,
+ ebot = etop + sel.clientHeight,
+ offset = 120;
+ // first element ?
+ if ((sel.previousElementSibling === null) && (ebot < wheight)) {
+ // set to the top of page if the first element
+ // is fully included in the viewport
+ window.scroll(window.scrollX, 0);
+ return;
+ }
+ if (wtop > (etop - offset)) {
+ window.scroll(window.scrollX, etop - offset);
+ } else {
+ var wbot = wtop + wheight;
+ if (wbot < (ebot + offset)) {
+ window.scroll(window.scrollX, ebot - wheight + offset);
+ }
+ }
+ }
+
+ function scrollPage(amount) {
+ return function() {
+ window.scrollBy(0, amount);
+ highlightResult('visible')();
+ };
+ }
+
+ function scrollPageTo(position, nav) {
+ return function() {
+ window.scrollTo(0, position);
+ highlightResult(nav)();
+ };
+ }
+
+ function searchInputFocus() {
+ window.scrollTo(0, 0);
+ document.querySelector('#q').focus();
+ }
+
+ function openResult(newTab) {
+ return function() {
+ var link = document.querySelector('.result[data-vim-selected] h3 a');
+ if (link !== null) {
+ var url = link.getAttribute('href');
+ if (newTab) {
+ window.open(url);
+ } else {
+ window.location.href = url;
+ }
+ }
+ };
+ }
+
+ function initHelpContent(divElement) {
+ var categories = {};
+
+ for (var k in vimKeys) {
+ var key = vimKeys[k];
+ categories[key.cat] = categories[key.cat] || [];
+ categories[key.cat].push(key);
+ }
+
+ var sorted = Object.keys(categories).sort(function(a, b) {
+ return categories[b].length - categories[a].length;
+ });
+
+ if (sorted.length === 0) {
+ return;
+ }
+
+ var html = '<a href="#" class="close" aria-label="close" title="close">×</a>';
+ html += '<h3>How to navigate searx with Vim-like hotkeys</h3>';
+ html += '<table>';
+
+ for (var i = 0; i < sorted.length; i++) {
+ var cat = categories[sorted[i]];
+
+ var lastCategory = i === (sorted.length - 1);
+ var first = i % 2 === 0;
+
+ if (first) {
+ html += '<tr>';
+ }
+ html += '<td>';
+
+ html += '<h4>' + cat[0].cat + '</h4>';
+ html += '<ul class="list-unstyled">';
+
+ for (var cj in cat) {
+ html += '<li><kbd>' + cat[cj].key + '</kbd> ' + cat[cj].des + '</li>';
+ }
+
+ html += '</ul>';
+ html += '</td>'; // col-sm-*
+
+ if (!first || lastCategory) {
+ html += '</tr>'; // row
+ }
+ }
+
+ html += '</table>';
+
+ 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%';
+ initHelpContent(helpPanel);
+ var body = document.getElementsByTagName('body')[0];
+ body.appendChild(helpPanel);
+ } else {
+ // togggle hidden
+ helpPanel.classList.toggle('invisible');
+ return;
+ }
+
+ }
+
+});
diff --git a/searx/static/themes/simple/js/searx_src/searx_mapresult.js b/searx/static/themes/simple/js/searx_src/searx_mapresult.js
new file mode 100644
index 000000000..869d07da0
--- /dev/null
+++ b/searx/static/themes/simple/js/searx_src/searx_mapresult.js
@@ -0,0 +1,176 @@
+/**
+* searx is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2014 by Thomas Pointhuber, <thomas.pointhuber@gmx.at>
+* (C) 2017 by Alexandre Flament, <alex@al-f.net>
+*/
+(function (w, d, searx) {
+ 'use strict';
+
+ searx.ready(function () {
+ searx.on('.searx_overpass_request', 'click', function(event) {
+ // no more request
+ this.classList.remove("searx_overpass_request");
+
+ //
+ var overpass_url = "https://overpass-api.de/api/interpreter?data=";
+ var query_start = overpass_url + "[out:json][timeout:25];(";
+ var query_end = ");out meta;";
+
+ var osm_id = this.dataset.osmId;
+ var osm_type = this.dataset.osmType;
+ var result_table = d.querySelector("#" + this.dataset.resultTable);
+ var result_table_loadicon = d.querySelector("#" + this.dataset.resultTableLoadicon);
+
+ // tags which can be ignored
+ var osm_ignore_tags = [ "addr:city", "addr:country", "addr:housenumber", "addr:postcode", "addr:street" ];
+
+ if(osm_id && osm_type && result_table) {
+ var query = null;
+ switch(osm_type) {
+ case 'node':
+ query = query_start + "node(" + osm_id + ");" + query_end;
+ break;
+ case 'way':
+ query = query_start + "way(" + osm_id + ");" + query_end;
+ break;
+ case 'relation':
+ query = query_start + "relation(" + osm_id + ");" + query_end;
+ break;
+ default:
+ break;
+ }
+ if(query) {
+ // console.log(query);
+ searx.http( 'GET', query ).then(function(html, contentType) {
+ html = JSON.parse(html);
+ if(html && html.elements && html.elements[0]) {
+ var element = html.elements[0];
+ var newHtml = "";
+ for (var row in element.tags) {
+ if(element.tags.name === null || osm_ignore_tags.indexOf(row) == -1) {
+ newHtml += "<tr><td>" + row + "</td><td>";
+ switch(row) {
+ case "phone":
+ case "fax":
+ newHtml += "<a href=\"tel:" + element.tags[row].replace(/ /g,'') + "\">" + element.tags[row] + "</a>";
+ break;
+ case "email":
+ newHtml += "<a href=\"mailto:" + element.tags[row] + "\">" + element.tags[row] + "</a>";
+ break;
+ case "website":
+ case "url":
+ newHtml += "<a href=\"" + element.tags[row] + "\">" + element.tags[row] + "</a>";
+ break;
+ case "wikidata":
+ newHtml += "<a href=\"https://www.wikidata.org/wiki/" + element.tags[row] + "\">" + element.tags[row] + "</a>";
+ break;
+ case "wikipedia":
+ if(element.tags[row].indexOf(":") != -1) {
+ newHtml += "<a href=\"https://" + element.tags[row].substring(0,element.tags[row].indexOf(":")) + ".wikipedia.org/wiki/" + element.tags[row].substring(element.tags[row].indexOf(":")+1) + "\">" + element.tags[row] + "</a>";
+ break;
+ }
+ /* jshint ignore:start */
+ default:
+ /* jshint ignore:end */
+ newHtml += element.tags[row];
+ break;
+ }
+ newHtml += "</td></tr>";
+ }
+ }
+ result_table_loadicon.parentNode.removeChild(result_table_loadicon);
+ result_table.classList.remove('invisible');
+ result_table.querySelector("tbody").innerHTML = newHtml;
+ }
+ })
+ .catch(function() {
+ result_table_loadicon.classList.remove('invisible');
+ result_table_loadicon.innerHTML = "could not load data!";
+ });
+ }
+ }
+
+ // this event occour only once per element
+ event.preventDefault();
+ });
+
+ searx.on('.searx_init_map', 'click', function(event) {
+ // no more request
+ this.classList.remove("searx_init_map");
+
+ //
+ var leaflet_target = this.dataset.leafletTarget;
+ var map_lon = parseFloat(this.dataset.mapLon);
+ var map_lat = parseFloat(this.dataset.mapLat);
+ var map_zoom = parseFloat(this.dataset.mapZoom);
+ var map_boundingbox = JSON.parse(this.dataset.mapBoundingbox);
+ var map_geojson = JSON.parse(this.dataset.mapGeojson);
+
+ searx.loadStyle('leaflet/leaflet.css');
+ searx.loadScript('leaflet/leaflet.js', function() {
+ var map_bounds = null;
+ if(map_boundingbox) {
+ var southWest = L.latLng(map_boundingbox[0], map_boundingbox[2]);
+ var northEast = L.latLng(map_boundingbox[1], map_boundingbox[3]);
+ map_bounds = L.latLngBounds(southWest, northEast);
+ }
+
+ // init map
+ var map = L.map(leaflet_target);
+ // create the tile layer with correct attribution
+ var osmMapnikUrl='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
+ var osmMapnikAttrib='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> 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 © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';
+ var osmWikimedia = new L.TileLayer(osmWikimediaUrl, {minZoom: 1, maxZoom: 19, attribution: osmWikimediaAttrib});
+ // init map view
+ if(map_bounds) {
+ // TODO hack: https://github.com/Leaflet/Leaflet/issues/2021
+ // Still useful ?
+ setTimeout(function () {
+ map.fitBounds(map_bounds, {
+ maxZoom:17
+ });
+ }, 0);
+ } else if (map_lon && map_lat) {
+ if(map_zoom) {
+ map.setView(new L.latLng(map_lat, map_lon),map_zoom);
+ } else {
+ map.setView(new L.latLng(map_lat, map_lon),8);
+ }
+ }
+
+ map.addLayer(osmMapnik);
+
+ var baseLayers = {
+ "OSM Mapnik": osmMapnik/*,
+ "OSM Wikimedia": osmWikimedia*/
+ };
+
+ L.control.layers(baseLayers).addTo(map);
+
+ if(map_geojson) {
+ L.geoJson(map_geojson).addTo(map);
+ } /*else if(map_bounds) {
+ L.rectangle(map_bounds, {color: "#ff7800", weight: 3, fill:false}).addTo(map);
+ }*/
+ });
+
+ // this event occour only once per element
+ event.preventDefault();
+ });
+ });
+})(window, document, window.searx);
diff --git a/searx/static/themes/simple/js/searx_src/searx_results.js b/searx/static/themes/simple/js/searx_src/searx_results.js
new file mode 100644
index 000000000..b13da8391
--- /dev/null
+++ b/searx/static/themes/simple/js/searx_src/searx_results.js
@@ -0,0 +1,63 @@
+/**
+* searx is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2017 by Alexandre Flament, <alex@al-f.net>
+*/
+(function(w, d, searx) {
+ 'use strict';
+
+ searx.ready(function() {
+ searx.image_thumbnail_layout = new searx.ImageLayout('#urls', '#urls .result-images', 'img.image_thumbnail', 200);
+ searx.image_thumbnail_layout.watch();
+
+ searx.on('.btn-collapse', 'click', function(event) {
+ var btnLabelCollapsed = this.getAttribute('data-btn-text-collapsed');
+ var btnLabelNotCollapsed = this.getAttribute('data-btn-text-not-collapsed');
+ var target = this.getAttribute('data-target');
+ var targetElement = d.querySelector(target);
+ var html = this.innerHTML;
+ if (this.classList.contains('collapsed')) {
+ html = html.replace(btnLabelCollapsed, btnLabelNotCollapsed);
+ } else {
+ html = html.replace(btnLabelNotCollapsed, btnLabelCollapsed);
+ }
+ this.innerHTML = html;
+ this.classList.toggle('collapsed');
+ targetElement.classList.toggle('invisible');
+ });
+
+ searx.on('.media-loader', 'click', function(event) {
+ var target = this.getAttribute('data-target');
+ var iframe_load = d.querySelector(target + ' > iframe');
+ var srctest = iframe_load.getAttribute('src');
+ if (srctest === null || srctest === undefined || srctest === false) {
+ iframe_load.setAttribute('src', iframe_load.getAttribute('data-src'));
+ }
+ });
+
+ w.addEventListener('scroll', function() {
+ var e = d.getElementById('backToTop'),
+ scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
+ if (e !== null) {
+ if (scrollTop >= 200) {
+ e.style.opacity = 1;
+ } else {
+ e.style.opacity = 0;
+ }
+ }
+ });
+
+ });
+
+})(window, document, window.searx);
diff --git a/searx/static/themes/simple/js/searx_src/searx_search.js b/searx/static/themes/simple/js/searx_src/searx_search.js
new file mode 100644
index 000000000..580d98d6a
--- /dev/null
+++ b/searx/static/themes/simple/js/searx_src/searx_search.js
@@ -0,0 +1,117 @@
+/**
+* searx is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* searx is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with searx. If not, see < http://www.gnu.org/licenses/ >.
+*
+* (C) 2017 by Alexandre Flament, <alex@al-f.net>
+*/
+(function(w, d, searx) {
+ 'use strict';
+
+ var firstFocus = true, qinput_id = "q", qinput;
+
+ function placeCursorAtEnd(element) {
+ if (element.setSelectionRange) {
+ var len = element.value.length;
+ element.setSelectionRange(len, len);
+ }
+ }
+
+ function submitIfQuery() {
+ if (qinput.value.length > 0) {
+ var search = document.getElementById('search');
+ setTimeout(search.submit.bind(search), 0);
+ }
+ }
+
+ function createClearButton(qinput) {
+ var cs = document.getElementById('clear_search');
+ var updateClearButton = function() {
+ if (qinput.value.length === 0) {
+ cs.classList.add("empty");
+ } else {
+ cs.classList.remove("empty");
+ }
+ };
+
+ // update status, event listener
+ updateClearButton();
+ cs.addEventListener('click', function() {
+ qinput.value='';
+ qinput.focus();
+ updateClearButton();
+ });
+ qinput.addEventListener('keyup', updateClearButton, false);
+ }
+
+ searx.ready(function() {
+ qinput = d.getElementById(qinput_id);
+
+ function placeCursorAtEndOnce(e) {
+ if (firstFocus) {
+ placeCursorAtEnd(qinput);
+ firstFocus = false;
+ } else {
+ // e.preventDefault();
+ }
+ }
+
+ if (qinput !== null) {
+ // clear button
+ createClearButton(qinput);
+
+ // autocompleter
+ if (searx.autocompleter) {
+ searx.autocomplete = AutoComplete.call(w, {
+ Url: "./autocompleter",
+ EmptyMessage: searx.no_item_found,
+ HttpMethod: searx.method,
+ MinChars: 4,
+ Delay: 300,
+ }, "#" + qinput_id);
+
+ // hack, see : https://github.com/autocompletejs/autocomplete.js/issues/37
+ w.addEventListener('resize', function() {
+ var event = new CustomEvent("position");
+ qinput.dispatchEvent(event);
+ });
+ }
+
+ qinput.addEventListener('focus', placeCursorAtEndOnce, false);
+ qinput.focus();
+ }
+
+ // vanilla js version of search_on_category_select.js
+ if (qinput !== null && searx.search_on_category_select) {
+ d.querySelector('.help').className='invisible';
+
+ searx.on('#categories input', 'change', function(e) {
+ var i, categories = d.querySelectorAll('#categories input[type="checkbox"]');
+ for(i=0; i<categories.length; i++) {
+ if (categories[i] !== this && categories[i].checked) {
+ categories[i].click();
+ }
+ }
+ if (! this.checked) {
+ this.click();
+ }
+ submitIfQuery();
+ return false;
+ });
+
+ searx.on(d.getElementById('time_range'), 'change', submitIfQuery);
+ searx.on(d.getElementById('language'), 'change', submitIfQuery);
+ }
+
+ });
+
+})(window, document, window.searx);