1if (document.body.className.indexOf('api-page') !== -1) { 2 3 let elems = document.querySelectorAll('h2, h3, h4, tr'); 4 5 for (let i = 0, len = elems.length; i < len; i++) { 6 const el = elems[i]; 7 8 if (el.id) { 9 const anchor = document.createElement('a'); 10 anchor.setAttribute('data-anchor', el.id); 11 if (!el.children.length) { 12 // For headers, insert the anchor before. 13 el.parentNode.insertBefore(anchor, el); 14 15 // Clicking on the row (meaning "the link icon on the ::before) 16 // jumps to the item 17 el.onclick = function () { 18 return function (ev) { 19 if (ev.offsetX < 0) { 20 window.location.hash = `#${ev.target.id}`; 21 } 22 }; 23 }(el.id); 24 } else { 25 // For table rows, insert the anchor inside the first <td> 26 el.querySelector('td').appendChild(anchor); 27 28 // Clicking on the row (meaning "the link icon on the ::before) 29 // jumps to the item 30 el.parentNode.onclick = function () { 31 return function (ev) { 32 if (ev.offsetX < 0) { 33 window.location.hash = `#${ev.target.parentNode.id}`; 34 } 35 }; 36 }(el.id); 37 } 38 } 39 } 40 41 elems = document.querySelectorAll('div.accordion'); 42 for (let i = 0, len = elems.length; i < len; i++) { 43 const el = elems[i]; 44 45 el.querySelector('label').addEventListener('click', function (c) { 46 return function () { 47 if (c.className === 'accordion expanded') { 48 c.className = 'accordion collapsed'; 49 } else { 50 c.className = 'accordion expanded'; 51 } 52 }; 53 }(el)); 54 55 // el.className = 'accordion collapsed'; 56 // el.querySelector('.accordion-content').style.display = 'none'; 57 } 58 59 60 // open accordion of anchor if collapsed 61 const urlAnchor = location.hash; 62 if (urlAnchor) { 63 const fnc = function () { 64 // timeout because the page is not finished loading with collapsed accordions 65 setTimeout(() => { 66 // .closest('.accordion') would be a alternative but is not working in IE 67 const getParentAccordion = function (el) { 68 while (el.parentNode && (` ${el.parentNode.className} `).indexOf(' accordion ') === -1) { 69 el = el.parentNode; 70 } 71 return el.parentNode && (` ${el.parentNode.className} `).indexOf(' accordion ') > -1 ? el.parentNode : null; 72 }; 73 74 const elm = document.getElementById(urlAnchor.substring(1)); 75 if (elm) { 76 const parent = getParentAccordion(elm); 77 if (parent) { 78 parent.className = 'accordion expanded'; 79 } 80 // For Firefox: Accordion have to be expanded before scrolling 81 setTimeout(() => { 82 elm.scrollIntoView(); 83 }, 10); 84 } 85 }, 100); 86 }; 87 window.addEventListener('load', fnc); 88 } 89}
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.