<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">;(function($){

    let modInit = 0;
    
    let showHistory = function(searchtext){
        let history = localStorage.getItem('yr_search_hist'),
            items = [],
            html = '';

        if(localStorage.getItem('yr_search_hist') !== null){
            items = JSON.parse(history);
        }

        if(searchtext != '' &amp;&amp; !items.includes(searchtext)){
            items.unshift(searchtext);
            items = items.slice(0, 4);

            localStorage.setItem('yr_search_hist', JSON.stringify(items));
        }

        for(let item of items){
            html += '&lt;div&gt;&lt;a href="#" class="px-3 py-0"&gt;' + item + '&lt;/a&gt;&lt;/div&gt;';
        } 
        $('.msr-history-items').html(html);

        //console.log(localStorage.getItem('yr_search_hist'));
    }

    let showMoreBtn = function(){
        $('.msr-moreUrl').html('&lt;button type="submit" class="col-auto mt-3 mx-auto btn btn-primary" form="mod-search-form"&gt;РЎРјРѕС‚СЂРµС‚СЊ РІСЃРµ СЂРµР·СѓР»СЊС‚Р°С‚С‹&lt;/button&gt;');
    }

    $(document).on('click', '.msr-history-items a', function(e){
        e.stopPropagation();
        e.preventDefault();

        let searchtext = $(this).text();

        $('[name=searchtext]').val(searchtext);
        getSearch(searchtext);
    });

    $(document).on('click', '.msr-history-clear', function(e){
        localStorage.removeItem('yr_search_hist');
        $('.msr-history-items').html('');
    });
    
    // show mod
    $('[name=searchtext]').on('focus', function(){
        let searchtext = $('[name=searchtext]').val();

        $('#modsearchresult').show('fast');
        $('.msr-btn-back').show('fast');
        $('[name=searchtext]').removeClass('rounded-left');

        if(!modInit){
            getSearch(searchtext);
            modInit = 1;
        }
    });

    // hide mod
    let hideModSrch = function(){
        $('[name=searchtext]').addClass('rounded-left');
        $('#modsearchresult').hide('fast');
        $('.msr-btn-back').hide('fast');
    }

    $(document).on('mousedown', function(e){
        if($(e.target).closest('header.mod-srch').length){
            return;
        }
        hideModSrch();

    }).on('click', '.msr-btn-back', function(e){
        hideModSrch();
        $('[name=searchtext]').val('');
    });
    
    let getSearch = function(searchtext = ""){
        console.log('LOG: TypeWatch callback: (' + (this.type || this.nodeName) + ') ' + searchtext);

        $.ajax({
            type: "POST",
            url: "/search/modSearch",
            dataType: "json",
			data: {"searchtext": searchtext}
        }).done(function (json) {
            $('#modsearchresult').html(json.html);
            showHistory(searchtext);
            if(json.moreUrl != '' &amp;&amp; searchtext != ''){
                showMoreBtn();
            }
        });
    }

    // callback: The callback function
    // wait: The number of milliseconds to wait after the the last key press before firing the callback
    // highlight: Highlights the element when it receives focus
    // allowSubmit: Allows a non-multiline element to be submitted (enter key) regardless of captureLength
    // captureLength: Minimum # of characters necessary to fire the callback
    let options = {
        callback: getSearch,
        wait: 700,
        highlight: true,
        allowSubmit: false,
        captureLength: 2
    }

    $('[name=searchtext]').typeWatch( options );


}(jQuery));</pre></body></html>