PageSourceSearch

https://www.opensourcefeed.org/assets/script/main.js

js opensourcefeed.org collected 2026-10-02 17:48:41 UTC 3,411 bytes, 92 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function () {
2
3    const searchField = document.getElementById('search-field');
4
5    if (searchField) {
6        // Focus the input when the search icon is clicked
7        document.getElementById('search-btn').addEventListener('click', function () {
8            searchField.focus();
9        });
10
11        // Filter the results on keyup
12        document.getElementById('search-field').addEventListener('keyup', function () {
13            const query = this.value;
14            const entryParent = document.getElementById('result-list');
15            const entries = entryParent.querySelectorAll('li:not(#no-result)');
16            let hasResult = false;
17            const noResult = document.getElementById('no-result');
18
19            if (query !== undefined && query !== '') {
20                entries.forEach(function (entry) {
21                    if (entry.textContent.toLowerCase().indexOf(query.toLowerCase()) === -1) {
22                        entry.style.display = 'none';
23                    } else {
24                        hasResult = true;
25                        entry.style.display = '';
26                    }
27                });
28
29                if (hasResult) {
30                    noResult.style.display = 'none';
31                } else {
32                    noResult.style.display = '';
33                }
34            }
35
36            if (hasResult) {
37                entryParent.style.width = (this.offsetWidth - 1) + 'px';
38                entryParent.style.marginLeft = document.getElementById('search-btn').offsetWidth + 'px';
39                entryParent.style.display = 'block';
40            } else {
41                entryParent.style.display = 'none';
42            }
43        });
44
45        const closeSearch = function () {
46            const searchField = document.getElementById('search-field');
47            searchField.value = '';
48            searchField.dispatchEvent(new Event('keyup'));
49        };
50
51        // Close the search result when clicking outside
52        document.body.addEventListener('click', function (e) {
53            if (!document.getElementById('search-area').contains(e.target)) {
54                closeSearch();
55            }
56        });
57
58        document.addEventListener('keyup', function (e) {
59            if (e.key === 'Escape') {
60                closeSearch();
61            }
62        });
63    }
64
65    // Control size of navbar on scrolling
66    window.addEventListener('scroll', function () {
67        const navbar = document.querySelector('.navbar');
68        const main = document.querySelector('main');
69        const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
70
71        if (scrollTop > 50) {
72            navbar.classList.add('navbar-small');
73            main.style.marginTop = '100px';
74        } else {
75            navbar.classList.remove('navbar-small');
76            main.removeAttribute('style');
77        }
78
79        if (window.innerWidth > 768) {
80            const elem = document.querySelector('aside ins.adsbygoogle');
81            if (elem) {
82                if (scrollTop > 0) {
83                    elem.style.position = 'fixed';
84                    elem.style.top = '20px';
85                } else {
86                    elem.style.position = 'relative';
87                }
88            }
89        }
90    });
91
92});

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.