1/** 2 * Copyright (C) 2024 Clément Latzarus 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU Affero General Public License as published 6 * by the Free Software Foundation, version 3. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Affero General Public License for more details. 12 * 13 * You should have received a copy of the GNU Affero General Public License 14 * along with this program. If not, see <https://www.gnu.org/licenses/>. 15 */ 16 17document.addEventListener('DOMContentLoaded', function() { 18 19 const applyButton = document.getElementById('listApply'); 20 if (!applyButton) return; 21 22 // Choix en attente, appliqués seulement au clic sur "Actualiser" 23 const pendingParams = new URLSearchParams(window.location.search); 24 pendingParams.delete('p'); 25 pendingParams.delete('s'); 26 pendingParams.delete('_FORMAT'); 27 28 function rememberChoice(link, keys) { 29 const linkParams = new URL(link.href, window.location.href).searchParams; 30 keys.forEach(function(key) { 31 if (linkParams.has(key)) pendingParams.set(key, linkParams.get(key)); 32 else pendingParams.delete(key); 33 }); 34 pendingParams.delete('p'); 35 } 36 37 function markSelected(link, group) { 38 group.forEach(function(a) { a.removeAttribute('data-selected'); }); 39 link.setAttribute('data-selected', 'true'); 40 } 41 42 // Filtre (Afficher :) 43 const filterLinks = document.querySelectorAll('#listFilter .dropdown-item'); 44 const filterButton = document.querySelector('#listFilter > button'); 45 filterLinks.forEach(function(link) { 46 link.addEventListener('click', function(e) { 47 e.preventDefault(); 48 rememberChoice(link, ['q']); 49 markSelected(link, filterLinks); 50 filterButton.innerHTML = 51 '<i class="fa fa-square ' + link.dataset.color + '"></i> ' + 52 link.textContent.trim() + ' <span class="caret"></span>'; 53 }); 54 }); 55 56 // Tri (Trier par :) 57 const sortLinks = document.querySelectorAll('#listSort .dropdown-item'); 58 const sortButton = document.querySelector('#listSort > button'); 59 sortLinks.forEach(function(link) { 60 link.addEventListener('click', function(e) { 61 e.preventDefault(); 62 rememberChoice(link, ['o', 'd']); 63 markSelected(link, sortLinks); 64 sortButton.innerHTML = link.textContent.trim() + ' <span class="caret"></span>'; 65 }); 66 }); 67 68 applyButton.addEventListener('click', function() { 69 const query = pendingParams.toString(); 70 window.location.href = window.location.pathname + (query ? '?' + query : ''); 71 }); 72 73});
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.