1(function () { 2 let rtocList = []; 3 let lastScrollY = 0; 4 let lastBodyClientHeight = 0; 5 let sidebar_rtoc_wrapper = document.querySelector('.sidebar #rtoc-mokuji-wrapper'); 6 if (!sidebar_rtoc_wrapper) { 7 sidebar_rtoc_wrapper = document.querySelector('.widget #rtoc-mokuji-wrapper'); 8 } 9 if (!sidebar_rtoc_wrapper) { 10 sidebar_rtoc_wrapper = document.querySelector('.c-widget #rtoc-mokuji-wrapper'); 11 } 12 if (!sidebar_rtoc_wrapper) { 13 sidebar_rtoc_wrapper = document.querySelector('#scrollad #rtoc-mokuji-wrapper'); 14 } 15 if (!sidebar_rtoc_wrapper) { 16 sidebar_rtoc_wrapper = document.querySelector('#sideBarTracking #rtoc-mokuji-wrapper'); 17 } 18 19 if (sidebar_rtoc_wrapper) { 20 sidebar_rtoc_wrapper.classList.add('rtoc-sidebar-contents'); 21 } else { 22 return; 23 } 24 function init() { 25 rtocList = []; 26 rtocParentList = []; 27 if (sidebar_rtoc_wrapper == null) { 28 return; 29 } 30 const itemList = sidebar_rtoc_wrapper.querySelectorAll('a'); 31 const itemAllList = sidebar_rtoc_wrapper.querySelectorAll('.level-1 > .rtoc-item > a'); 32 console.log(itemList); 33 for (let i = 0; i < itemList.length; i++) { 34 const a = itemList[i];
35 const linkAnker = a.href.substring(a.href.lastIndexOf('#')); 36 const itemElement = document.querySelector(decodeURI(linkAnker)); 37 let top = itemElement.offsetTop; 38 let parent = itemElement.offsetParent; 39 while (parent != null) { 40 top += parent.offsetTop; 41 parent = parent.offsetParent; 42 } 43 rtocList.push({ top: top, bottom: 1e30, itemdom: a.parentElement }); 44 if (i > 0) { 45 rtocList[i - 1].bottom = rtocList[i].top; 46 } 47 } 48 for (let i = 0; i < itemAllList.length; i++) { 49 const a = itemAllList[i]; 50 const linkAnker = a.href.substring(a.href.lastIndexOf('#')); 51 const itemAllElement = document.querySelector(decodeURI(linkAnker)); 52 const tag = itemAllElement.tagName; 53 let top = itemAllElement.offsetTop; 54 let parent = itemAllElement.offsetParent; 55 while (parent != null) { 56 top += parent.offsetTop; 57 parent = parent.offsetParent; 58 } 59 rtocParentList.push({ top: top, bottom: 1e30, itemdom: a.parentElement }); 60 if (i > 0) { 61 rtocParentList[i - 1].bottom = rtocParentList[i].top; 62 } 63 } 64 } 65 init(); 66 function updateSection(scrollY) { 67 if (document.body.clientHeight !== lastBodyClientHeight) { 68 init(); 69 } 70 for (let sec of rtocList) { 71 sec.itemdom.classList.remove('rtoc-current'); 72 } 73 for (let sec of rtocParentList) { 74 sec.itemdom.classList.remove('rtoc-show'); 75 } 76 77 for (let i = 0; i < rtocList.length; i++) { 78 const sec = rtocList[i]; 79 if (sec.top <= scrollY && scrollY < sec.bottom) { 80 sec.itemdom.classList.add('rtoc-current'); 81 break; 82 } 83 } 84 for (let i = 0; i < rtocParentList.length; i++) { 85 const sec = rtocParentList[i]; 86 if (sec.top <= scrollY && scrollY < sec.bottom) { 87 sec.itemdom.classList.add('rtoc-show'); 88 break; 89 } 90 } 91 } 92 function widgetScroll(hiddenDOM) { 93 const highlightContents = sidebar_rtoc_wrapper.querySelector('.rtoc-current'); 94 if (!highlightContents) return; 95 } 96 97 let ticking = false; 98 const scrollHeight = sidebar_rtoc_wrapper.querySelector('.rtoc-mokuji').scrollHeight; 99 const displayHeight = sidebar_rtoc_wrapper.querySelector('.rtoc-mokuji').offsetHeight; 100 document.addEventListener('scroll', function () { 101 lastScrollY = window.scrollY; 102 if (ticking === false) { 103 window.requestAnimationFrame(function () { 104 updateSection(lastScrollY + 300); 105 ticking = false; 106 }); 107 ticking = true; 108 } 109 if (scrollHeight > displayHeight) { 110 widgetScroll(scrollHeight - displayHeight); 111 } 112 }); 113})();
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.