1$(document).ready(function () { 2 Search.init(); 3}); 4 5var CardEqualizerSearch = function (cardsSmall) { 6 var maxHeight = 0; 7 var maxHeightPContain; 8 var priceContainer; 9 cardsSmall.each(function () { 10 if ($(this).outerHeight() > maxHeight) { 11 maxHeight = $(this).outerHeight(); 12 } 13 }); 14 15 cardsSmall.each(function () { 16 $(this).height(maxHeight + "px"); 17 priceContainer = $(this).find('.card-price-container'); 18 if (priceContainer) { 19 priceContainer.css('bottom', '40px'); 20 priceContainer.css('top', 'auto'); 21 priceContainer.css('position', 'absolute'); 22 } 23 }); 24} 25 26var Search = { 27 Tags: [], 28 SearchCache: '', 29 TextSearch: false, 30 31 init: function () { 32 Search.TextSearch = $('#text-search-main').size() > 0; 33 34 jQuery.ajax({ 35 cache: false, 36 type: "POST", 37 url: '/ajax/tour-tags.aspx', 38 success: function (tagsInfo) { 39 for (var i = 0; i < tagsInfo.length; i++) { 40 Search.Tags.push(tagsInfo[i]); 41 } 42 Search.filterInterests(); 43 if (!Search.TextSearch) { 44 $('#filterDurations a.collapsed').trigger('click'); //open interest initially 45 } 46 Search.showTownListing(); 47 } 48 }); 49 50 var updateTravelStyles = function () { 51 var $destination = $('.search-results-filters input[name="destination"]:checked'); 52 var $travelStyles = $('.search-results-filters input[name="travelStyles"]'); 53 54 $travelStyles.removeClass('included'); 55 $destination.each(function () { 56 var ts = $(this).attr('data-travel-style'); 57 $travelStyles.not('.included').each(function () { 58 if ((',' + ts + ',').indexOf(',' + $(this).val() + ',') > -1) { 59 $(this).addClass('included'); 60 } 61 }); 62 }); 63 64 $('.search-results-filters input[name="travelStyles"].included').prop('disabled', false); 65 $travelStyles.not('.included').prop('disabled', true).prop('checked', false); 66 } 67 68 var updateTags = function () { 69 var $destination = $('.search-results-filters input[name="destination"]:checked'); 70 var $tags = $('input[name="tags"]'); 71 72 $tags.removeClass('included'); 73 $destination.each(function () { 74 var destination = $(this).val(); 75 $tags.not('.included').each(function () { 76 if ((',' + $(this).attr('data-destination-ids') + ',').indexOf(',' + destination + ',') > -1) { 77 $(this).addClass('included'); 78 } 79 }); 80 }); 81 82 $('.search-results-filters input[name="tags"].included').prop('disabled', false); 83 $tags.not('.included').prop('disabled', true).prop('checked', false); 84 85 $('.filterTags').each(function () { 86 var that = $(this); 87 var count = that.find('input[name="tags"]:not(:disabled)').length; 88 89 if (count == 0) { 90 that.hide(); 91 } 92 else { 93 that.show(); 94 } 95 }); 96 } 97 98 if (Search.TextSearch) { 99 //show destinations 100 $('#searchResults > div').each(function () { 101 var webs = $(this).attr('data-web'); 102 $('.search-results-filters input[name="destination"]').each(function () { 103 if ((',' + webs + ',').indexOf(',' + $(this).val() + ',') > -1) { 104 $(this).addClass('included'); 105 } 106 }); 107 }); 108 $('.search-results-filters input[name="destination"]').not('.included').prop('disabled', true); 109 $('#filterDestinations a.collapsed').trigger('click'); //open interest initially 110 } 111 112 $('.search-results-filters input[name="destination"]').click(function () { 113 updateTravelStyles(); 114 updateTags();
115 }); 116 updateTravelStyles(); 117 updateTags(); 118 119 $('#filterDestinations input[name=destination]').click(function () { 120 Search.showTownListing(); 121 Search.filterInterests(); 122 }); 123 124 $('#filterTravelStyles input[name=travelStyles]').click(function () { 125 Search.filterInterests(); 126 }); 127 128 $('#filterSeasons input[name=seasonoverview]').click(function () { 129 Search.filterSeason(); 130 Search.showFilters(); 131 }); 132 $('#filterSeasons input[name=season]').click(function () { 133 Search.filterSeasonOverview(); 134 Search.showFilters(); 135 }); 136 137 $('.filterTags input[name=tags]').click(function () { 138 Search.showFilters(); 139 }); 140 141 $('.search-results-filters input[name=towns], .search-results-filters input[name=interests], .search-results-filters input[name=duration]').click(function () { 142 Search.showFilters(); 143 }); 144 145 $('#filterList a.clear').click(function () { 146 Search.clearAllFilters(); 147 Search.filterInterests(); 148 return false; 149 }); 150 151 $('#search-sort').change(function () { 152 Search.sort(); 153 }); 154 }, 155 156 showTownListing: function () { 157 var web_id = parseInt($('#filterDestinations input[name=destination]:checked').val()); 158 $('#filterTowns, #filterTowns label').hide(); 159 var hasTowns = false; 160 for (var i = 0; i < Search.Tags.length; i++) { 161 if (Search.Tags[i].WebId == web_id) { 162 for (var j = 0; j < Search.Tags[i].Tags.length; j++) { 163 if ($('#filterTowns input[value="' + Search.Tags[i].Tags[j] + '"]').length > 0) { 164 $('#filterTowns input[value="' + Search.Tags[i].Tags[j] + '"]').next().show(); 165 hasTowns = true; 166 } 167 } 168 } 169 } 170 171 if (hasTowns) { 172 $('#filterTowns').show(); 173 } 174 else { 175 $('#filterTowns input').prop('checked', false); 176 } 177 }, 178 179 filterSeason: function () { 180 var $seasons = $('.search-results-filters input[name="seasonoverview"]:checked'); 181 $('#filterSeasons input[name=season]').prop('checked', false); 182 183 if ($seasons.length > 0) { 184 if ($seasons.val() == 'all') { 185 var all = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]; 186 $('#filterSeasons input[name="season"]').each(function () { 187 if (all.indexOf($(this).val()) > -1) { 188 $(this).prop('checked', true); 189 } 190 }); 191 } 192 else if ($seasons.val() == 'summer') { 193 var summer = ["5", "6", "7", "8", "9"]; 194 $('#filterSeasons input[name="season"]').each(function () { 195 if (summer.indexOf($(this).val()) > -1) { 196 $(this).prop('checked', true); 197 } 198 }); 199 } 200 else if ($seasons.val() == 'winter') { 201 var winter = ["1", "2", "3", "4", "10", "11", "12"]; 202 $('#filterSeasons input[name="season"]').each(function () { 203 if (winter.indexOf($(this).val()) > -1) { 204 $(this).prop('checked', true); 205 } 206 }); 207 } 208 } 209 }, 210 211 filterSeasonOverview: function () { 212 var months = $('#filterSeasons input[name="season"]:checked').map(function () { return this.value; }).get().join(","); 213 if (months == "1,2,3,4,5,6,7,8,9,10,11,12") { 214 $('#filterSeasons input#seasoncheck1').prop('checked', true); 215 } 216 else if (months == "5,6,7,8,9") { 217 $('#filterSeasons input#seasoncheck2').prop('checked', true); 218 } 219 else if (months == "1,2,3,4,10,11,12") { 220 $('#filterSeasons input#seasoncheck3').prop('checked', true); 221 } 222 else { 223 $('#filterSeasons input[name=seasonoverview]').prop('checked', false); 224 } 225 }, 226 227 filterInterests: function () { 228 if ($('#filterInterests').length) { 229 var query = "destination=" + $('.search-results-filters input[name="destination"]:checked').map(function () { return this.value; }).get().join(","); 230 query += "&travelStyles=" + $('.search-results-filters input[name="travelStyles"]:checked').map(function () { return this.value; }).get().join(","); 231 232 jQuery.ajax({ 233 cache: false, 234 type: "POST", 235 url: '/ajax/tour-search-categories.aspx', 236 data: query, 237 success: function (ids) { 238 if ($('.search-results-filters input[name="destination"]:checked').size() == 0) { 239 $('#filterInterests input').each(function () { 240 $(this).next().show(); 241 }); 242 } else { 243 $('#filterInterests input').each(function () { 244 var val = $(this).val(); 245 var interestShown = false; 246 ids.forEach(function (id) { 247 if (parseInt(val) == parseInt(id)) { 248 interestShown = true; 249 } 250 }); 251 252 if (interestShown) { 253 $(this).next().show(); 254 } else { 255 $(this).prop('checked', false); 256 $(this).next().hide(); 257 } 258 259 }); 260 } 261 Search.showFilters(); 262 } 263 }); 264 } 265 else { 266 Search.showFilters(); 267 } 268 }, 269 270 showFilters: function () { 271 var $filterList = $('#filterList'); 272 var _listing = ''; 273 274 var $destination = $('.search-results-filters input[name="destination"]:checked'); 275 if ($destination.length > 0) { 276 $destination.each(function () { 277 _listing += '<a href="" onclick="return Search.removeFilter(this);" class="button-filter" data-destination="' + $(this).val() + '">' + $(this).attr('data-name') + '</a>\n'; 278 }); 279 } 280 281 var $towns = $('.search-results-filters input[name="towns"]:checked'); 282 if ($towns.length > 0) { 283 $towns.each(function () { 284 _listing += '<a href="" onclick="return Search.removeFilter(this);" class="button-filter" data-town="' + $(this).attr('data-name') + '">' + $(this).attr('data-name') + '</a>\n'; 285 }); 286 } 287 288 var $travelStyles = $('.search-results-filters input[name="travelStyles"]:checked'); 289 if ($travelStyles.length > 0) { 290 $travelStyles.each(function () { 291 _listing += '<a href="" onclick="return Search.removeFilter(this);" class="button-filter" data-travel-style="' + $(this).val() + '">' + $(this).attr('data-name') + '</a>\n'; 292 }) 293 } 294 295 var $interests = $('.search-results-filters input[name="interests"]:checked'); 296 if ($interests.length > 0) { 297 $interests.each(function () { 298 _listing += '<a href="" onclick="return Search.removeFilter(this);" class="button-filter" data-interest="' + $(this).val() + '">' + $(this).attr('data-name') + '</a>\n'; 299 }) 300 } 301 302 var $seasons = $('.search-results-filters input[name="season"]:checked'); 303 if ($seasons.length > 0) { 304 $seasons.each(function () { 305 _listing += '<a href="" onclick="return Search.removeFilter(this);" class="button-filter" data-season="' + $(this).val() + '">' + $(this).attr('data-name') + '</a>\n'; 306 }) 307 } 308 309 var $durations = $('.search-results-filters input[name="duration"]:checked'); 310 if ($durations.length > 0) { 311 $durations.each(function () { 312 _listing += '<a href="" onclick="return Search.removeFilter(this);" class="button-filter" data-duration="' + $(this).val() + '">' + $(this).attr('data-name') + '</a>\n'; 313 }) 314 } 315 316 var $tags = $('.search-results-filters input[name="tags"]:checked'); 317 if ($tags.length > 0) { 318 $tags.each(function () { 319 _listing += '<a href="" onclick="return Search.removeFilter(this);" class="button-filter" data-tour-tag="' + $(this).val() + '">' + $(this).attr('data-name') + '</a>\n'; 320 }) 321 } 322 323 $filterList.find('a:not(.clear)').remove(); 324 $filterList.prepend(_listing); 325 Search.search(); 326 }, 327 328 removeFilter: function (obj) { 329 var interestAffected = false; 330 if ($(obj).attr('data-destination') != undefined) { 331 $('.search-results-filters #filterDestinations input[value="' + $(obj).attr('data-destination') + '"]').prop('checked', false); 332 Search.showTownListing(); 333 $(obj).remove(); 334 interestAffected = true; 335 } 336 else if ($(obj).attr('data-town') != undefined) { 337 $('.search-results-filters #filterTowns input[value="' + $(obj).attr('data-town') + '"]').prop('checked', false); 338 $(obj).remove(); 339 } 340 else if ($(obj).attr('data-travel-style') != undefined) { 341 $('.search-results-filters #filterTravelStyles input[value="' + $(obj).attr('data-travel-style') + '"]').prop('checked', false); 342 $(obj).remove(); 343 interestAffected = true; 344 } 345 else if ($(obj).attr('data-interest') != undefined) { 346 $('.search-results-filters #filterInterests input[value="' + $(obj).attr('data-interest') + '"]').prop('checked', false); 347 $(obj).remove(); 348 } 349 else if ($(obj).attr('data-season') != undefined) { 350 $('.search-results-filters #filterSeasons input[value="' + $(obj).attr('data-season') + '"]').prop('checked', false); 351 Search.filterSeasonOverview(); 352 $(obj).remove(); 353 } 354 else if ($(obj).attr('data-duration') != undefined) { 355 $('.search-results-filters #filterDurations input[value="' + $(obj).attr('data-duration') + '"]').prop('checked', false); 356 $(obj).remove(); 357 } 358 else if ($(obj).attr('data-tour-tag') != undefined) { 359 $('.search-results-filters .filterTags input[value="' + $(obj).attr('data-tour-tag') + '"]').prop('checked', false); 360 $(obj).remove(); 361 } 362 363 if (interestAffected) { 364 Search.filterInterests(); 365 } else { 366 Search.search(); 367 } 368 return false; 369 }, 370 371 clearAllFilters: function () { 372 $('#filterList a:not(.clear)').remove(); 373 $('#filterTowns, #filterTowns label').hide(); 374 $('.search-results-filters input').prop('checked', false); 375 $('#filterSeasons input[name=season]').removeClass('checked'); 376 Search.search(); 377 return false; 378 }, 379 380 search: function () { 381 $('#searchLoader').show(); 382 $('#searchNotice').hide(); 383 $('#searchResults').hide(); 384 $('#search-count').text('(..)'); 385 386 if ($('#filterList a:not(.clear)').length == 0) { 387 if (Search.TextSearch) { 388 //show all initially on Text Search 389 $('#search-count').text('(' + $('#searchResults > div').size() + ')'); 390 $('#searchResults > div').each(function () { 391 var web = parseInt($(this).attr('data-primary-host')) || parseInt($(this).attr('data-host'));
392 var host = "https://" + $('#filterDestinations input[value="' + web + '"]').attr('data-host'); 393 var url = $(this).attr('data-url'); 394 var webPath = $(this).attr('data-web-path') == 'true'; 395 var fullUrl = webPath ? url : host + url; 396 $(this).find('.card-main-link,.item-link').attr('href', fullUrl); 397 $(this).find('.map-link').attr('href', fullUrl + '#map'); 398 $(this).show(); 399 }); 400 $('#searchResults').show(); 401 402 setTimeout(function () { 403 $('.card').height('auto'); 404 var cardEqualizer = new CardEqualizerSearch($('.card')); 405 }, 500); 406 407 $('#searchLoader').hide(); 408 409 } else { 410 $('#searchLoader').hide(); 411 //$('#searchNotice').show(); 412 $('#searchNotice').hide(); 413 Search.sort(); 414 let $searchResults = $('#searchResults > div'); 415 $searchResults.hide(); 416 var _count = 0; 417 418 const destinations = $('#filterDestinations input').map(function () { 419 return Number(this.value); 420 }).get(); 421 422 $searchResults.each(function () { 423 var _web = $(this).attr('data-web').split(',').map(function (s) { 424 return Number(s.trim()); 425 }); 426 const hasMatch = destinations.some(v => _web.includes(v)); 427 if (hasMatch) { 428 //generate url 429 var web = parseInt($(this).attr('data-primary-host')) || parseInt($(this).attr('data-host')); 430 var host = "https://" + $('#filterDestinations input[value="' + web + '"]').attr('data-host'); 431 var url = $(this).attr('data-url'); 432 var webPath = $(this).attr('data-web-path') == 'true'; 433 var fullUrl = webPath ? url : host + url; 434 $(this).find('.card-main-link,.item-link').attr('href', fullUrl); 435 $(this).find('.map-link').attr('href', fullUrl + '#map'); 436 437 _count++; 438 439 showCardImage(this); 440 $(this).show(); 441 } 442 }); 443 $('#search-count').text('(' + _count + ')'); 444 $('#searchLoader').hide(); 445 $('#searchResults').show(); 446 } 447 } else { 448 let $searchResults = $('#searchResults > div'); 449 $searchResults.hide(); 450 $searchResults.removeClass('d t ts i w s l tt') 451 .removeClass('lazy-search'); 452 $searchResults.removeAttr('data-host'); 453 454 if ($('#filterList a[data-destination]').length == 0) { 455 $searchResults.addClass('d'); 456 } 457 else { 458 $('#filterList a[data-destination]').each(function () { 459 var _destination = $(this).attr('data-destination'); 460 $searchResults.each(function () { 461 var _web = $(this).attr('data-web'); 462 if ((',' + _web + ',').indexOf(',' + _destination + ',') > -1) { 463 $(this).addClass('d'); 464 $(this).attr('data-host', _destination); 465 } 466 }); 467 }); 468 } 469 470 if ($('#filterList a[data-town]').length == 0) { 471 $searchResults.addClass('t'); 472 } 473 else { 474 $('#filterList a[data-town]').each(function () { 475 var _town = $(this).attr('data-town'); 476 $searchResults.each(function () { 477 var _tags = $(this).attr('data-tags'); 478 if ((',' + _tags + ',').indexOf(',town:' + _town + ',') > -1) { 479 $(this).addClass('t'); 480 } 481 }); 482 }); 483 } 484 485 if ($('#filterList a[data-travel-style]').length == 0) { 486 $searchResults.addClass('ts'); 487 } 488 else { 489 $('#filterList a[data-travel-style]').each(function () { 490 var _travelStyle = $(this).attr('data-travel-style'); 491 $searchResults.each(function () { 492 var _categories = $(this).attr('data-categories'); 493 if ((',' + _categories + ',').indexOf(',' + _travelStyle + ',') > -1) { 494 $(this).addClass('ts'); 495 } 496 }); 497 }); 498 } 499 500 501 if ($('#filterList a[data-interest]').length == 0) { 502 $searchResults.addClass('i'); 503 } 504 else { 505 if ($('#filterList a[data-interest]').length > 1) { 506 var _classes = ''; 507 $('#filterList a[data-interest]').each(function () { 508 var _interest = $(this).attr('data-interest'); 509 _classes += '.f' + _interest; 510 $searchResults.each(function () { 511 var _categories = $(this).attr('data-categories'); 512 if ((',' + _categories + ',').indexOf(',' + _interest + ',') > -1) { 513 $(this).addClass('f' + _interest); 514 } 515 }); 516 }); 517 $(_classes).addClass('i'); 518 } else { 519 $('#filterList a[data-interest]').each(function () { 520 var _interest = $(this).attr('data-interest'); 521 $searchResults.each(function () { 522 var _categories = $(this).attr('data-categories'); 523 if ((',' + _categories + ',').indexOf(',' + _interest + ',') > -1) { 524 $(this).addClass('i'); 525 } 526 }); 527 }); 528 } 529 } 530 531 if ($('#filterList a[data-season]').length == 0) { 532 $searchResults.addClass('s'); 533 } 534 else { 535 $('#filterList a[data-season]').each(function () { 536 var _season = $(this).attr('data-season'); 537 if (_season == 'all') { 538 $searchResults.addClass('s'); 539 } 540 else { 541 $searchResults.each(function () { 542 var _seasons = $(this).attr('data-seasons'); 543 if (_seasons.indexOf('{' + _season + '}') > -1) { 544 $(this).addClass('s'); 545 } 546 }); 547 } 548 }); 549 } 550 551 if ($('#filterList a[data-duration]').length == 0) { 552 $searchResults.addClass('l'); 553 } 554 else { 555 $('#filterList a[data-duration]').each(function () { 556 var _duration = $(this).attr('data-duration'); 557 var _from = parseInt(_duration.split('-')[0]); 558 var _to = parseInt(_duration.split('-')[1]); 559 $searchResults.each(function () { 560 var _days = parseInt($(this).attr('data-days')) || 0; 561 if (_days >= _from && _days <= _to) { 562 $(this).addClass('l'); 563 } 564 }); 565 }); 566 } 567 568 569 if ($('#filterList a[data-tour-tag]').length == 0) { 570 $searchResults.addClass('tt'); 571 } 572 else { 573 if ($('#filterList a[data-tour-tag]').length > 1) { 574 var _classes = ''; 575 $('#filterList a[data-tour-tag]').each(function () { 576 var _tag = $(this).attr('data-tour-tag'); 577 _classes += '.tt' + _tag; 578 $searchResults.each(function () { 579 var _tags = $(this).attr('data-tour-tags'); 580 if ((',' + _tags + ',').indexOf(',' + _tag + ',') > -1) { 581 $(this).addClass('tt' + _tag); 582 } 583 }); 584 }); 585 $(_classes).addClass('tt'); 586 } else { 587 $('#filterList a[data-tour-tag]').each(function () { 588 var _tag = $(this).attr('data-tour-tag'); 589 590 $searchResults.each(function () { 591 var _tags = $(this).attr('data-tour-tags'); 592 if ((',' + _tags + ',').indexOf(',' + _tag + ',') > -1) { 593 $(this).addClass('tt'); 594 } 595 }); 596 }); 597 } 598 } 599 600 Search.sort(); 601 $searchResults = $('#searchResults > div'); //refresh sorted 602 var _count = 0; 603 $searchResults.each(function () { 604 if ($(this).hasClass('d') && $(this).hasClass('t') && $(this).hasClass('ts') && $(this).hasClass('i') && $(this).hasClass('s') && $(this).hasClass('l') && $(this).hasClass('tt')) { 605 //generate url 606 var web = parseInt($(this).attr('data-primary-host')) || parseInt($(this).attr('data-host'));
607 var host = "https://" + $('#filterDestinations input[value="' + web + '"]').attr('data-host'); 608 var url = $(this).attr('data-url'); 609 var webPath = $(this).attr('data-web-path') == 'true'; 610 var fullUrl = webPath ? url : host + url; 611 $(this).find('.card-main-link,.item-link').attr('href', fullUrl); 612 $(this).find('.map-link').attr('href', fullUrl + '#map'); 613 614 _count++; 615 if (_count > 6) { 616 $(this).css('display', '').addClass('lazy-search'); 617 } 618 else { 619 showCardImage(this); 620 $(this).show(); 621 } 622 } 623 }); 624 625 setTimeout(function () { 626 $('.card').height('auto'); 627 var cardEqualizer = new CardEqualizerSearch($('.card')); 628 }, 500); 629 630 $('#search-count').text('(' + _count + ')'); 631 $('#searchLoader').hide(); 632 $('#searchResults').show(); 633 } 634 }, 635 636 sort: function () { 637 var sort = $('#search-sort').val(); 638 639 var getNumber = function (text) { 640 return text.replace(/\./g, '').replace(/,/g, '').replace(/ /g, ''); 641 } 642 643 var getprice = function (price) { 644 if (price) { 645 price = getNumber(price); 646 return parseInt(price); 647 } 648 return 0; 649 } 650 651 let $searchResults = $('#searchResults '); 652 if (sort == 'price+' || sort == 'price-' || sort == 'duration-' || sort == 'duration+') { 653 $searchResults.find('> div').sort(function (a, b) { 654 if (sort.indexOf('price') > -1) { 655 var aprice = getprice($(a).find('.mw').text()); 656 var bprice = getprice($(b).find('.mw').text()); 657 if (sort.indexOf('-') > -1) { 658 return bprice - aprice; 659 } else { 660 return aprice - bprice; 661 } 662 } 663 else if (sort.indexOf('duration') > -1) { 664 if (sort.indexOf('-') > -1) { 665 return (parseInt(b.dataset.days) || 0) - (parseInt(a.dataset.days) || 0); 666 } else { 667 return (parseInt(a.dataset.days) || 0) - (parseInt(b.dataset.days) || 0); 668 } 669 } 670 }) 671 .appendTo($searchResults); 672 } 673 674 if (sort == null) { 675 676 //put tours with exact match at the top first 677 678 var webs = []; 679 $('#filterList a[data-destination]').each(function () { 680 var _destination = $(this).attr('data-destination'); 681 webs.push(parseInt(_destination)); 682 }); 683 684 if (webs.length > 0) { 685 let excl = [9, 11, 29]; 686 const countries = webs.filter(x => !excl.includes(x)); 687 688 $searchResults.find('> div').each(function () { 689 let matches = -1; 690 if (webs.length == 1) { 691 var primaryHost = $(this).data('primary-host'); 692 if (webs[0] == primaryHost) { 693 //exact match 694 matches = 999; 695 } 696 } 697 698 if (matches <= 0) { 699 var thisWebs = $(this).data('web').toString().split(',').map(Number); 700 var intersections = thisWebs.filter(e => webs.indexOf(e) !== -1); 701 matches = intersections.length; 702 703 //check for exact country match 704 const thisCountries = thisWebs.filter(x => !excl.includes(x)); 705 if (countries.length > 0 && countries.length == thisCountries.length) { 706 const exactCountryMatch = countries.every((x) => thisCountries.includes(x));
707 if (exactCountryMatch) { 708 matches = 999; 709 } 710 } 711 } 712 713 $(this).data('web-match', matches); 714 }).sort(function (a, b) { 715 return $(b).data('web-match') - $(a).data('web-match'); 716 }).appendTo($searchResults); 717 } 718 } 719 else if (sort.indexOf('price') > -1) { 720 //put tours with no price at the bottom 721 var $noprice = $searchResults.find('> div[data-price=""]'); 722 $noprice.appendTo($searchResults); 723 } 724 725 } 726} 727 728 729var showCardImage = function (that) { 730 var $image = $(that).find('.card-img'); 731 if (!$image.hasClass('loaded')) { 732 var image = $image.attr('data-src'); 733 if ($(window).width() <= 480 && $image[0].hasAttribute('data-src-s')) { 734 image = $image.attr('data-src-s'); 735 } 736 else if ($(window).width() <= 980 && $image[0].hasAttribute('data-src-m')) { 737 image = $image.attr('data-src-m'); 738 } 739 $image.css('background-image', 'url("' + image + '")') 740 .addClass('loaded'); 741 } 742} 743 744$(window).scroll(function () { 745 if ($('.lazy-search').length) { 746 var containerTop = $('.search-results').offset().top; 747 var containerHeight = $('.search-results').outerHeight(); 748 var offset = containerTop + containerHeight - $(window).height(); 749 750 if ($(window).scrollTop() > offset) { 751 $('.lazy-search').slice(0, 3).each(function () { 752 showCardImage(this); 753 $(this).removeClass('lazy-search'); 754 }); 755 756 } 757 } 758}); 759 760$(document).ready(function () { 761 if ($('.text-search').length) { 762 $('.card-tour').each(function () { 763 showCardImage(this); 764 }); 765 } 766});
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.