Skip to content

Commit

Permalink
[fix] eslint --fix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
return42 committed Nov 23, 2021
1 parent ac46821 commit 78d8051
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 82 deletions.
48 changes: 24 additions & 24 deletions searx/static/themes/simple/src/js/head/00_init.js
Expand Up @@ -6,31 +6,31 @@
*/
/* global DocumentTouch:readonly */
(function(w, d) {
'use strict';
'use strict';

// add data- properties
var script = d.currentScript || (function() {
var scripts = d.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
// add data- properties
var script = d.currentScript || (function() {
var scripts = d.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();

// try to detect touch screen
w.searxng = {
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',
hotkeys: script.getAttribute('data-hotkeys') === 'true',
static_path: script.getAttribute('data-static-path'),
translations: JSON.parse(script.getAttribute('data-translations')),
};
// try to detect touch screen
w.searxng = {
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',
hotkeys: script.getAttribute('data-hotkeys') === 'true',
static_path: script.getAttribute('data-static-path'),
translations: JSON.parse(script.getAttribute('data-translations')),
};

// update the css
var hmtlElement = d.getElementsByTagName("html")[0];
hmtlElement.classList.remove('no-js');
hmtlElement.classList.add('js');
if (w.searxng.touch) {
hmtlElement.classList.add('touch');
}
// update the css
var hmtlElement = d.getElementsByTagName("html")[0];
hmtlElement.classList.remove('no-js');
hmtlElement.classList.add('js');
if (w.searxng.touch) {
hmtlElement.classList.add('touch');
}
})(window, document);
24 changes: 12 additions & 12 deletions searx/static/themes/simple/src/js/main/00_toolkit.js
Expand Up @@ -61,12 +61,12 @@ window.searxng = (function(w, d) {

searxng.http = function(method, url) {
var req = new XMLHttpRequest(),
resolve = function() {},
reject = function() {},
promise = {
then: function(callback) { resolve = callback; return promise; },
catch: function(callback) { reject = callback; return promise; }
};
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);
Expand Down Expand Up @@ -100,8 +100,8 @@ window.searxng = (function(w, d) {

searxng.loadStyle = function(src) {
var path = searxng.static_path + src,
id = "style_" + src.replace('.', '_'),
s = d.getElementById(id);
id = "style_" + src.replace('.', '_'),
s = d.getElementById(id);
if (s === null) {
s = d.createElement('link');
s.setAttribute('id', id);
Expand All @@ -114,8 +114,8 @@ window.searxng = (function(w, d) {

searxng.loadScript = function(src, callback) {
var path = searxng.static_path + src,
id = "script_" + src.replace('.', '_'),
s = d.getElementById(id);
id = "script_" + src.replace('.', '_'),
s = d.getElementById(id);
if (s === null) {
s = d.createElement('script');
s.setAttribute('id', id);
Expand All @@ -142,11 +142,11 @@ window.searxng = (function(w, d) {

searxng.insertAfter = function(newNode, referenceNode) {
referenceNode.parentNode.insertAfter(newNode, referenceNode.nextSibling);
};
};

searxng.on('.close', 'click', function() {
this.parentNode.classList.add('invisible');
});

return searxng;
})(window, document);
34 changes: 17 additions & 17 deletions searx/static/themes/simple/src/js/main/keyboard.js
Expand Up @@ -174,7 +174,7 @@ searxng.ready(function() {
function highlightResult(which) {
return function(noScroll) {
var current = document.querySelector('.result[data-vim-selected]'),
effectiveWhich = which;
effectiveWhich = which;
if (current === null) {
// no selection : choose the first one
current = document.querySelector('.result');
Expand All @@ -194,7 +194,7 @@ searxng.ready(function() {
next = effectiveWhich;
} else {
switch (effectiveWhich) {
case 'visible':
case 'visible':
var top = document.documentElement.scrollTop || document.body.scrollTop;
var bot = top + document.documentElement.clientHeight;

Expand All @@ -208,24 +208,24 @@ searxng.ready(function() {
}
}
break;
case 'down':
case 'down':
next = current.nextElementSibling;
if (next === null) {
next = results[0];
}
break;
case 'up':
case 'up':
next = current.previousElementSibling;
if (next === null) {
next = results[results.length - 1];
}
break;
case 'bottom':
case 'bottom':
next = results[results.length - 1];
break;
case 'top':
case 'top':
/* falls through */
default:
default:
next = results[0];
}
}
Expand Down Expand Up @@ -280,10 +280,10 @@ searxng.ready(function() {
return;
}
var wtop = document.documentElement.scrollTop || document.body.scrollTop,
wheight = document.documentElement.clientHeight,
etop = sel.offsetTop,
ebot = etop + sel.clientHeight,
offset = 120;
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
Expand Down Expand Up @@ -386,23 +386,23 @@ searxng.ready(function() {

html += '</table>';

divElement.innerHTML = html;
divElement.innerHTML = html;
}

function toggleHelp() {
var helpPanel = document.querySelector('#vim-hotkeys-help');
if (helpPanel === undefined || helpPanel === null) {
// first call
// first call
helpPanel = document.createElement('div');
helpPanel.id = 'vim-hotkeys-help';
helpPanel.className='dialog-modal';
helpPanel.id = 'vim-hotkeys-help';
helpPanel.className='dialog-modal';
initHelpContent(helpPanel);
initHelpContent(helpPanel);
initHelpContent(helpPanel);
initHelpContent(helpPanel);
var body = document.getElementsByTagName('body')[0];
body.appendChild(helpPanel);
} else {
// togggle hidden
// togggle hidden
helpPanel.classList.toggle('invisible');
return;
}
Expand Down
44 changes: 22 additions & 22 deletions searx/static/themes/simple/src/js/main/preferences.js
@@ -1,28 +1,28 @@
/* SPDX-License-Identifier: AGPL-3.0-or-later */
(function (w, d, searxng) {
'use strict';
'use strict';

searxng.ready(function() {
let engine_descriptions = null;
function load_engine_descriptions() {
if (engine_descriptions == null) {
searxng.http("GET", "engine_descriptions.json").then(function(content) {
engine_descriptions = JSON.parse(content);
for (const [engine_name, description] of Object.entries(engine_descriptions)) {
let elements = d.querySelectorAll('[data-engine-name="' + engine_name + '"] .engine-description');
for(const element of elements) {
let source = ' (<i>' + searxng.translations['Source'] + ':&nbsp;' + description[1] + '</i>)';
element.innerHTML = description[0] + source;
}
}
});
searxng.ready(function() {
let engine_descriptions = null;
function load_engine_descriptions() {
if (engine_descriptions == null) {
searxng.http("GET", "engine_descriptions.json").then(function(content) {
engine_descriptions = JSON.parse(content);
for (const [engine_name, description] of Object.entries(engine_descriptions)) {
let elements = d.querySelectorAll('[data-engine-name="' + engine_name + '"] .engine-description');
for(const element of elements) {
let source = ' (<i>' + searxng.translations['Source'] + ':&nbsp;' + description[1] + '</i>)';
element.innerHTML = description[0] + source;
}
}
}
});
}
}

if (d.querySelector('body[class="preferences_endpoint"]')) {
for(const el of d.querySelectorAll('[data-engine-name]')) {
searxng.on(el, 'mouseenter', load_engine_descriptions);
}
}
});
if (d.querySelector('body[class="preferences_endpoint"]')) {
for(const el of d.querySelectorAll('[data-engine-name]')) {
searxng.on(el, 'mouseenter', load_engine_descriptions);
}
}
});
})(window, document, window.searxng);
6 changes: 3 additions & 3 deletions searx/static/themes/simple/src/js/main/results.js
Expand Up @@ -70,7 +70,7 @@
searxng.image_thumbnail_layout.align();
searxng.scrollPageToSelected();
}
searxng.on('.result-detail-close', 'click', e => {
searxng.on('.result-detail-close', 'click', e => {
e.preventDefault();
searxng.closeDetail();
});
Expand All @@ -79,8 +79,8 @@

w.addEventListener('scroll', function() {
var e = d.getElementById('backToTop'),
scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
results = d.getElementById('results');
scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
results = d.getElementById('results');
if (e !== null) {
if (scrollTop >= 100) {
results.classList.add('scrolling');
Expand Down
6 changes: 3 additions & 3 deletions searx/static/themes/simple/src/js/main/search.js
Expand Up @@ -23,9 +23,9 @@
var cs = document.getElementById('clear_search');
var updateClearButton = function() {
if (qinput.value.length === 0) {
cs.classList.add("empty");
cs.classList.add("empty");
} else {
cs.classList.remove("empty");
cs.classList.remove("empty");
}
};

Expand Down Expand Up @@ -54,7 +54,7 @@
if (qinput !== null) {
// clear button
createClearButton(qinput);

// autocompleter
if (searxng.autocompleter) {
searxng.autocomplete = AutoComplete.call(w, {
Expand Down
2 changes: 1 addition & 1 deletion searx/static/themes/simple/svg4web.svgo.js
Expand Up @@ -15,5 +15,5 @@ module.exports = {
// Optimize SVG for WEB usage
'convertStyleToAttrs',
'removeXMLNS'
],
],
};

0 comments on commit 78d8051

Please sign in to comment.