1$(document).ready(function () { 2 3 const filterCategory = $('[data-category-filter]'); 4 let activeContainer = $(); 5 const mediaContainer = $('.media-container'); 6 const $switch = $("#toggle-eligible-credits-video"); 7 let creditCheckActived = false; 8 let tagFilterActived = false; 9 10 function categoryFilter(e, target) { 11 const ths = $(e.currentTarget); 12 let targetContainer; 13 14 if ($.isArray(target)) { 15 activeContainer = $(); 16 target.forEach((i => { 17 targetContainer = mediaContainer.filter(`[data-category="${i}"]`); 18 activeContainer = activeContainer.add(targetContainer); 19 })) 20 } else { 21 targetContainer = mediaContainer.filter(`[data-category="${target}"]`); 22 if (ths.hasClass('active-filter-tag')) { 23 ths.removeClass('active-filter-tag'); 24 activeContainer = activeContainer.not(targetContainer); 25 } else { 26 ths.addClass('active-filter-tag'); 27 activeContainer = activeContainer.add(targetContainer); 28 } 29 } 30 31 if (activeContainer.length === 0) { 32 mediaContainer.show(); 33 } else { 34 mediaContainer.hide(); 35 activeContainer.show(); 36 } 37 $("#tag_filter_select").change(); 38 }; 39 40 if (filterCategory) { 41 filterCategory.click(function (e) { 42 const ths = $(this); 43 const target = ths.attr('data-category-filter'); 44 categoryFilter(e, target); 45 }); 46 }; 47 48 $("#cat-dropdwn-aux").change(function (e) { 49 const values = $(this).val(); 50 categoryFilter(e, values) 51 }); 52 53 54 $("#tag_filter_select").change(function (e) { 55 const values = $(this).val(); 56 let data; 57 const containers = activeContainer.length ? activeContainer : mediaContainer; 58 $.each(containers, function (index, container) { 59 let cardsToShow = $(); 60 const $container = $(container); 61 const allCards = $container.data('mediaGroup').dataSrc; 62 $.each(allCards, function (i, card) { 63 const tags = $(card).find('.tags-group .tags'); 64 $.each(tags, function (indx, tag) { 65 cardsToShow = letFilter(values, creditCheckActived, tag, cardsToShow, card); 66 }) 67 }); 68 69 if (values.length === 0 && !creditCheckActived) { 70 data = allCards; 71 tagFilterActived = false; 72 } else { 73 data = cardsToShow; 74 tagFilterActived = true; 75 } 76 $container.data('mediaGroup')._init(data); 77 if (!$('.media-container:visible').length) { 78 const d = $('<div></div>', { 79 class: "container filter-no-data", 80 text: 'No Data' 81 }); 82 $('.filter-no-data').remove(); 83 d.insertAfter($('.sticky-filter')); 84 } else { 85 $('.filter-no-data').remove(); 86 } 87 }); 88 }); 89 90 $switch.change(function () { 91 const isChecked = $(this).prop("checked"); 92 creditCheckActived = isChecked; 93 $("#tag_filter_select").change(); 94 }); 95}); 96 97function letFilter(values, creditCheckActived, tag, cardsToShow, card) { 98 if (values.length && creditCheckActived) { 99 if (values.includes($(tag).text())) { 100 cardsToShow = cardsToShow.add(card); 101 let hasCredit = $(card).find('.vcredit').length; 102 if (!hasCredit) { 103 cardsToShow = cardsToShow.not(card); 104 } 105 } 106 } else if (values.length && !creditCheckActived) { 107 if (values.includes($(tag).text())) { 108 cardsToShow = cardsToShow.add(card); 109 } 110 } else if (!values.length && creditCheckActived) { 111 let hasCredit = $(card).find('.vcredit').length; 112 if (hasCredit) { 113 cardsToShow = cardsToShow.add(card); 114 } 115 } 116 return cardsToShow; 117} 118
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.