1(function () { 2 'use strict'; 3 4 const selector = '.lkc-content .lkc-excerpt'; 5 6 function getLineHeight(style) { 7 const lineHeight = parseFloat(style.lineHeight); 8 if (Number.isFinite(lineHeight) && lineHeight > 0) { 9 return lineHeight; 10 } 11 12 const fontSize = parseFloat(style.fontSize); 13 return Number.isFinite(fontSize) && fontSize > 0 ? fontSize * 1.2 : 16; 14 } 15 16 function fitExcerpt(excerpt) { 17 const content = excerpt.closest('.lkc-content'); 18 if (!content) { 19 return; 20 } 21 22 excerpt.style.maxHeight = ''; 23 24 const contentStyle = window.getComputedStyle(content); 25 if (contentStyle.overflowY === 'visible' && contentStyle.overflow === 'visible') { 26 return; 27 } 28 29 const excerptStyle = window.getComputedStyle(excerpt); 30 const lineHeight = getLineHeight(excerptStyle); 31 const contentRect = content.getBoundingClientRect(); 32 const excerptRect = excerpt.getBoundingClientRect(); 33 const paddingTop = parseFloat(excerptStyle.paddingTop) || 0; 34 const paddingBottom = parseFloat(excerptStyle.paddingBottom) || 0; 35 const borderTop = parseFloat(excerptStyle.borderTopWidth) || 0; 36 const borderBottom = parseFloat(excerptStyle.borderBottomWidth) || 0; 37 const reservedHeight = paddingTop + paddingBottom + borderTop + borderBottom; 38 const available = contentRect.bottom - excerptRect.top - reservedHeight; 39 const lines = Math.floor(available / lineHeight); 40 41 if (lines <= 0) { 42 excerpt.style.maxHeight = '0px'; 43 return; 44 } 45 46 const maxHeight = lines * lineHeight + (excerptStyle.boxSizing === 'border-box' ? reservedHeight : 0); 47 excerpt.style.maxHeight = maxHeight + 'px'; 48 } 49 50 function fitAll() { 51 document.querySelectorAll(selector).forEach(fitExcerpt); 52 } 53 54 let resizeTimer = 0; 55 function requestFit() { 56 window.clearTimeout(resizeTimer); 57 resizeTimer = window.setTimeout(fitAll, 50); 58 } 59 60 if (document.readyState === 'loading') { 61 document.addEventListener('DOMContentLoaded', fitAll); 62 } else { 63 fitAll(); 64 } 65 66 window.addEventListener('load', fitAll); 67 window.addEventListener('resize', requestFit); 68})();
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.