searxng/searx/static/themes/simple/js/searxng.head.js

40 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
2021-10-01 16:07:27 +00:00
* @license
* (C) Copyright Contributors to the SearXNG project.
* (C) Copyright Contributors to the searx project (2014 - 2021).
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
2021-08-31 13:33:38 +00:00
/* global DocumentTouch:readonly */
(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
2021-10-01 16:07:27 +00:00
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',
2021-11-05 11:45:15 +00:00
hotkeys: script.getAttribute('data-hotkeys') === 'true',
static_path: script.getAttribute('data-static-path'),
translations: JSON.parse(script.getAttribute('data-translations')),
2021-11-30 11:43:18 +00:00
theme : {
// image that is displayed if load of <img src='...'> failed
img_load_error: 'img/img_load_error.svg'
}
2021-06-16 12:23:44 +00:00
};
// update the css
2021-11-19 15:56:07 +00:00
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);