1(function() { 2 'use strict'; 3 4 var citeData = null; 5 var activeStyle = 'bibtex'; 6 var lastView = 'app'; 7 var lastLabel = null; 8 9 window.openCiteModal = function(view, label) { 10 lastView = view || 'app'; 11 lastLabel = label || null; 12 var modal = document.getElementById('cite-modal'); 13 if (!modal) return; 14 var output = document.getElementById('cite-output'); 15 if (output) output.textContent = 'Loading...'; 16 modal.classList.add('active'); 17 18 // Reset to BibTeX tab 19 activeStyle = 'bibtex'; 20 document.querySelectorAll('.cite-style-tab').forEach(function(btn) { 21 btn.classList.toggle('active', btn.getAttribute('data-style') === 'bibtex'); 22 }); 23 24 var url = location.origin + location.pathname + location.search; 25 var qs = '?view=' + encodeURIComponent(lastView) 26 + (lastLabel ? '&label=' + encodeURIComponent(lastLabel) : '') 27 + '&url=' + encodeURIComponent(url); 28 29 fetch('/api/citation' + qs) 30 .then(function(r) { return r.json(); }) 31 .then(function(data) { 32 citeData = data; 33 renderActiveStyle(); 34 }) 35 .catch(function() { 36 if (output) output.textContent = 'Error loading citation.'; 37 }); 38 }; 39 40 window.closeCiteModal = function() { 41 var modal = document.getElementById('cite-modal'); 42 if (modal) modal.classList.remove('active'); 43 }; 44 45 window.switchCiteStyle = function(style) { 46 activeStyle = style; 47 document.querySelectorAll('.cite-style-tab').forEach(function(btn) { 48 btn.classList.toggle('active', btn.getAttribute('data-style') === style); 49 }); 50 renderActiveStyle(); 51 }; 52 53 window.copyCitation = function() { 54 var output = document.getElementById('cite-output'); 55 if (!output) return; 56 var text = output.textContent; 57 if (navigator.clipboard) { 58 navigator.clipboard.writeText(text).then(function() { 59 flashCopyButton(); 60 }); 61 } else { 62 var ta = document.createElement('textarea'); 63 ta.value = text; 64 document.body.appendChild(ta); 65 ta.select(); 66 try { document.execCommand('copy'); flashCopyButton(); } catch (e) {} 67 document.body.removeChild(ta); 68 } 69 }; 70 71 function renderActiveStyle() { 72 var output = document.getElementById('cite-output'); 73 if (!output || !citeData || !citeData.styles) return; 74 output.textContent = citeData.styles[activeStyle] || ''; 75 } 76 77 function flashCopyButton() { 78 var btn = document.querySelector('.cite-copy-btn'); 79 if (!btn) return; 80 var orig = btn.innerHTML; 81 btn.innerHTML = '<span class="material-symbols-outlined">check</span> Copied'; 82 setTimeout(function() { btn.innerHTML = orig; }, 1500); 83 } 84 85 document.addEventListener('keydown', function(e) { 86 if (e.key === 'Escape') closeCiteModal(); 87 }); 88})();
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.