forked from Ponysearch/Ponysearch
[fix] eslint --fix
automatically fix some of the problems reported by eslint rules:: $ ./manage nvm.bash nvm-env$ npm --prefix searx/static/themes/simple run eslint-fix Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
32cf24a272
commit
34f5e9c7a3
10 changed files with 201 additions and 201 deletions
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
(function (w, d) {
|
(function (w, d) {
|
||||||
function ImageLayout(container_selector, results_selector, img_selector, verticalMargin, horizontalMargin, maxHeight) {
|
function ImageLayout (container_selector, results_selector, img_selector, verticalMargin, horizontalMargin, maxHeight) {
|
||||||
this.container_selector = container_selector;
|
this.container_selector = container_selector;
|
||||||
this.results_selector = results_selector;
|
this.results_selector = results_selector;
|
||||||
this.img_selector = img_selector;
|
this.img_selector = img_selector;
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (width - images.length * this.verticalMargin) / r; //have to round down because Firefox will automatically roundup value with number of decimals > 3
|
return (width - images.length * this.verticalMargin) / r; // have to round down because Firefox will automatically roundup value with number of decimals > 3
|
||||||
};
|
};
|
||||||
|
|
||||||
ImageLayout.prototype._setSize = function (images, height) {
|
ImageLayout.prototype._setSize = function (images, height) {
|
||||||
|
@ -147,12 +147,12 @@
|
||||||
var results_nodes = d.querySelectorAll(this.results_selector);
|
var results_nodes = d.querySelectorAll(this.results_selector);
|
||||||
var results_length = results_nodes.length;
|
var results_length = results_nodes.length;
|
||||||
|
|
||||||
function img_load_error(event) {
|
function img_load_error (event) {
|
||||||
// console.log("ERROR can't load: " + event.originalTarget.src);
|
// console.log("ERROR can't load: " + event.originalTarget.src);
|
||||||
event.originalTarget.src = w.searxng.static_path + w.searxng.theme.img_load_error;
|
event.originalTarget.src = w.searxng.static_path + w.searxng.theme.img_load_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function throttleAlign() {
|
function throttleAlign () {
|
||||||
if (obj.isAlignDone) {
|
if (obj.isAlignDone) {
|
||||||
obj.isAlignDone = false;
|
obj.isAlignDone = false;
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function (grunt) {
|
||||||
|
|
||||||
const eachAsync = require('each-async');
|
const eachAsync = require('each-async');
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ module.exports = function(grunt) {
|
||||||
new (require('less-plugin-clean-css'))()
|
new (require('less-plugin-clean-css'))()
|
||||||
],
|
],
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
sourceMapURL: (name) => { const s = name.split('/'); return s[s.length - 1] + '.map';},
|
sourceMapURL: (name) => { const s = name.split('/'); return s[s.length - 1] + '.map'; },
|
||||||
outputSourceFiles: true,
|
outputSourceFiles: true,
|
||||||
},
|
},
|
||||||
files: {
|
files: {
|
||||||
|
@ -178,10 +178,10 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerMultiTask('svg2jinja', 'Create Jinja2 macro', function() {
|
grunt.registerMultiTask('svg2jinja', 'Create Jinja2 macro', function () {
|
||||||
const ejs = require('ejs'), svgo = require('svgo');
|
const ejs = require('ejs'), svgo = require('svgo');
|
||||||
const icons = {}
|
const icons = {}
|
||||||
for(const iconName in this.data.src) {
|
for (const iconName in this.data.src) {
|
||||||
const svgFileName = this.data.src[iconName];
|
const svgFileName = this.data.src[iconName];
|
||||||
try {
|
try {
|
||||||
const svgContent = grunt.file.read(svgFileName, { encoding: 'utf8' })
|
const svgContent = grunt.file.read(svgFileName, { encoding: 'utf8' })
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
/* global DocumentTouch:readonly */
|
/* global DocumentTouch:readonly */
|
||||||
(function(w, d) {
|
(function (w, d) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// add data- properties
|
// add data- properties
|
||||||
var script = d.currentScript || (function() {
|
var script = d.currentScript || (function () {
|
||||||
var scripts = d.getElementsByTagName('script');
|
var scripts = d.getElementsByTagName('script');
|
||||||
return scripts[scripts.length - 1];
|
return scripts[scripts.length - 1];
|
||||||
})();
|
})();
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
hotkeys: script.getAttribute('data-hotkeys') === 'true',
|
hotkeys: script.getAttribute('data-hotkeys') === 'true',
|
||||||
static_path: script.getAttribute('data-static-path'),
|
static_path: script.getAttribute('data-static-path'),
|
||||||
translations: JSON.parse(script.getAttribute('data-translations')),
|
translations: JSON.parse(script.getAttribute('data-translations')),
|
||||||
theme : {
|
theme: {
|
||||||
// image that is displayed if load of <img src='...'> failed
|
// image that is displayed if load of <img src='...'> failed
|
||||||
img_load_error: 'img/img_load_error.svg'
|
img_load_error: 'img/img_load_error.svg'
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* (C) Copyright Contributors to the searx project (2014 - 2021).
|
* (C) Copyright Contributors to the searx project (2014 - 2021).
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
window.searxng = (function(w, d) {
|
window.searxng = (function (w, d) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ window.searxng = (function(w, d) {
|
||||||
|
|
||||||
// from https://plainjs.com/javascript/events/live-binding-event-handlers-14/
|
// from https://plainjs.com/javascript/events/live-binding-event-handlers-14/
|
||||||
if (w.Element) {
|
if (w.Element) {
|
||||||
(function(ElementPrototype) {
|
(function (ElementPrototype) {
|
||||||
ElementPrototype.matches = ElementPrototype.matches ||
|
ElementPrototype.matches = ElementPrototype.matches ||
|
||||||
ElementPrototype.matchesSelector ||
|
ElementPrototype.matchesSelector ||
|
||||||
ElementPrototype.webkitMatchesSelector ||
|
ElementPrototype.webkitMatchesSelector ||
|
||||||
ElementPrototype.msMatchesSelector ||
|
ElementPrototype.msMatchesSelector ||
|
||||||
function(selector) {
|
function (selector) {
|
||||||
var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;
|
var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;
|
||||||
while (nodes[++i] && nodes[i] != node);
|
while (nodes[++i] && nodes[i] != node);
|
||||||
return !!nodes[i];
|
return !!nodes[i];
|
||||||
|
@ -26,7 +26,7 @@ window.searxng = (function(w, d) {
|
||||||
})(Element.prototype);
|
})(Element.prototype);
|
||||||
}
|
}
|
||||||
|
|
||||||
function callbackSafe(callback, el, e) {
|
function callbackSafe (callback, el, e) {
|
||||||
try {
|
try {
|
||||||
callback.call(el, e);
|
callback.call(el, e);
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
|
@ -36,14 +36,14 @@ window.searxng = (function(w, d) {
|
||||||
|
|
||||||
var searxng = window.searxng || {};
|
var searxng = window.searxng || {};
|
||||||
|
|
||||||
searxng.on = function(obj, eventType, callback, useCapture) {
|
searxng.on = function (obj, eventType, callback, useCapture) {
|
||||||
useCapture = useCapture || false;
|
useCapture = useCapture || false;
|
||||||
if (typeof obj !== 'string') {
|
if (typeof obj !== 'string') {
|
||||||
// obj HTMLElement, HTMLDocument
|
// obj HTMLElement, HTMLDocument
|
||||||
obj.addEventListener(eventType, callback, useCapture);
|
obj.addEventListener(eventType, callback, useCapture);
|
||||||
} else {
|
} else {
|
||||||
// obj is a selector
|
// obj is a selector
|
||||||
d.addEventListener(eventType, function(e) {
|
d.addEventListener(eventType, function (e) {
|
||||||
var el = e.target || e.srcElement, found = false;
|
var el = e.target || e.srcElement, found = false;
|
||||||
while (el && el.matches && el !== d && !(found = el.matches(obj))) el = el.parentElement;
|
while (el && el.matches && el !== d && !(found = el.matches(obj))) el = el.parentElement;
|
||||||
if (found) callbackSafe(callback, el, e);
|
if (found) callbackSafe(callback, el, e);
|
||||||
|
@ -51,7 +51,7 @@ window.searxng = (function(w, d) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
searxng.ready = function(callback) {
|
searxng.ready = function (callback) {
|
||||||
if (document.readyState != 'loading') {
|
if (document.readyState != 'loading') {
|
||||||
callback.call(w);
|
callback.call(w);
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,20 +59,20 @@ window.searxng = (function(w, d) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
searxng.http = function(method, url) {
|
searxng.http = function (method, url) {
|
||||||
var req = new XMLHttpRequest(),
|
var req = new XMLHttpRequest(),
|
||||||
resolve = function() {},
|
resolve = function () {},
|
||||||
reject = function() {},
|
reject = function () {},
|
||||||
promise = {
|
promise = {
|
||||||
then: function(callback) { resolve = callback; return promise; },
|
then: function (callback) { resolve = callback; return promise; },
|
||||||
catch: function(callback) { reject = callback; return promise; }
|
catch: function (callback) { reject = callback; return promise; }
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
req.open(method, url, true);
|
req.open(method, url, true);
|
||||||
|
|
||||||
// On load
|
// On load
|
||||||
req.onload = function() {
|
req.onload = function () {
|
||||||
if (req.status == 200) {
|
if (req.status == 200) {
|
||||||
resolve(req.response, req.responseType);
|
resolve(req.response, req.responseType);
|
||||||
} else {
|
} else {
|
||||||
|
@ -81,11 +81,11 @@ window.searxng = (function(w, d) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle network errors
|
// Handle network errors
|
||||||
req.onerror = function() {
|
req.onerror = function () {
|
||||||
reject(Error("Network Error"));
|
reject(Error("Network Error"));
|
||||||
};
|
};
|
||||||
|
|
||||||
req.onabort = function() {
|
req.onabort = function () {
|
||||||
reject(Error("Transaction is aborted"));
|
reject(Error("Transaction is aborted"));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ window.searxng = (function(w, d) {
|
||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
searxng.loadStyle = function(src) {
|
searxng.loadStyle = function (src) {
|
||||||
var path = searxng.static_path + src,
|
var path = searxng.static_path + src,
|
||||||
id = "style_" + src.replace('.', '_'),
|
id = "style_" + src.replace('.', '_'),
|
||||||
s = d.getElementById(id);
|
s = d.getElementById(id);
|
||||||
|
@ -112,7 +112,7 @@ window.searxng = (function(w, d) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
searxng.loadScript = function(src, callback) {
|
searxng.loadScript = function (src, callback) {
|
||||||
var path = searxng.static_path + src,
|
var path = searxng.static_path + src,
|
||||||
id = "script_" + src.replace('.', '_'),
|
id = "script_" + src.replace('.', '_'),
|
||||||
s = d.getElementById(id);
|
s = d.getElementById(id);
|
||||||
|
@ -121,7 +121,7 @@ window.searxng = (function(w, d) {
|
||||||
s.setAttribute('id', id);
|
s.setAttribute('id', id);
|
||||||
s.setAttribute('src', path);
|
s.setAttribute('src', path);
|
||||||
s.onload = callback;
|
s.onload = callback;
|
||||||
s.onerror = function() {
|
s.onerror = function () {
|
||||||
s.setAttribute('error', '1');
|
s.setAttribute('error', '1');
|
||||||
};
|
};
|
||||||
d.body.appendChild(s);
|
d.body.appendChild(s);
|
||||||
|
@ -140,11 +140,11 @@ window.searxng = (function(w, d) {
|
||||||
referenceNode.parentNode.insertBefore(newNode, referenceNode);
|
referenceNode.parentNode.insertBefore(newNode, referenceNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
searxng.insertAfter = function(newNode, referenceNode) {
|
searxng.insertAfter = function (newNode, referenceNode) {
|
||||||
referenceNode.parentNode.insertAfter(newNode, referenceNode.nextSibling);
|
referenceNode.parentNode.insertAfter(newNode, referenceNode.nextSibling);
|
||||||
};
|
};
|
||||||
|
|
||||||
searxng.on('.close', 'click', function() {
|
searxng.on('.close', 'click', function () {
|
||||||
this.parentNode.classList.add('invisible');
|
this.parentNode.classList.add('invisible');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* SPDX-License-Identifier: AGPL-3.0-or-later */
|
/* SPDX-License-Identifier: AGPL-3.0-or-later */
|
||||||
/*global searxng*/
|
/* global searxng */
|
||||||
|
|
||||||
searxng.ready(function() {
|
searxng.ready(function () {
|
||||||
|
|
||||||
function isElementInDetail(el) {
|
function isElementInDetail (el) {
|
||||||
while (el !== undefined) {
|
while (el !== undefined) {
|
||||||
if (el.classList.contains('detail')) {
|
if (el.classList.contains('detail')) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,7 +18,7 @@ searxng.ready(function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getResultElement(el) {
|
function getResultElement (el) {
|
||||||
while (el !== undefined) {
|
while (el !== undefined) {
|
||||||
if (el.classList.contains('result')) {
|
if (el.classList.contains('result')) {
|
||||||
return el;
|
return el;
|
||||||
|
@ -28,11 +28,11 @@ searxng.ready(function() {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isImageResult(resultElement) {
|
function isImageResult (resultElement) {
|
||||||
return resultElement && resultElement.classList.contains('result-images');
|
return resultElement && resultElement.classList.contains('result-images');
|
||||||
}
|
}
|
||||||
|
|
||||||
searxng.on('.result', 'click', function(e) {
|
searxng.on('.result', 'click', function (e) {
|
||||||
if (!isElementInDetail(e.target)) {
|
if (!isElementInDetail(e.target)) {
|
||||||
highlightResult(this)(true);
|
highlightResult(this)(true);
|
||||||
let resultElement = getResultElement(e.target);
|
let resultElement = getResultElement(e.target);
|
||||||
|
@ -43,7 +43,7 @@ searxng.ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
searxng.on('.result a', 'focus', function(e) {
|
searxng.on('.result a', 'focus', function (e) {
|
||||||
if (!isElementInDetail(e.target)) {
|
if (!isElementInDetail(e.target)) {
|
||||||
let resultElement = getResultElement(e.target);
|
let resultElement = getResultElement(e.target);
|
||||||
if (resultElement && resultElement.getAttribute("data-vim-selected") === null) {
|
if (resultElement && resultElement.getAttribute("data-vim-selected") === null) {
|
||||||
|
@ -155,7 +155,7 @@ searxng.ready(function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (searxng.hotkeys) {
|
if (searxng.hotkeys) {
|
||||||
searxng.on(document, "keydown", function(e) {
|
searxng.on(document, "keydown", function (e) {
|
||||||
// check for modifiers so we don't break browser's hotkeys
|
// check for modifiers so we don't break browser's hotkeys
|
||||||
if (Object.prototype.hasOwnProperty.call(vimKeys, e.keyCode) && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) {
|
if (Object.prototype.hasOwnProperty.call(vimKeys, e.keyCode) && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) {
|
||||||
var tagName = e.target.tagName.toLowerCase();
|
var tagName = e.target.tagName.toLowerCase();
|
||||||
|
@ -171,8 +171,8 @@ searxng.ready(function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlightResult(which) {
|
function highlightResult (which) {
|
||||||
return function(noScroll) {
|
return function (noScroll) {
|
||||||
var current = document.querySelector('.result[data-vim-selected]'),
|
var current = document.querySelector('.result[data-vim-selected]'),
|
||||||
effectiveWhich = which;
|
effectiveWhich = which;
|
||||||
if (current === null) {
|
if (current === null) {
|
||||||
|
@ -244,11 +244,11 @@ searxng.ready(function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadPage() {
|
function reloadPage () {
|
||||||
document.location.reload(true);
|
document.location.reload(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeFocus(e) {
|
function removeFocus (e) {
|
||||||
const tagName = e.target.tagName.toLowerCase();
|
const tagName = e.target.tagName.toLowerCase();
|
||||||
if (document.activeElement && (tagName === 'input' || tagName === 'select' || tagName === 'textarea')) {
|
if (document.activeElement && (tagName === 'input' || tagName === 'select' || tagName === 'textarea')) {
|
||||||
document.activeElement.blur();
|
document.activeElement.blur();
|
||||||
|
@ -257,8 +257,8 @@ searxng.ready(function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pageButtonClick(css_selector) {
|
function pageButtonClick (css_selector) {
|
||||||
return function() {
|
return function () {
|
||||||
var button = document.querySelector(css_selector);
|
var button = document.querySelector(css_selector);
|
||||||
if (button) {
|
if (button) {
|
||||||
button.click();
|
button.click();
|
||||||
|
@ -266,15 +266,15 @@ searxng.ready(function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function GoToNextPage() {
|
function GoToNextPage () {
|
||||||
return pageButtonClick('nav#pagination .next_page button[type="submit"]');
|
return pageButtonClick('nav#pagination .next_page button[type="submit"]');
|
||||||
}
|
}
|
||||||
|
|
||||||
function GoToPreviousPage() {
|
function GoToPreviousPage () {
|
||||||
return pageButtonClick('nav#pagination .previous_page button[type="submit"]');
|
return pageButtonClick('nav#pagination .previous_page button[type="submit"]');
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollPageToSelected() {
|
function scrollPageToSelected () {
|
||||||
var sel = document.querySelector('.result[data-vim-selected]');
|
var sel = document.querySelector('.result[data-vim-selected]');
|
||||||
if (sel === null) {
|
if (sel === null) {
|
||||||
return;
|
return;
|
||||||
|
@ -301,27 +301,27 @@ searxng.ready(function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollPage(amount) {
|
function scrollPage (amount) {
|
||||||
return function() {
|
return function () {
|
||||||
window.scrollBy(0, amount);
|
window.scrollBy(0, amount);
|
||||||
highlightResult('visible')();
|
highlightResult('visible')();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollPageTo(position, nav) {
|
function scrollPageTo (position, nav) {
|
||||||
return function() {
|
return function () {
|
||||||
window.scrollTo(0, position);
|
window.scrollTo(0, position);
|
||||||
highlightResult(nav)();
|
highlightResult(nav)();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchInputFocus() {
|
function searchInputFocus () {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
document.querySelector('#q').focus();
|
document.querySelector('#q').focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function openResult(newTab) {
|
function openResult (newTab) {
|
||||||
return function() {
|
return function () {
|
||||||
var link = document.querySelector('.result[data-vim-selected] h3 a');
|
var link = document.querySelector('.result[data-vim-selected] h3 a');
|
||||||
if (link === null) {
|
if (link === null) {
|
||||||
link = document.querySelector('.result[data-vim-selected] > a');
|
link = document.querySelector('.result[data-vim-selected] > a');
|
||||||
|
@ -337,7 +337,7 @@ searxng.ready(function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function initHelpContent(divElement) {
|
function initHelpContent (divElement) {
|
||||||
var categories = {};
|
var categories = {};
|
||||||
|
|
||||||
for (var k in vimKeys) {
|
for (var k in vimKeys) {
|
||||||
|
@ -346,7 +346,7 @@ searxng.ready(function() {
|
||||||
categories[key.cat].push(key);
|
categories[key.cat].push(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
var sorted = Object.keys(categories).sort(function(a, b) {
|
var sorted = Object.keys(categories).sort(function (a, b) {
|
||||||
return categories[b].length - categories[a].length;
|
return categories[b].length - categories[a].length;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -389,13 +389,13 @@ searxng.ready(function() {
|
||||||
divElement.innerHTML = html;
|
divElement.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleHelp() {
|
function toggleHelp () {
|
||||||
var helpPanel = document.querySelector('#vim-hotkeys-help');
|
var helpPanel = document.querySelector('#vim-hotkeys-help');
|
||||||
if (helpPanel === undefined || helpPanel === null) {
|
if (helpPanel === undefined || helpPanel === null) {
|
||||||
// first call
|
// first call
|
||||||
helpPanel = document.createElement('div');
|
helpPanel = document.createElement('div');
|
||||||
helpPanel.id = 'vim-hotkeys-help';
|
helpPanel.id = 'vim-hotkeys-help';
|
||||||
helpPanel.className='dialog-modal';
|
helpPanel.className = 'dialog-modal';
|
||||||
initHelpContent(helpPanel);
|
initHelpContent(helpPanel);
|
||||||
initHelpContent(helpPanel);
|
initHelpContent(helpPanel);
|
||||||
initHelpContent(helpPanel);
|
initHelpContent(helpPanel);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
searxng.ready(function () {
|
searxng.ready(function () {
|
||||||
searxng.on('.searxng_init_map', 'click', function(event) {
|
searxng.on('.searxng_init_map', 'click', function (event) {
|
||||||
// no more request
|
// no more request
|
||||||
this.classList.remove("searxng_init_map");
|
this.classList.remove("searxng_init_map");
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@
|
||||||
var map_geojson = JSON.parse(this.dataset.mapGeojson);
|
var map_geojson = JSON.parse(this.dataset.mapGeojson);
|
||||||
|
|
||||||
searxng.loadStyle('css/leaflet.css');
|
searxng.loadStyle('css/leaflet.css');
|
||||||
searxng.loadScript('js/leaflet.js', function() {
|
searxng.loadScript('js/leaflet.js', function () {
|
||||||
var map_bounds = null;
|
var map_bounds = null;
|
||||||
if(map_boundingbox) {
|
if (map_boundingbox) {
|
||||||
var southWest = L.latLng(map_boundingbox[0], map_boundingbox[2]);
|
var southWest = L.latLng(map_boundingbox[0], map_boundingbox[2]);
|
||||||
var northEast = L.latLng(map_boundingbox[1], map_boundingbox[3]);
|
var northEast = L.latLng(map_boundingbox[1], map_boundingbox[3]);
|
||||||
map_bounds = L.latLngBounds(southWest, northEast);
|
map_bounds = L.latLngBounds(southWest, northEast);
|
||||||
|
@ -28,26 +28,26 @@
|
||||||
// init map
|
// init map
|
||||||
var map = L.map(leaflet_target);
|
var map = L.map(leaflet_target);
|
||||||
// create the tile layer with correct attribution
|
// create the tile layer with correct attribution
|
||||||
var osmMapnikUrl='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
var osmMapnikUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||||
var osmMapnikAttrib='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';
|
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 osmMapnik = new L.TileLayer(osmMapnikUrl, {minZoom: 1, maxZoom: 19, attribution: osmMapnikAttrib});
|
||||||
var osmWikimediaUrl='https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png';
|
var osmWikimediaUrl = 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png';
|
||||||
var osmWikimediaAttrib = 'Wikimedia maps | Maps data © <a href="https://openstreetmap.org">OpenStreetMap contributors</a>';
|
var osmWikimediaAttrib = 'Wikimedia maps | Maps data © <a href="https://openstreetmap.org">OpenStreetMap contributors</a>';
|
||||||
var osmWikimedia = new L.TileLayer(osmWikimediaUrl, {minZoom: 1, maxZoom: 19, attribution: osmWikimediaAttrib});
|
var osmWikimedia = new L.TileLayer(osmWikimediaUrl, {minZoom: 1, maxZoom: 19, attribution: osmWikimediaAttrib});
|
||||||
// init map view
|
// init map view
|
||||||
if(map_bounds) {
|
if (map_bounds) {
|
||||||
// TODO hack: https://github.com/Leaflet/Leaflet/issues/2021
|
// TODO hack: https://github.com/Leaflet/Leaflet/issues/2021
|
||||||
// Still useful ?
|
// Still useful ?
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
map.fitBounds(map_bounds, {
|
map.fitBounds(map_bounds, {
|
||||||
maxZoom:17
|
maxZoom: 17
|
||||||
});
|
});
|
||||||
}, 0);
|
}, 0);
|
||||||
} else if (map_lon && map_lat) {
|
} else if (map_lon && map_lat) {
|
||||||
if(map_zoom) {
|
if (map_zoom) {
|
||||||
map.setView(new L.latLng(map_lat, map_lon),map_zoom);
|
map.setView(new L.latLng(map_lat, map_lon), map_zoom);
|
||||||
} else {
|
} else {
|
||||||
map.setView(new L.latLng(map_lat, map_lon),8);
|
map.setView(new L.latLng(map_lat, map_lon), 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,11 +60,11 @@
|
||||||
|
|
||||||
L.control.layers(baseLayers).addTo(map);
|
L.control.layers(baseLayers).addTo(map);
|
||||||
|
|
||||||
if(map_geojson) {
|
if (map_geojson) {
|
||||||
L.geoJson(map_geojson).addTo(map);
|
L.geoJson(map_geojson).addTo(map);
|
||||||
} /*else if(map_bounds) {
|
} /* else if(map_bounds) {
|
||||||
L.rectangle(map_bounds, {color: "#ff7800", weight: 3, fill:false}).addTo(map);
|
L.rectangle(map_bounds, {color: "#ff7800", weight: 3, fill:false}).addTo(map);
|
||||||
}*/
|
} */
|
||||||
});
|
});
|
||||||
|
|
||||||
// this event occour only once per element
|
// this event occour only once per element
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
(function (w, d, searxng) {
|
(function (w, d, searxng) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
searxng.ready(function() {
|
searxng.ready(function () {
|
||||||
let engine_descriptions = null;
|
let engine_descriptions = null;
|
||||||
function load_engine_descriptions() {
|
function load_engine_descriptions () {
|
||||||
if (engine_descriptions == null) {
|
if (engine_descriptions == null) {
|
||||||
searxng.http("GET", "engine_descriptions.json").then(function(content) {
|
searxng.http("GET", "engine_descriptions.json").then(function (content) {
|
||||||
engine_descriptions = JSON.parse(content);
|
engine_descriptions = JSON.parse(content);
|
||||||
for (const [engine_name, description] of Object.entries(engine_descriptions)) {
|
for (const [engine_name, description] of Object.entries(engine_descriptions)) {
|
||||||
let elements = d.querySelectorAll('[data-engine-name="' + engine_name + '"] .engine-description');
|
let elements = d.querySelectorAll('[data-engine-name="' + engine_name + '"] .engine-description');
|
||||||
for(const element of elements) {
|
for (const element of elements) {
|
||||||
let source = ' (<i>' + searxng.translations['Source'] + ': ' + description[1] + '</i>)';
|
let source = ' (<i>' + searxng.translations['Source'] + ': ' + description[1] + '</i>)';
|
||||||
element.innerHTML = description[0] + source;
|
element.innerHTML = description[0] + source;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d.querySelector('body[class="preferences_endpoint"]')) {
|
if (d.querySelector('body[class="preferences_endpoint"]')) {
|
||||||
for(const el of d.querySelectorAll('[data-engine-name]')) {
|
for (const el of d.querySelectorAll('[data-engine-name]')) {
|
||||||
searxng.on(el, 'mouseenter', load_engine_descriptions);
|
searxng.on(el, 'mouseenter', load_engine_descriptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/* SPDX-License-Identifier: AGPL-3.0-or-later */
|
/* SPDX-License-Identifier: AGPL-3.0-or-later */
|
||||||
(function(w, d, searxng) {
|
(function (w, d, searxng) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
searxng.ready(function() {
|
searxng.ready(function () {
|
||||||
searxng.image_thumbnail_layout = new searxng.ImageLayout('#urls', '#urls .result-images', 'img.image_thumbnail', 14, 6, 200);
|
searxng.image_thumbnail_layout = new searxng.ImageLayout('#urls', '#urls .result-images', 'img.image_thumbnail', 14, 6, 200);
|
||||||
searxng.image_thumbnail_layout.watch();
|
searxng.image_thumbnail_layout.watch();
|
||||||
|
|
||||||
searxng.on('.btn-collapse', 'click', function() {
|
searxng.on('.btn-collapse', 'click', function () {
|
||||||
var btnLabelCollapsed = this.getAttribute('data-btn-text-collapsed');
|
var btnLabelCollapsed = this.getAttribute('data-btn-text-collapsed');
|
||||||
var btnLabelNotCollapsed = this.getAttribute('data-btn-text-not-collapsed');
|
var btnLabelNotCollapsed = this.getAttribute('data-btn-text-not-collapsed');
|
||||||
var target = this.getAttribute('data-target');
|
var target = this.getAttribute('data-target');
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
targetElement.classList.toggle('invisible');
|
targetElement.classList.toggle('invisible');
|
||||||
});
|
});
|
||||||
|
|
||||||
searxng.on('.media-loader', 'click', function() {
|
searxng.on('.media-loader', 'click', function () {
|
||||||
var target = this.getAttribute('data-target');
|
var target = this.getAttribute('data-target');
|
||||||
var iframe_load = d.querySelector(target + ' > iframe');
|
var iframe_load = d.querySelector(target + ' > iframe');
|
||||||
var srctest = iframe_load.getAttribute('src');
|
var srctest = iframe_load.getAttribute('src');
|
||||||
|
@ -31,8 +31,8 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
searxng.selectImage = function(resultElement) {
|
searxng.selectImage = function (resultElement) {
|
||||||
/*eslint no-unused-vars: 0*/
|
/* eslint no-unused-vars: 0 */
|
||||||
if (resultElement) {
|
if (resultElement) {
|
||||||
// load full size image in background
|
// load full size image in background
|
||||||
const imgElement = resultElement.querySelector('.result-images-source img');
|
const imgElement = resultElement.querySelector('.result-images-source img');
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
searxng.scrollPageToSelected();
|
searxng.scrollPageToSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
searxng.closeDetail = function(e) {
|
searxng.closeDetail = function (e) {
|
||||||
d.getElementById('results').classList.remove('image-detail-open');
|
d.getElementById('results').classList.remove('image-detail-open');
|
||||||
searxng.image_thumbnail_layout.align();
|
searxng.image_thumbnail_layout.align();
|
||||||
searxng.scrollPageToSelected();
|
searxng.scrollPageToSelected();
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
searxng.on('.result-detail-previous', 'click', e => searxng.selectPrevious(false));
|
searxng.on('.result-detail-previous', 'click', e => searxng.selectPrevious(false));
|
||||||
searxng.on('.result-detail-next', 'click', e => searxng.selectNext(false));
|
searxng.on('.result-detail-next', 'click', e => searxng.selectNext(false));
|
||||||
|
|
||||||
w.addEventListener('scroll', function() {
|
w.addEventListener('scroll', function () {
|
||||||
var e = d.getElementById('backToTop'),
|
var e = d.getElementById('backToTop'),
|
||||||
scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
|
scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
|
||||||
results = d.getElementById('results');
|
results = d.getElementById('results');
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
/* SPDX-License-Identifier: AGPL-3.0-or-later */
|
/* SPDX-License-Identifier: AGPL-3.0-or-later */
|
||||||
/* global AutoComplete */
|
/* global AutoComplete */
|
||||||
(function(w, d, searxng) {
|
(function (w, d, searxng) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var firstFocus = true, qinput_id = "q", qinput;
|
var firstFocus = true, qinput_id = "q", qinput;
|
||||||
|
|
||||||
function placeCursorAtEnd(element) {
|
function placeCursorAtEnd (element) {
|
||||||
if (element.setSelectionRange) {
|
if (element.setSelectionRange) {
|
||||||
var len = element.value.length;
|
var len = element.value.length;
|
||||||
element.setSelectionRange(len, len);
|
element.setSelectionRange(len, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitIfQuery() {
|
function submitIfQuery () {
|
||||||
if (qinput.value.length > 0) {
|
if (qinput.value.length > 0) {
|
||||||
var search = document.getElementById('search');
|
var search = document.getElementById('search');
|
||||||
setTimeout(search.submit.bind(search), 0);
|
setTimeout(search.submit.bind(search), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createClearButton(qinput) {
|
function createClearButton (qinput) {
|
||||||
var cs = document.getElementById('clear_search');
|
var cs = document.getElementById('clear_search');
|
||||||
var updateClearButton = function() {
|
var updateClearButton = function () {
|
||||||
if (qinput.value.length === 0) {
|
if (qinput.value.length === 0) {
|
||||||
cs.classList.add("empty");
|
cs.classList.add("empty");
|
||||||
} else {
|
} else {
|
||||||
|
@ -31,18 +31,18 @@
|
||||||
|
|
||||||
// update status, event listener
|
// update status, event listener
|
||||||
updateClearButton();
|
updateClearButton();
|
||||||
cs.addEventListener('click', function() {
|
cs.addEventListener('click', function () {
|
||||||
qinput.value='';
|
qinput.value = '';
|
||||||
qinput.focus();
|
qinput.focus();
|
||||||
updateClearButton();
|
updateClearButton();
|
||||||
});
|
});
|
||||||
qinput.addEventListener('keyup', updateClearButton, false);
|
qinput.addEventListener('keyup', updateClearButton, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
searxng.ready(function() {
|
searxng.ready(function () {
|
||||||
qinput = d.getElementById(qinput_id);
|
qinput = d.getElementById(qinput_id);
|
||||||
|
|
||||||
function placeCursorAtEndOnce() {
|
function placeCursorAtEndOnce () {
|
||||||
if (firstFocus) {
|
if (firstFocus) {
|
||||||
placeCursorAtEnd(qinput);
|
placeCursorAtEnd(qinput);
|
||||||
firstFocus = false;
|
firstFocus = false;
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
},
|
},
|
||||||
MinChars: 4,
|
MinChars: 4,
|
||||||
Delay: 300,
|
Delay: 300,
|
||||||
_Position:function() {
|
_Position: function () {
|
||||||
this.DOMResults.setAttribute("class", "autocomplete");
|
this.DOMResults.setAttribute("class", "autocomplete");
|
||||||
this.DOMResults.style.top = (this.Input.offsetTop + this.Input.offsetHeight) + "px";
|
this.DOMResults.style.top = (this.Input.offsetTop + this.Input.offsetHeight) + "px";
|
||||||
this.DOMResults.style.left = this.Input.offsetLeft + "px";
|
this.DOMResults.style.left = this.Input.offsetLeft + "px";
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
}, "#" + qinput_id);
|
}, "#" + qinput_id);
|
||||||
|
|
||||||
// hack, see : https://github.com/autocompletejs/autocomplete.js/issues/37
|
// hack, see : https://github.com/autocompletejs/autocomplete.js/issues/37
|
||||||
w.addEventListener('resize', function() {
|
w.addEventListener('resize', function () {
|
||||||
var event = new CustomEvent("position");
|
var event = new CustomEvent("position");
|
||||||
qinput.dispatchEvent(event);
|
qinput.dispatchEvent(event);
|
||||||
});
|
});
|
||||||
|
@ -88,11 +88,11 @@
|
||||||
|
|
||||||
// vanilla js version of search_on_category_select.js
|
// vanilla js version of search_on_category_select.js
|
||||||
if (qinput !== null && d.querySelector('.help') != null && searxng.search_on_category_select) {
|
if (qinput !== null && d.querySelector('.help') != null && searxng.search_on_category_select) {
|
||||||
d.querySelector('.help').className='invisible';
|
d.querySelector('.help').className = 'invisible';
|
||||||
|
|
||||||
searxng.on('#categories input', 'change', function() {
|
searxng.on('#categories input', 'change', function () {
|
||||||
var i, categories = d.querySelectorAll('#categories input[type="checkbox"]');
|
var i, categories = d.querySelectorAll('#categories input[type="checkbox"]');
|
||||||
for(i=0; i<categories.length; i++) {
|
for (i = 0; i < categories.length; i++) {
|
||||||
if (categories[i] !== this && categories[i].checked) {
|
if (categories[i] !== this && categories[i].checked) {
|
||||||
categories[i].click();
|
categories[i].click();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue