1function URLEncode(url) { 2 url = encodeURIComponent(url); 3 var find = [ 4 "%C4%84", 5 "%C4%85", 6 "%C4%86", 7 "%C4%87", 8 "%C4%98", 9 "%C4%99", 10 "%C5%81", 11 "%C5%82", 12 "%C5%83", 13 "%C5%84", 14 "%C3%93", 15 "%C3%B3", 16 "%C5%9A", 17 "%C5%9B", 18 "%C5%BB", 19 "%C5%BC", 20 "%C5%B9", 21 "%C5%BA" 22 ]; 23 var repl = [ 24 "%A1", 25 "%B1", 26 "%C6", 27 "%E6", 28 "%CA", 29 "%EA", 30 "%A3", 31 "%B3", 32 "%D1", 33 "%F1", 34 "%D3", 35 "%F3", 36 "%A6", 37 "%B6", 38 "%AF", 39 "%BF", 40 "%AC", 41 "%BC" 42 ]; 43 for (var i = 0; i < find.length; i++) { 44 var regex = new RegExp(find[i], "g"); 45 url = url.replace(regex, repl[i]); 46 } 47 return url.replace(new RegExp("%", "g"), "%25"); 48} 49 50function goToBook(link){ 51 let title = link.querySelector("h3").innerText; 52 let full_phrase = "podpowiedzi: "; 53 let phrase = document.querySelector(".page-tools .search-line input").value; 54 let href = link.getAttribute('href'); 55 56 if(title != '' && phrase != ''){ 57 full_phrase += phrase; 58 ga("send", "event", "podpowiedzi", full_phrase, title); 59 ga("send", "pageview", "/search?szukaj=" + URLEncode(full_phrase)); 60 } 61 window.location.href = href; 62} 63 64$(document).ready(function() { 65 /** KOPIA modulu do sugestii wyszukiwarki, zmiana url, multi wylaczone*/ 66 jQuery(".page-tools .search-line input").unbind(); 67 68 if ($(window).width() > 1199) { 69 $(".suggest-list").css("max-height", $(window).height() - 60 + "px"); 70 $(".suggest-list").css("overflow-y", "auto"); 71 } 72 var protocol = document.location.protocol; 73 var audiobooki = 0; 74 var serwis = document.location.hostname.split(".")[0]; 75 if (serwis == "audiobooki") { 76 audiobooki = 1; 77 serwis = "ebookpoint"; 78 } 79 if(serwis == 'local' || serwis == 'dev'){ 80 serwis = document.location.hostname.split(".")[1]; 81 } 82 jQuery(".page-tools .search-line input").focus(function() { 83 suggestInputFocus(jQuery(".page-tools .suggest-list")); 84 }); 85 jQuery(".small-suggest input").focus(function() { 86 suggestInputFocus(jQuery(this).siblings(".suggest-list")); 87 }); 88 jQuery(".page-tools .search-line input").blur(function() { 89 suggestInputBlur(jQuery(".page-tools .suggest-list")); 90 }); 91 jQuery(".small-suggest input").blur(function() { 92 suggestInputBlur(jQuery(this).siblings(".suggest-list")); 93 }); 94 jQuery(".page-tools .suggest-list") 95 .mouseenter(function() { 96 $(this).addClass("hover"); 97 }) 98 .mouseleave(function() { 99 $(this).removeClass("hover"); 100 }); 101 jQuery(".small-suggest .suggest-list") 102 .mouseenter(function() { 103 $(this).addClass("hover"); 104 }) 105 .mouseleave(function() { 106 $(this).removeClass("hover"); 107 }); 108 jQuery(".page-tools .search-line input").keydown(function(e) { 109 suggestInputKeyDown( 110 e, 111 jQuery(".page-tools .suggest-list .item-list"), 112 jQuery(this).val() 113 ); 114 }); 115 jQuery(".small-suggest input").keydown(function(e) { 116 suggestInputKeyDown( 117 e, 118 jQuery(this) 119 .siblings(".suggest-list") 120 .find(".item-list"), 121 jQuery(this).val() 122 ); 123 }); 124 jQuery(".page-tools .search-line input").keyup(function(e) { 125 suggestInputKeyUp( 126 e, 127 jQuery(this).val(), 128 jQuery(".page-tools .suggest-list"), 129 serwis 130 ); 131 }); 132 jQuery(".small-suggest input").keyup(function(e) { 133 var collection = ""; 134 var inputId = jQuery(this).attr("id"); 135 if (inputId == "inputSearch1") { 136 collection = "wydawcy"; 137 } else if (inputId == "inputSearch2") { 138 collection = "autorzy"; 139 } 140 suggestInputKeyUp( 141 e, 142 jQuery(this).val(), 143 jQuery(this).siblings(".suggest-list"), 144 collection 145 ); 146 }); 147 jQuery(".authors-search-input").keyup(function(e) { 148 suggestInputKeyUp( 149 e, 150 jQuery(this).val(), 151 jQuery(this).siblings(".suggest-list"), 152 'autorzy' 153 ); 154 }); 155 jQuery(".publisher-search-input").keyup(function(e) { 156 suggestInputKeyUp( 157 e, 158 jQuery(this).val(), 159 jQuery(this).siblings(".suggest-list"), 160 'wydawcy' 161 ); 162 }); 163 jQuery(".series-search-input").keyup(function(e) { 164 suggestInputKeyUp( 165 e, 166 jQuery(this).val(), 167 jQuery(this).siblings(".suggest-list"), 168 'serie' 169 ); 170 }); 171 function suggestInputFocus(suggestList) {
172 if (suggestList.find(".item-list").children().length > 0) { 173 suggestList.show(); 174 } 175 } 176 function suggestInputBlur(suggestList) { 177 if (!suggestList.hasClass("hover")) { 178 suggestList.hide(); 179 } 180 } 181 function suggestInputKeyDown(e, list, fraza) { 182 if (e.keyCode == 38) { 183 e.preventDefault(); 184 } else if (e.keyCode == 40) { 185 e.preventDefault(); 186 } else if (e.keyCode == 13) { 187 var actIdx = getActivePosition(list); 188 if (actIdx > -1) { 189 e.preventDefault(); 190 var thisA = list 191 .children() 192 .eq(actIdx) 193 .find("a"); 194 goToSuggestion(thisA, fraza); 195 } 196 } 197 } 198 function suggestInputKeyUp(e, phrase, suggestList, collection) { 199 var list = suggestList.find(".item-list"); 200 if (phrase.length > 2) { 201 if (e.keyCode == 38) { 202 e.preventDefault(); 203 var activeIndex = getActivePosition(list); 204 if (activeIndex == -1) { 205 setActivePosition(list, activeIndex); 206 } else { 207 setActivePosition(list, activeIndex - 1); 208 } 209 } else if (e.keyCode == 40) { 210 e.preventDefault(); 211 var activeIndex = getActivePosition(list); 212 setActivePosition(list, activeIndex + 1); 213 } else { 214 var multi = collection == serwis; 215 getSuggestionsWithAjax( 216 suggestList, 217 list, 218 phrase, 219 collection, 220 multi, 221 0, 222 "" 223 ); 224 } 225 } else { 226 suggestList.hide(); 227 list.empty(); 228 } 229 } 230 function getSuggestionsWithAjax( 231 suggestList, 232 list, 233 phrase, 234 collection, 235 multi, 236 last, 237 resultsString 238 ) { 239 phrase = cleanPhrase(phrase); 240 241 jQuery.ajax({ 242 url: "/api/solr/suggest/all/" + encodeURIComponent(phrase), 243 success: function(data) { 244 list.empty(); 245 var li = resultsString; 246 // nh2020 247 last = true; 248 var search_collections = [collection, "audio", "video", 'autorzy', 'wydawcy', 'lektorzy', 'serie', 'destynacje']; 249 if(collection != serwis){ 250 search_collections = [collection]; 251 } 252 var globalUids = []; 253 254 search_collections.forEach(collection => { 255 json = data[collection]; 256 if (json.numFound > 0) { 257 suggestList.show(); 258 var sharedEbooks = ""; 259 var fingerprints = ";"; 260 var iterator = 0; 261 var max_ebook = 4; 262 var max_audio = 2; 263 var max_video = 2; 264 var current_url = window.location.href; 265 if(current_url.includes('/kategorie/audiobooki')){ 266 max_ebook = 2; 267 max_audio = 4; 268 max_video = 2; 269 }else if(current_url.includes('/kategorie/kursy')){ 270 max_ebook = 2; 271 max_audio = 2; 272 max_video = 4; 273 } 274 275 jQuery(json.docs).each(function(index, elem) { 276 iterator++; 277 278 if(iterator > max_ebook) { return false; }; 279 if(collection == 'audio' && iterator > max_audio) { return false ;}; 280 if(collection == 'video' && iterator > max_video) { return false; }; 281 if(globalUids.includes(elem.uid)) { return false; }; 282 var firstOrLast = ""; 283 if (index == 0) { 284 firstOrLast += " first"; 285 } 286 if (index + 1 == json.docs.length) { 287 firstOrLast += " last"; 288 } 289 var dubel = false; 290 if (elem.shared_ebook) { 291 if (sharedEbooks.indexOf(elem.shared_ebook) !== -1) { 292 dubel = true; 293 } else { 294 sharedEbooks += elem.shared_ebook + ";"; 295 } 296 } 297 if (collection == "autorzy" || collection == 'lektorzy') { 298 if (fingerprints.indexOf(";" + elem.fingerprint + ";") !== -1) { 299 dubel = true; 300 } else { 301 fingerprints += elem.fingerprint + ";"; 302 } 303 } 304 305 if (!dubel) { 306 var linkFormat = "#format/d"; 307 var cover_height = 65; 308 var cover_ident = elem.uid; 309 if(elem.formaty){ 310 $idDruk = elem.formaty.indexOf('d'); 311 if(elem.status[$idDruk] == 3 && elem.formaty.includes('pem') || elem.status[$idDruk] == 0 && elem.formaty.includes('pem')){ 312 $idEbook = elem.formaty.indexOf('pem'); 313 if(elem.status[$idEbook] != 3 && elem.status[$idEbook] != 0){ 314 linkFormat = "#format/e"; 315 } 316 } 317 } 318 if(linkFormat == "#format/d" && elem.paper_cover){ 319 cover_ident = elem.uid + "_d"; 320 } 321 if(collection == 'audio'){ 322 linkFormat = "#format/3"; 323 cover_ident = elem.uid + "_3"; 324 cover_height = 50; 325 }else if(collection == 'video'){ 326 linkFormat = "#format/w"; 327 } 328 329 if (collection == serwis || collection == 'audio' || collection == 'video') { 330 li += 331 '<li class="suggest-ksiazka' + 332 firstOrLast + 333 '"><a href="/ksiazki/' + 334 ((elem.seolink.length>0)? elem.seolink +",":'') + 335 elem.uid + 336 ".htm" + 337 linkFormat + 338 '" onclick="goToBook(this); return false;"><h3><strong>' + 339 elem.title + 340 "</strong></h3>"; 341 if ($(window).width() > 678) { 342 li += 343 '<p class="cover"><img src="https://static01.helion.com.pl/global/okladki/65x85/' + 344 cover_ident + 345 '.jpg" onerror="this.src=\'https://static01.helion.com.pl/global/okladki/65x85/' + 346 serwis +
347 '-brak.jpg\';" style="width:50px;height:' + 348 cover_height + 349 'px;" alt="' + 350 elem.title + 351 '"/></p>'; 352 } 353 li += '<p class="name">' + elem.author + "</p>"; 354 if(index==0 && collection == serwis){ 355 li+='<span class="label label-info">Druk/Ebooki</span>'; 356 } 357 if(index==0 && collection == 'audio'){ 358 li+='<span class="label label-info">Audiobooki</span>'; 359 } 360 if(index==0 && collection == 'video'){ 361 li+='<span class="label label-info">Kursy video</span>'; 362 } 363 li += "</a></li>"; 364 globalUids.push(elem.uid); 365 } else { 366 var type = ""; 367 var style = ""; 368 if (collection == "wydawcy") { 369 type = "wydawca"; 370 style = "wydawca"; 371 } else if (collection == "autorzy") { 372 type = "autorzy"; 373 style = "autor"; 374 } else if (collection == "serie") { 375 type = "serie"; 376 style = "wydawca"; 377 } else if(collection == 'lektorzy'){ 378 type = 'lektor'; 379 style = 'autor'; 380 } else if (collection == "destynacje") { 381 type = "destynacje"; 382 style = "destynacja"; 383 } 384 li += 385 '<li class="suggest-' + 386 style + 387 firstOrLast + 388 '"><a href="/' + 389 type + 390 "/" + 391 ((elem.seolink.length>0)? elem.seolink :'') + 392 (audiobooki || collection == 'lektorzy' ? "?format=3" : "") + 393 '" onclick="goToBook(this); return false;"><h3><strong>' + 394 elem.name + 395 "</strong></h3>"; 396 if (index == 0 && multi) { 397 li += '<span class="label">' + collection + "</span>"; 398 } 399 li += "</a></li>"; 400 } 401 } 402 }); 403 } 404 }); 405 406 if (!multi || last) { 407 if (li.length > 0) { 408 list.append(li); 409 if (multi || collection == serwis) { 410 list.append( 411 '<li class="wszystkie"><p class="button"><a href="/search?szukaj=' + 412 decodeURI(phrase) + 413 (audiobooki ? "&format=3" : "") + 414 '">Zobacz wszystkie</a></p></li>' 415 ); 416 } 417 } else { 418 suggestList.hide(); 419 } 420 } else { 421 var nextCollection = ""; 422 if (collection == serwis){ 423 nextCollection = "autorzy"; 424 } else if (collection == "autorzy") { 425 nextCollection = "lektorzy"; 426 } else if(collection == 'lektorzy'){ 427 nextCollection = 'wydawcy'; 428 } else if (collection == "wydawcy") { 429 nextCollection = "serie"; 430 } else if (collection == "serie") { 431 nextCollection = "destynacje"; 432 } 433 if ( 434 (serwis != "bezdroza" && nextCollection == "serie") || 435 nextCollection == "destynacje" 436 ) { 437 last = 1; 438 } 439 getSuggestionsWithAjax( 440 suggestList, 441 list, 442 phrase, 443 nextCollection, 444 multi, 445 last, 446 li 447 ); 448 } 449 } 450 }); 451 } 452 function getActivePosition(list) { 453 var actIdx = -1; 454 list.children().each(function(idx) { 455 if (jQuery(this).hasClass("active")) { 456 actIdx = idx; 457 } 458 }); 459 return actIdx; 460 } 461 function setActivePosition(list, idx) { 462 var suggestions = list.children(); 463 suggestions.removeClass("active"); 464 idx = idx % suggestions.length; 465 suggestions.eq(idx).addClass("active"); 466 } 467 function goToSuggestion(thisA, fraza) { 468 let full_fraza = "podpowiedzi: "; 469 full_fraza += fraza; 470 ga("send", "event", "podpowiedzi", full_fraza, thisA.find("strong").text()); 471 ga("send", "pageview", "/search?szukaj=" + URLEncode(full_fraza)); 472 window.location.href = thisA.attr("href"); 473 } 474 function cleanPhrase(str) { 475 return String(str) 476 .replace(/&/g, "") 477 .replace(/</g, "") 478 .replace(/>/g, "") 479 .replace(/\"/g, "") 480 .replace(/\'/g, "") 481 .replace(/\//g, ""); 482 } 483});
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.