HEX
Server: nginx/1.28.0
System: Linux yisu-68a5f20334161 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: www (1000)
PHP: 8.2.28
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/q.autos58.cn/wp-content/themes/morenews/assets/search-script.js
jQuery(document).ready(function($) {

    if (!afLiveSearch.enabled) return;

    let timer;
    const resultsBox = $('#af-live-search-results');
    const searchInput = $('input[type="search"]');

    let items = [];
    let index = -1;

    function resetNavigation() {
        items = resultsBox.find('[role="option"]');
        index = -1;
        items.attr('aria-selected', 'false');
    }

    searchInput.on('keyup', function (e) {

        // Keyboard navigation
        if (e.key === 'ArrowDown' && items.length) {
            index = (index + 1) % items.length;
            items.attr('aria-selected', 'false')
                .eq(index).attr('aria-selected', 'true').focus();
            return;
        }

        if (e.key === 'ArrowUp' && items.length) {
            index = (index - 1 + items.length) % items.length;
            items.attr('aria-selected', 'false')
                .eq(index).attr('aria-selected', 'true').focus();
            return;
        }

        if (e.key === 'Enter' && index >= 0) {
            window.location = items.eq(index).find('a').attr('href');
            return;
        }

        // Regular typing
        const query = $(this).val().trim();
        clearTimeout(timer);

        timer = setTimeout(function() {

            if (query.length < 2) {
                resultsBox.html('').attr('aria-expanded', 'false');
                return;
            }

            $.ajax({
                url: afLiveSearch.ajax_url,
                type: 'POST',
                data: {
                    action: 'morenews_live_search',
                    s: query,
                    nonce: afLiveSearch.nonce,
                    limit: afLiveSearch.results_count
                },
                beforeSend: function () {
                    resultsBox
                        .html('<div class="loading" role="status">' + afLiveSearch.searching_text + '</div>')
                        .attr('aria-expanded', 'true');
                },
                success: function (response) {
                    resultsBox.html(response).attr('aria-expanded', 'true');
                    resetNavigation();
                }
            });

        }, 300);
    });

    // Close when clicking outside
    $(document).on('click', function(e){
        if (!$(e.target).closest('.af-search-wrap').length) {
            resultsBox.html('').attr('aria-expanded', 'false');
        }
    });
});