PageSourceSearch

https://www.palmknihy.cz/-a888---TbnrymXm/autocomplete.js?_linka=a66669

js palmknihy.cz collected 2026-09-24 09:40:47 UTC 8,883 bytes, 19 lines download raw bytes

1import {isMobile} from "/-a824---HU0081tt/mobile-detect.js?_linka=d20198";import translate from "/-d1127---RDTYinol/dictionary.js?_linka=a68655";import debounce from "/-a889---Ybt3RN4x/debounce.js?_linka=d17805";export default class Autocomplete{constructor(){this.selectors={FORM:"#search",SEARCH_INPUT:'#search \x3e input[type\x3d"search"]',AUTOCOMPLETE_CONTAINER:"#autocomplete-content",DROPDOWN_TOGGLE:"#autocomplete-toggle",MAIN_MENU_INPUT:"#dropdown-main",MAIN_MENU_ELEM:"nav.main-menu",AUTOCOMPLETE_CLOSE:".autocomplete__close",
2SELLING_CARD:".selling-card.autocomplete-card"};this.formData={};this.options={DROPDOWN_SHOWN:false,ENDPOINT_URL:$("#search").data("ajax-url"),MIN_CHARS:2,DELAY:200};this.init()}init(){this.bindSearch();this.bindOnClickHide();this.bind()}bind(){let autocompleteCls=this;$(document).on("click",function(e){var $trigger=$(autocompleteCls.selectors.AUTOCOMPLETE_CONTAINER);var $inp=$(autocompleteCls.selectors.SEARCH_INPUT);if($trigger!==e.target&&!$inp.is(":focus")&&!$trigger.has(e.target).length)autocompleteCls.hideAutocomplete()});
3$(autocompleteCls.selectors.SEARCH_INPUT).on("focus",function(e){if($(e.currentTarget).val().length>=autocompleteCls.options.MIN_CHARS)autocompleteCls.showAutocomplete()})}bindSearch(){const that=this;$(this.selectors.SEARCH_INPUT).on("input",debounce(function(){let v=$(this).val();let l=v&&v.length||0;if(l<that.options.MIN_CHARS)that.hideAutocomplete();else that.requestData()},this.options.DELAY))}bindOnClickHide(){let that=this;$(document).click(function(e){if($(e.target).is($(that.selectors.DROPDOWN_TOGGLE)))that.showDropdown();
4else if($(e.target).closest("#search")<=0&&!$(e.target).closest($(".hystmodal").hasClass("hystmodal--active"))){that.hideAutocomplete();that.hideDropdown()}});$(document).on("click",function(e){if(e.target===$(that.selectors.AUTOCOMPLETE_CLOSE)[0]){e.preventDefault();$(that.selectors.SEARCH_INPUT).val("");that.hideAutocomplete();$(that.selectors.SEARCH_INPUT).blur()}});$(document).keyup(function(e){if(e.keyCode!==27)return;that.hideAutocomplete();$(that.selectors.SEARCH_INPUT).blur()});$(document).on("click",
5that.selectors.SELLING_CARD,function(){location.href=$(this).data("link")})}requestData(){var self=this;TDI.Ajax.Request.send(this.options.ENDPOINT_URL,{method:"GET",contentType:false,processData:false,cache:false,trigger:$(self.selectors.FORM),data:$.param({query:$(self.selectors.SEARCH_INPUT).val()},true),start:function(){var $ddEl=$(self.selectors.AUTOCOMPLETE_CONTAINER);$ddEl.addClass("autocomplete autocomplete__content autocomplete--open autocomplete--loading");$ddEl.html(`
6	        	<div class="autocomplete__content-wrapper">
7	        		<div class="autocomplete__body" align="center">
8	        			<div class="autocomplete__main">
9		        			<h4 class="autocomplete__section-title" data-cy="search-title"><strong>${translate("AUTOCOMPLETE_TITLE")}</strong></h4>
10		        			<svg id="eJOTmheMHcP1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 80 80" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" width="80" height="80"><style><![CDATA[#eJOTmheMHcP7_tr {animation: eJOTmheMHcP7_tr__tr 2000ms cubic-bezier(0,.50,.8,.8) infinite normal forwards}@keyframes eJOTmheMHcP7_tr__tr { 0% {transform: translate(40px,48.332451px) rotate(0deg)} 35% {transform: translate(40px,48.332451px) rotate(0deg)} 95% {transform: translate(40px,48.332451px) rotate(-180deg)} 100% {transform: translate(40px,48.332451px) rotate(-180deg)}} #eJOTmheMHcP8_tr {animation: eJOTmheMHcP8_tr__tr 2000ms cubic-bezier(0,.50,.8,.8) infinite normal forwards}@keyframes eJOTmheMHcP8_tr__tr { 0% {transform: translate(40px,48.332451px) rotate(0deg)} 25% {transform: translate(40px,48.332451px) rotate(0deg)} 80% {transform: translate(40px,48.332451px) rotate(-180deg)} 100% {transform: translate(40px,48.332451px) rotate(-180deg)}} #eJOTmheMHcP9_tr {animation: eJOTmheMHcP9_tr__tr 2000ms cubic-bezier(0,.50,.8,.8) infinite normal forwards}@keyframes eJOTmheMHcP9_tr__tr { 0% {transform: translate(40px,48.332451px) rotate(0deg)} 15% {transform: translate(40px,48.332451px) rotate(0deg)} 65% {transform: translate(40px,48.332451px) rotate(-180deg)} 100% {transform: translate(40px,48.332451px) rotate(-180deg)}} #eJOTmheMHcP10_tr {animation: eJOTmheMHcP10_tr__tr 2000ms cubic-bezier(0,.50,.8,.8) infinite normal forwards}@keyframes eJOTmheMHcP10_tr__tr { 0% {transform: translate(40px,48.332451px) rotate(0deg)} 5% {transform: translate(40px,48.332451px) rotate(0deg)} 50% {transform: translate(40px,48.332451px) rotate(-180deg)} 100% {transform: translate(40px,48.332451px) rotate(-180deg)}}]]></style><g transform="translate(6.5 19.08245)"><line x1="1.25" y1="32.75" x2="27.75" y2="32.75" fill="none" stroke="#1894bb" stroke-width="2.5" stroke-linecap="round"/><line x1="39.25" y1="32.75" x2="65.75" y2="32.75" fill="none" stroke="#1894bb" stroke-width="2.5" stroke-linecap="round"/>
10<path d="M27.9013,32c-.2552.4413-.4013.9536-.4013,1.5c0,1.6569,1.3431,3,3,3h6c1.6569,0,3-1.3431,3-3c0-.5464-.1461-1.0587-.4013-1.5h2.6943c.1348.4768.207.98.207,1.5c0,3.0376-2.4624,5.5-5.5,5.5h-6c-3.0376,0-5.5-2.4624-5.5-5.5c0-.52.0722-1.0232.207-1.5h2.6943Z" fill="#1894bb"/></g><line x1="68.25" y1="29.25" x2="41.25" y2="29.25" transform="matrix(-1 0 0 1 78.25 19.082452)" fill="none" stroke="#1894bb" stroke-width="2.5" stroke-linecap="round"/><g id="eJOTmheMHcP7_tr" transform="translate(40,48.332451) rotate(0)"><line x1="68.25" y1="29.25" x2="41.25" y2="29.25" transform="scale(1,-1) translate(-38.25,-29.249999)" fill="none" stroke="#1894bb" stroke-width="2.5" stroke-linecap="round"/></g><g id="eJOTmheMHcP8_tr" transform="translate(40,48.332451) rotate(0)"><line x1="68.25" y1="29.25" x2="41.25" y2="29.25" transform="scale(1,-1) translate(-38.25,-29.249999)" fill="none" stroke="#1894bb" stroke-width="2.5" stroke-linecap="round"/></g><g id="eJOTmheMHcP9_tr" transform="translate(40,48.332451) rotate(0)"><line x1="68.25" y1="29.25" x2="41.25" y2="29.25" transform="scale(1,-1) translate(-38.25,-29.249999)" fill="none" stroke="#1894bb" stroke-width="2.5" stroke-linecap="round"/></g><g id="eJOTmheMHcP10_tr" transform="translate(40,48.332451) rotate(0)"><line x1="68.25" y1="29.25" x2="41.25" y2="29.25" transform="scale(1,-1) translate(-38.25,-29.249999)" fill="none" stroke="#1894bb" stroke-width="2.5" stroke-linecap="round"/></g><line x1="68.25" y1="29.25" x2="41.25" y2="29.25" transform="matrix(1 0 0-1 1.75 77.58245)" fill="none" stroke="#1894bb" stroke-width="2.5" stroke-linecap="round"/></svg>
11		        			<p>${translate("AUTOCOMPLETE_SEARCHING")}</p>
12	        			</div>
13					</div>
14				</div>
15        	`);self.showAutocomplete()},end:(xhr,status)=>self.requestFinished(xhr,status)})}requestFinished(xhr,status){const isEmpty=$(this.selectors.AUTOCOMPLETE_CONTAINER).hasClass("autocomplete__content--empty");function toBasicLatin(str){return str.normalize("NFD").replace(/[\u0300-\u036F]/g,"")}var highlightText=function(name){function escapeRegExp(string){return string.replace(/[.*+?^${}()|[\]\\]/g,"\\$\x26")}$(name).each(function(){const searchText=$(".autocomplete-form input[name\x3d'query']").val();
16const escapedSearch=escapeRegExp(searchText);const escapedNFD=escapeRegExp(toBasicLatin(searchText));let pattern=escapedSearch;if(escapedSearch!==escapedNFD)pattern=`${escapedSearch}|${escapedNFD}`;const regex=new RegExp(`(${pattern})`,"gi");let text=$(this).html();const newText=text.replace(regex,"\x3cspan\x3e$1\x3c/span\x3e");$(this).html(newText)})};highlightText(".selling-card.autocomplete-card a[data-cy\x3d'title']");highlightText(".selling-card.autocomplete-card a[data-cy\x3d'author']");highlightText(".search-segments__main-list-item a[data-cy\x3d'search-author']");
17highlightText(".search-segments__main-list-item a[data-cy\x3d'search-category']");highlightText(".search-segments__main-list-item a[data-cy\x3d'search-brand']");highlightText(".search-segments__main-list-item a[data-cy\x3d'search-series']");this.showAutocomplete()}showDropdown(){$(this.selectors.MAIN_MENU_INPUT).prop("checked",false);$(this.selectors.MAIN_MENU_ELEM).addClass("hidden");$(this.selectors.DROPDOWN_TOGGLE).addClass("hidden");$(this.selectors.SEARCH_INPUT).focus()}hideDropdown(){$(this.selectors.DROPDOWN_TOGGLE).removeClass("hidden");
18$(this.selectors.SEARCH_INPUT).blur()}showAutocomplete(){if($(this.selectors.AUTOCOMPLETE_CONTAINER).children().length>0){$(this.selectors.AUTOCOMPLETE_CONTAINER).addClass("autocomplete--open");$("body").addClass("autocomplete__results");if(isMobile(true))$("body").css("overflow","hidden")}}hideAutocomplete(){if($(this.selectors.AUTOCOMPLETE_CONTAINER).hasClass("autocomplete--open")){$(this.selectors.AUTOCOMPLETE_CONTAINER).removeClass("autocomplete--open");$("body").removeClass("autocomplete__results");
19if(isMobile(true))$("body").css("overflow","")}}};

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.