1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-14 16:50:11 +01:00
searxng/searx/static/themes/simple/js/searxng.head.js

36 lines
1.4 KiB
JavaScript
Raw Normal View History

/**
2021-10-01 18:07:27 +02: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 15:33:38 +02: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 18:07:27 +02: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 12:45:15 +01:00
hotkeys: script.getAttribute('data-hotkeys') === 'true',
static_path: script.getAttribute('data-static-path'),
translations: JSON.parse(script.getAttribute('data-translations')),
2021-06-16 14:23:44 +02:00
};
// update the css
2021-11-19 16:56:07 +01: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);