PageSourceSearch

https://voka.io/wp-content/litespeed/js/22b1438c8e4368944e66e1a1c1cb94d3.js?ver=b94d3

js voka.io collected 2026-09-24 18:04:18 UTC 7,478 bytes, 36 lines download raw bytes

1document.addEventListener("DOMContentLoaded",function(){const searchInput=document.getElementById("s");const clearButton=document.getElementById("clear-search");clearButton.addEventListener("click",function(event){event.preventDefault();searchInput.value="";searchInput.focus()})});function extractTextInHighlightedStrong(str){const regex=/<strong class="highlight">.*?<\/strong>/;const match=str.match(regex);if(match&&match.length>0){const innerTextRegex=/<strong class="highlight">(.*?)<\/strong>/;const innerMatch=match[0].match(innerTextRegex);if(innerMatch&&innerMatch.length>1){return innerMatch[1]}}
2return null}
3function replacePunctuationWithUnicode(str){if(!str)return'';let replacedStr=str;replacedStr=replacedStr.replaceAll(/[.]/g,"\\u002E");replacedStr=replacedStr.replaceAll(/[?]/g,"\\u003F");replacedStr=replacedStr.replaceAll(/!/g,"\\u0021");replacedStr=replacedStr.replaceAll(/;/g,"\\u003B");return replacedStr}
4function replaceUnicodeWithPunctuation(str){if(!str)return'';let replacedStr=str;replacedStr=replacedStr.replaceAll(/\\u002E/g,".");replacedStr=replacedStr.replaceAll(/\\u003F/g,"?");replacedStr=replacedStr.replaceAll(/\\u0021/g,"!");replacedStr=replacedStr.replaceAll(/\\u003B/g,";");return replacedStr}
5function truncateStringWithHighlight(value,query){const text=value.replaceAll("&#038;","&").replaceAll("&#8211;","-");const maxLength=window.innerWidth>1279?180:140;if(text.length<maxLength)return text;const queryWithoutPunctuation=replacePunctuationWithUnicode(query);const queryLower=queryWithoutPunctuation.toLowerCase().replaceAll("'","&#039;");function truncateAtPunctuation(str){const match=str.match(/[.?!;]\s.*/);if(match){const index=match.index;return str.substring(0,index+1)}
6return str}
7let fullStr='';let fullStrWithoutTags='';function recursive(str){if(!str)return;const part=truncateAtPunctuation(str);const partWithoutTags=part.replace(/<[^>]*>/g,'');if(!text.toLowerCase().includes(queryLower)){if((fullStr+part).length<=maxLength||!fullStr){fullStr+=part;recursive(str.replace(part,''))}
8return}
9if(part.toLowerCase().includes(`<strong class="highlight">${queryLower}</strong>`)){fullStr+=part;fullStrWithoutTags+=partWithoutTags;if(fullStrWithoutTags.length<maxLength-50){recursive(str.replace(part,''));return}
10if(fullStrWithoutTags.length>=maxLength){return}
11recursive(str.replace(part,''));return}
12if(fullStr){if(fullStrWithoutTags.length<=maxLength-50){fullStr+=part;fullStrWithoutTags+=partWithoutTags;recursive(str.replace(part,''));return}else if((fullStrWithoutTags+partWithoutTags).length>=maxLength+50){return}else if((fullStrWithoutTags+partWithoutTags).length<maxLength+50&&(fullStrWithoutTags+partWithoutTags).length>=maxLength){fullStr+=part;fullStrWithoutTags+=partWithoutTags;return}else{fullStr+=part;fullStrWithoutTags+=partWithoutTags;recursive(str.replace(part,''));return}}
13recursive(str.replace(part,''));return}
14const highlightedText=extractTextInHighlightedStrong(text);const textWithoutPunctuation=replacePunctuationWithUnicode(highlightedText)
15const contentText=text.replaceAll(highlightedText,textWithoutPunctuation)
16recursive(contentText);const result=replaceUnicodeWithPunctuation(fullStr);return result}
17function debounce(func,delay){let timeoutId;return function(...args){const context=this;clearTimeout(timeoutId);timeoutId=setTimeout(()=>{func.apply(context,args)},delay)}}
18document.addEventListener("DOMContentLoaded",function(){const quickLinks=document.getElementById('quick-links');const searchInput=document.getElementById("s");const resultsContainer=document.getElementById("search-results");const loaderContainer=document.getElementById("search-results-form-loader");const ajaxUrl=()=>window.location.origin==='http://localhost:85'?'http://localhost:85/wp-admin/admin-ajax.php':`${window.location.origin}/wp-admin/admin-ajax.php`;searchInput.addEventListener("input",debounce(function(){if(quickLinks){quickLinks.classList.add('hidden')}
19resultsContainer.classList.remove('hidden');const query=searchInput.value.trim();if(query.length<3){resultsContainer.innerHTML="<p>Enter at least 3 characters.</p>";return}
20if(loaderContainer){loaderContainer.style.display='block';resultsContainer.innerHTML=""}
21fetch(ajaxUrl(),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"main_ajax_search",query:query,}),}).then((response)=>response.json()).then((data)=>
21{if(data.success){resultsContainer.innerHTML='<span class="small-text results-title">Results:</span>';let len=data.data.length;let results=len>2?data.data.slice(0,2):data.data;resultsContainer.insertAdjacentHTML('beforeend',results.map((item)=>`<div class="search-item">
22                                    <div class="search-item-header">
23                                          ${item.type ? '<span class="page-type">'+item.type+ '</span>' : ''} 
24                                        <a href="${item.link}">
25                                            <h4 data-no-translation>${item.title}</h4>
26                                        </a>
27                                    </div>
28                                    <p class="small-text" data-no-translation>${truncateStringWithHighlight(item.content, query)}</p>
29                                </div>`).join(""));len>2&&resultsContainer.insertAdjacentHTML('beforeend',`<button id="all-search" data-query="${query}" class="small-button-text all-search">Show all</button>`);if(loaderContainer){loaderContainer.style.display='none'}}else{if(loaderContainer){loaderContainer.style.display='none'}
30resultsContainer.innerHTML=`<p>${data.data.message}</p>`}}).catch(()=>{resultsContainer.innerHTML="<p>Произошла ошибка. Попробуйте позже.</p>"})},500));const searchIcon=document.getElementById('search-icon');const searchPopup=document.getElementById('search-popup');const header=document.querySelector('header');const container=document.querySelector('#search-popup .container');const mobileSearchClose=document.getElementById('close-mobile-search');if(searchIcon){searchIcon.addEventListener('click',function(){searchPopup.classList.remove('hidden');document.documentElement.style.overflow='hidden'})}
31function checkMousePosition(event){if(searchPopup.classList.contains('hidden'))return;const isOutside=!header.contains(event.target)&&!container.contains(event.target);if(isOutside){searchPopup.classList.add('hidden');document.documentElement.style.overflow='auto';searchInput.value='';if(loaderContainer){loaderContainer.style.display='none'}
32if(quickLinks){quickLinks.classList.remove('hidden')}
33resultsContainer.classList.add('hidden');resultsContainer.innerHTML=''}}
34mobileSearchClose.addEventListener('click',()=>{searchPopup.classList.add('hidden');document.documentElement.style.overflow='auto'})
35document.addEventListener('mousemove',checkMousePosition)});document.addEventListener('click',function(event){if(event.target&&event.target.id==='all-search'){const query=event.target.getAttribute('data-query');if(query){if(allLangs?.languages){const currentLang=Object.entries(allLangs.languages).find(([key,val])=>window.location.href===val.current_page_url);if(currentLang?.length){const lang=currentLang[1].short_language_name;if(lang==='en'){window.location.href=window.location.origin+'/?s='+encodeURIComponent(query)}else{window.location.href=window.location.origin+'/'+lang+'/?s='+encodeURIComponent(query)}}}else{window.location.href='/?s='+encodeURIComponent(query)}}}})
36;

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.