PageSourceSearch

https://www.abn.ne/media/com_finder/js/finder.js?755761

js abn.ne collected 2026-10-01 11:52:26 UTC 2,874 bytes, 88 lines download raw bytes

1/**
2 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
3 * @license    GNU General Public License version 2 or later; see LICENSE.txt
4 */
5((Awesomplete, Joomla, window, document) => {
6
7  if (!Joomla) {
8    throw new Error('core.js was not properly initialised');
9  }
10
11  // Handle the autocomplete
12  const onInputChange = ({
13    target
14  }) => {
15    if (target.value.length > 1) {
16      target.awesomplete.list = [];
17      Joomla.request({
18        url: `${Joomla.getOptions('finder-search').url}&q=${target.value}`,
19        promise: true
20      }).then(xhr => {
21        let response;
22        try {
23          response = JSON.parse(xhr.responseText);
24        } catch (e) {
25          // Something went wrong, but we are not going to bother the enduser with this
26          console.error(e);
27          return;
28        }
29        if (Object.prototype.toString.call(response.suggestions) === '[object Array]') {
30          target.awesomplete.list = response.suggestions;
31        }
32      }).catch(xhr => {
33        // Something went wrong, but we are not going to bother the enduser with this
34        console.error(xhr);
35      });
36    }
37  };
38
39  // Handle the submit
40  const onSubmit = event => {
41    event.stopPropagation();
42    const advanced = event.target.querySelector('.js-finder-advanced');
43
44    // Disable select boxes with no value selected.
45    if (advanced) {
46      const fields = [].slice.call(advanced.querySelectorAll('select'));
47      fields.forEach(field => {
48        if (!field.value) {
49          field.setAttribute('disabled', 'disabled');
50        }
51      });
52    }
53  };
54
55  // Submits the form programmatically
56  const submitForm = event => {
57    const form = event.target.closest('form');
58    if (form) {
59      form.submit();
60    }
61  };
62
63  // The boot sequence
64  const onBoot = () => {
65    document.querySelectorAll('.js-finder-search-query').forEach(searchword => {
66      // Handle the auto suggestion
67      if (Joomla.getOptions('finder-search')) {
68        searchword.awesomplete = new Awesomplete(searchword, {
69          listLabel: Joomla.Text._('COM_FINDER_SEARCH_FORM_LIST_LABEL')
70        });
71
72        // If the current value is empty, set the previous value.
73        searchword.addEventListener('input', onInputChange);
74        const advanced = searchword.closest('form').querySelector('.js-finder-advanced');
75
76        // Do not submit the form on suggestion selection, in case of advanced form.
77        if (!advanced) {
78          searchword.addEventListener('awesomplete-selectcomplete', submitForm);
79        }
80      }
81    });
82    document.querySelectorAll('.js-finder-searchform').forEach(form => form.addEventListener('submit', onSubmit));
83
84    // Cleanup
85    document.removeEventListener('DOMContentLoaded', onBoot);
86  };
87  document.addEventListener('DOMContentLoaded', onBoot);
88})(window.Awesomplete, window.Joomla, window, document);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.