summaryrefslogtreecommitdiff
path: root/searx/static/themes/simple/src/js/head/00_init.js
blob: acd437f398844ab9cfc75cef020d08bb2672f026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
 * @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
 */
(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
  w.searxng = {
    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')),
    theme: {
      // image that is displayed if load of <img src='...'> failed
      img_load_error: 'img/img_load_error.svg'
    }
  };

  // update the css
  var hmtlElement = d.getElementsByTagName("html")[0];
  hmtlElement.classList.remove('no-js');
  hmtlElement.classList.add('js');
})(window, document);