[mod] client_settings: pass settings from server to JS client

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2022-04-13 17:08:19 +02:00
parent 9177172ea2
commit ed2a4c8087
8 changed files with 45 additions and 41 deletions

View file

@ -101,7 +101,7 @@ window.searxng = (function (w, d) {
};
searxng.loadStyle = function (src) {
var path = searxng.static_path + src,
var path = searxng.settings.theme_static_path + src,
id = "style_" + src.replace('.', '_'),
s = d.getElementById(id);
if (s === null) {
@ -115,7 +115,7 @@ window.searxng = (function (w, d) {
};
searxng.loadScript = function (src, callback) {
var path = searxng.static_path + src,
var path = searxng.settings.theme_static_path + src,
id = "script_" + src.replace('.', '_'),
s = d.getElementById(id);
if (s === null) {

View file

@ -62,7 +62,7 @@ searxng.ready(function () {
function (err) {
console.log(err);
var e = d.createElement('div');
e.textContent = searxng.translations.error_loading_next_page;
e.textContent = searxng.settings.translations.error_loading_next_page;
e.classList.add('dialog-error');
e.setAttribute('role', 'alert');
replaceChildrenWith(d.querySelector('#pagination'), [ e ]);
@ -70,7 +70,7 @@ searxng.ready(function () {
)
}
if (searxng.infinite_scroll && searxng.infinite_scroll_supported) {
if (searxng.settings.infinite_scroll && searxng.infinite_scroll_supported) {
const intersectionObserveOptions = {
rootMargin: "20rem",
};

View file

@ -154,7 +154,7 @@ searxng.ready(function () {
}
};
if (searxng.hotkeys) {
if (searxng.settings.hotkeys) {
searxng.on(document, "keydown", function (e) {
// 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) {

View file

@ -15,7 +15,7 @@
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>)';
let source = ' (<i>' + searxng.settings.translations.Source + ':&nbsp;' + description[1] + '</i>)';
element.innerHTML = description[0] + source;
}
}

View file

@ -59,11 +59,11 @@
createClearButton(qinput);
// autocompleter
if (searxng.autocompleter) {
if (searxng.settings.autocomplete_provider) {
searxng.autocomplete = AutoComplete.call(w, {
Url: "./autocompleter",
EmptyMessage: searxng.translations.no_item_found,
HttpMethod: searxng.method,
EmptyMessage: searxng.settings.translations.no_item_found,
HttpMethod: searxng.settings.http_method,
HttpHeaders: {
"Content-type": "application/x-www-form-urlencoded",
"X-Requested-With": "XMLHttpRequest"
@ -92,7 +92,7 @@
}
// 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.settings.search_on_category_select) {
d.querySelector('.help').className = 'invisible';
searxng.on('#categories input', 'change', function () {