PageSourceSearch

https://slmet.gov.sl/static/js/bulmahead.38a7439a61f2.js

js slmet.gov.sl collected 2026-10-04 00:29:59 UTC 2,326 bytes, 76 lines download raw bytes

1const debounce = (callback, wait) => {
2    let timeoutId = null;
3    return (...args) => {
4        window.clearTimeout(timeoutId);
5        timeoutId = window.setTimeout(() => {
6            callback.apply(null, args);
7        }, wait);
8    };
9}
10
11const bulmaHead = (id, idMenu, api, onSelect, delay, minLen = 2) => {
12    const input = document.getElementById(id)
13    const menuEl = document.getElementById(idMenu)
14    menuEl.innerHTML = '<div class="dropdown-content"></div>'
15
16    const setValue = e => {
17        e.preventDefault()
18        const label = e.target.text
19        const value = e.target.dataset.value
20        input.value = label
21        menuEl.style.display = 'none'
22        if (onSelect) {
23            onSelect({label, value})
24        }
25        return false
26    }
27
28    const handleApi = e => {
29        const value = e.target.value
30        menuEl.style.display = 'none'
31        menuEl.innerHTML = '<div class="dropdown-content"></div>'
32        if (value.length <= minLen) {
33            return
34        }
35
36        api(value).then(suggestions => {
37            const suggestionsEl = suggestions.map(({label, value}) => {
38                const a = document.createElement('a')
39                a.href = '#'
40                a.classList.add('dropdown-item')
41                a.innerHTML = label
42                a.dataset.value = value
43                a.addEventListener('click', setValue)
44                return a
45            })
46
47            suggestionsEl.map(suggEl => {
48                menuEl.childNodes[0].appendChild(suggEl)
49            })
50
51            if (suggestions.length > 0) {
52                menuEl.style.display = 'block'
53            }
54
55            if (suggestions.length === 0) {
56                const div = document.createElement('div')
57                div.classList.add('dropdown-item')
58                div.innerHTML = 'No result'
59                menuEl.childNodes[0].appendChild(div)
60
61                menuEl.style.display = 'block'
62            }
63        })
64    }
65    input.addEventListener('input', debounce(handleApi, delay))
66
67    input.addEventListener('focusout', e => {
68        if (e.relatedTarget === null || !e.relatedTarget.classList.contains('dropdown-item')) {
69            menuEl.style.display = 'none'
70        }
71    })
72
73    input.addEventListener('focusin', handleApi)
74}
75
76window.bulmaHead = bulmaHead

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.