github.com/Racer159/jackal@v0.32.7-0.20240401174413-0bd2339e4f2e/src/internal/packager/sbom/viewer/common.js (about) 1 const sbomSelector = document.getElementById('sbom-selector'); 2 const distroInfo = document.getElementById('distro-info'); 3 const modal = document.getElementById('modal'); 4 const modalFader = document.getElementById('modal-fader'); 5 const modalTitle = document.getElementById('modal-title'); 6 const modalContent = document.getElementById('modal-content'); 7 const artifactsTable = document.createElement('table'); 8 const mailtoMaintainerReplace = ` | <a href="mailto:$1">$1</a>`; 9 10 document.body.appendChild(artifactsTable); 11 12 function fileList(files, artifactName) { 13 if (files) { 14 const list = (files || []).map((file) => file.path || '').filter((test) => test); 15 16 if (list.length > 0) { 17 flatList = list.sort().join('<br>'); 18 return `<a href="#" onClick="showModal('${ 19 artifactName 20 }','${flatList}')">${list.length} files</a>`; 21 } 22 } 23 24 return '-'; 25 } 26 27 function choose(path) { 28 if (path !== '-') { 29 window.location.href = encodeURIComponent(`sbom-viewer-${path}.html`); 30 } 31 } 32 33 function exportCSV(path) { 34 if (window.dt) { 35 window.dt.export({ 36 type: 'csv', 37 filename: path 38 }); 39 } else { 40 showModal('Unable to Export', 'No data in current table'); 41 } 42 } 43 44 function showModal(title, list) { 45 modalTitle.innerText = `Files for ${title}`; 46 modalContent.innerHTML = list; 47 modalFader.className = 'active'; 48 modal.className = 'active'; 49 } 50 51 function hideModal() { 52 modalFader.className = ''; 53 modal.className = ''; 54 modalTitle.innerText = ''; 55 modalContent.innerHTML = ''; 56 }