1$(document).ready(function() { 2 3 function waitForElements(callback) { 4 var checkExist = setInterval(function() { 5 if ( 6 $('.directoryListFilters').length && 7 $('.directoryEntry').length && 8 $('.directoryEntries').length 9 ) { 10 clearInterval(checkExist); 11 callback(); 12 } 13 }, 100); 14 } 15 16 waitForElements(function() { 17 18 var $filterList = $('.directoryListFilters'); 19 var $filters = $filterList.find('.filter'); 20 var $mixerContainer = $('.directoryEntries'); 21 22 // Sauvegarder lâordre dâorigine 23 var $entries = $mixerContainer.find('.directoryEntry'); 24 $entries.each(function(i) { 25 $(this).attr('data-original-order', i); 26 }); 27 28 // Tri alphabétique des tags (ZâA) 29 var sortedFilters = $filters.sort(function(a, b) { 30 var A = $(a).attr('data-filter').toLowerCase(); 31 var B = $(b).attr('data-filter').toLowerCase(); 32 return B.localeCompare(A); 33 }); 34 $filters.detach(); 35 $filterList.empty().append(sortedFilters); 36 37 // Initialisation MixItUp V2 38 $mixerContainer.mixItUp({ 39 selectors: { target: '.directoryEntry', filter: '.filter' }, 40 load: { filter: 'all' }, 41 animation: { effects: 'fade scale', duration: 450 } 42 }); 43 44 // Récupérer le tag actif 45 function getCurrentFilter() { 46 var $active = $filterList.find('.filter.active'); 47 return $active.length ? $active.attr('data-filter') : 'all'; 48 } 49 50 // Parser date 51 function parseDate($entry) { 52 var txt = $entry.find('.filtre-date').text().trim(); 53 if (!txt) return new Date(0); 54 var p = txt.split('/'); 55 return new Date(p[2], p[1] - 1, p[0]); 56 } 57 58 // Tri par date 59 function sortByDate(desc) { 60 var $list = $mixerContainer.find('.directoryEntry'); 61 var sorted = $list.sort(function(a, b) { 62 var dA = parseDate($(a)); 63 var dB = parseDate($(b)); 64 return desc ? dB - dA : dA - dB; 65 }); 66 $list.detach(); 67 $mixerContainer.append(sorted); 68 $mixerContainer.mixItUp('filter', getCurrentFilter()); 69 } 70 71 // Tri alphabétique 72 function sortAlphabetical(asc) { 73 var $list = $mixerContainer.find('.directoryEntry'); 74 var sorted = $list.sort(function(a, b) { 75 var A = $(a).text().trim().toLowerCase(); 76 var B = $(b).text().trim().toLowerCase(); 77 return asc ? A.localeCompare(B) : B.localeCompare(A); 78 }); 79 $list.detach(); 80 $mixerContainer.append(sorted); 81 $mixerContainer.mixItUp('filter', getCurrentFilter()); 82 } 83 84 // Reset ordre 85 function resetOrder() { 86 var $list = $mixerContainer.find('.directoryEntry'); 87 var sorted = $list.sort(function(a, b) { 88 return $(a).data('original-order') - $(b).data('original-order'); 89 }); 90 $list.detach(); 91 $mixerContainer.append(sorted); 92 $mixerContainer.mixItUp('filter', getCurrentFilter()); 93 } 94 95 // 96 // === Gestion boutons === 97 // 98 var dateDesc = true; 99 var alphaAsc = true; 100 101 $('#sort-date').on('click', function() { 102 dateDesc = !dateDesc; 103 $(this).text(dateDesc ? "â³ Date â" : "â³ Date â"); 104 sortByDate(dateDesc); 105 }); 106 107 $('#sort-alpha').on('click', function() { 108 alphaAsc = !alphaAsc; 109 $(this).text(alphaAsc ? "ð¤ A â Z" : "ð¤ Z â A"); 110 sortAlphabetical(alphaAsc); 111 }); 112 113 $('#sort-reset').on('click', function() { 114 dateDesc = true; 115 alphaAsc = true; 116 $('#sort-date').text("â³ Date â"); 117 $('#sort-alpha').text("ð¤ A â Z"); 118 resetOrder(); 119 }); 120 121 });
122 123});
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.